Karim Belabas on Thu, 10 Apr 2014 12:14:51 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
+oo / -oo (infinity) |
Hi pari-dev, after toying with the idea for a few years, I finally bit the bullet and introduced a new type t_INFINITY, containing only 2 objects \pm\infty (printed respectively as +oo / -oo). It's meant as a "placeholder" for functions that accept \pm\infty as a parameter or produce it as a result: ? poldegree(0) %1 = -oo ? valuation(0, 2) %2 = +oo ? K = nfinit(x^2+1); P = idealprimedec(K,2)[1]; ? nfeltval(K,0,P) %4 = +oo ? idealval(K,[;],P) %5 = +oo ? intnum(t=0, +oo, 1/(t^2+1)) %6 = 1.5707963267948966192313216916397514421 The only implemented methods are: negation, comparison with real scalars (and infinities), equality tests and all variants of print(): ? -(-oo) %7 = +oo ? -oo < Pi %8 = 1 ? -oo < +oo %9 = 1 ? oo == 1 %10 = 0 ? oo == oo %11 = 1 ? printtex(-oo) -\infty 1) In particular, you can't "compute" with such objects: ? oo + 1 *** at top-level: oo+1 *** ^-- *** _+_: forbidden addition t_INT + t_INFINITY. ? I * oo *** at top-level: I*oo *** ^--- *** _*_: forbidden multiplication t_COMPLEX * t_INFINITY. 2) This isn't meant to handle floating point overflow either ? exp(1e100) *** at top-level: exp(1e100) *** ^---------- *** exp: overflow in expo(). It's a bit sad to "waste" a type for only two objects so far, but it was the only sensible possibility. (I definitely didn't want to abuse one of the existing types, e.g. taking advantage of "impossible values" for t_REAL codewords.) Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite Bordeaux 1 Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux1.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux1.fr/ [PARI/GP] `