Karim.Belabas on Sat, 12 May 2001 12:18:42 +0200 (MET DST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Changing PARI types |
On Fri, 11 May 2001, Gerhard Niklasch wrote: > In response to: > > Message-ID: <Pine.SOL.3.96.1010511082001.8135A-100000@elios> > > Date: Fri, 11 May 2001 08:28:52 +0100 (BST) > > From: Mark Chimley <M.Chimley@bristol.ac.uk> > > > > I have used "ground" to round the coefficients of a polynomial to the > > nearest integers, however the type of the coefficients remains at 6 > > (probably real or complex). This means that rootsmod (GEN) cannot handle > > the polynomial (the error actually comes from factormod, which is used > > by rootsmod). Is it possible to change the type of the coefficients so > > that they can be handled by rootsmod? > > > > For example, can I do something like: > > > > settyp (H [i], 1); > > > > for each coefficient, or would this be horribly dangerous? > > That would change the type marker of the object whilst leaving > the bit pattern as it is, and is very unlikely to result in a > recognizable PARI integer! As a matter of fact, it will. A "random" 31 bit integer presumably (corresponding to the adress of the real part). > (Look up "type" in the manual or > online help.) But you can get an integer directly: > > ===8<--- > (17:23) gp > ??round [...] > So, grndtoi() is what you're looking for. Well, the difference between ground and grndtoi is that the latter cannot fail with an error message: (13:16) gp > round (1.5e30) \\ ground behaviour *** precision loss in truncation (13:16) gp > round(1.5e30, &e) \\ rndtoi behaviour %1 = 1500000000000000000000000000000 (13:16) gp > e %2 = 5 (so the last 5 bits are subject to caution) I think the real problem is (13:18) gp > type(round(0*I)) %3 = "t_COMPLEX" Whereas: (13:16) gp > round(0*I) %4 = 0 (13:18) gp > type (%) %5 = "t_INT" In that case, the answer is simplify(). [ or ground(greal()) if you don't want to check accuracy ] 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://www.parigp-home.de/