Karim BELABAS on Mon, 19 Oct 1998 12:46:35 +0200 (MET DST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Member Functions |
> 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. Ex: the ell.j construct (= read 13th component, in the current implementation of the "ell" type) is defined by the following lines: { "j",(void*)j }, static GEN j(GEN x) { if (!is_ell(x)) err(member,"j",mark.member,mark.start); return (GEN)x[13]; } An interface to GP scripting language would be easily implemented, so that they 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... Karim. -- 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