Karim BELABAS on Tue, 20 Oct 1998 17:43:14 +0200 (MET DST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Member Functions |
Follow-up to myself: > > Is it possible to define new member functions with pari?, i would like to > > create new structures (similar to elliptic functions or number fields) and > > extract the information via the "dot" notation. > > It's not possible interactively. You have to modify the source code. It will > be quite easy if you're minimally profficient with C (or have access to > somebody who is): just add the new "member" in gp_member_list (in > language/anal.c) and write the corresponding (trivial) C function. > > [... quick C sample deleted ...] > > An interface to GP scripting language would be easily implemented, so that > new members could be defined at GP level and call a user function instead > of a pre-compiled routine. The above definition might then look like: > > check_ell_type(x)= if (type(x) != "t_VEC" || length(x) < 14, error("...")) > > x.j= check_ell_type(x); ell[13] > > I'll think about it. Don't expect it in 2.0.12, though... I lied: this will be in 2.0.12. The syntax check_ell_type(x)= if (type(x) != "t_VEC" || length(x) < 14, error("...")) ell.j = check_ell_type(ell); ell[13] \\ better than the obvious typo above... or equivalently { ell.j = if (...); ell[13] } is recognized right now in my private version ["x.z" statements are treated as special instances of user functions ".z" with a single argument "x"]. Karim, packaging 2.0.12. -- Karim Belabas email: Karim.Belabas@math.u-psud.fr Dep. de Mathematiques, Bat. 425 Universite Paris-Sud Tel: (00 33) 1 69 15 57 48 F-91405 Orsay (France) Fax: (00 33) 1 69 15 60 19 -- PARI/GP Home Page: http://pari.home.ml.org