Karim BELABAS on Thu, 17 Apr 2003 15:54:14 +0200 (MEST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: point notation |
On 17 Apr 2003, Markus Endres wrote: > I'm going to write a routine called GrInit which initialize a group ring > K[G] (like nfinit or bnfinit) in some way, returns something like the > wedderburn decomposition, K-irreducible characters, the maximal order > and something more. > > now, I want to use the point notation as in nfinit/bnfinit. that means, > I want a possibility to call my results like K.disc in K=nfinit(pol), as > example: KG=GrInit(...); KG.Kchi; which returns the characters > > This point notation would be very useful for me. Is there any > possibility to write such a 'point notation' by my own? (11:25) gp > x.Kchi = x[2] \\ definition (11:25) gp > [1,2,3].Kchi %1 = 2 It's paragraph 2.6.4 in User's manual (stable branch. It's 2.6.5 in CVS). See my "Contributed GP scripts" page for some examples, especially http://www.math.u-psud.fr/~belabas/pari/scripts/modsym.gp Caveats: 1) this might work better (i.e faster, possibly more reliable) on the _unstable_ branch (i.e from CVS). 2) for trivial accessors like the above, member functions are about twice slower than direct access (that's still about 10^6 accesses per second on a 1GHz machine). OTOH, member functions are much _faster_ than general user functions, in particular argument passing is much more efficient [ user functions copy their arguments, member functions don't. Allowing passing arguments as pointers has been discussed, but is not implemented yet ] ? D(nf) = nf[3] ? nf.D = nf[3] ? nf = nfinit(x^10-2); ? for (i=1,10000, D(nf)); time = 1,990 ms. \\ 10000 useless copies ... ? for (i=1,10000, nf.D); time = 20 ms. Hope this helps, Karim. -- Karim Belabas Tel: (+33) (0)1 69 15 57 48 Dép. de Mathématiques, Bât. 425 Fax: (+33) (0)1 69 15 60 19 Université Paris-Sud http://www.math.u-psud.fr/~belabas/ F-91405 Orsay (France) http://www.parigp-home.de/ [PARI/GP]