@@ -134,11 +134,14 @@ cdef extern from *:
134
134
#endif
135
135
136
136
#if PARI_VERSION_CODE >= PARI_VERSION(2, 12, 0)
137
- #define nfbasis(x, yptr, p) nfbasis(mkvec2(x, p), yptr)
137
+ #define old_nfbasis(x, yptr, p) nfbasis(mkvec2(x, p), yptr)
138
+ #else
139
+ #define old_nfbasis nfbasis
138
140
#endif
139
141
"""
140
142
GEN new_nf_nfzk(GEN nf, GEN rnfeq)
141
143
GEN new_nfeltup(GEN nf, GEN x, GEN zknf)
144
+ GEN old_nfbasis(GEN x, GEN * y, GEN p)
142
145
143
146
144
147
cdef class Gen(Gen_base):
@@ -2611,24 +2614,6 @@ cdef class Gen(Gen_base):
2611
2614
"""
2612
2615
return self .new_ref(gel(self .fixGEN(), 2 ))
2613
2616
2614
- def precision (x , long n = - 1 ):
2615
- """
2616
- Change the precision of `x` to be `n`, where `n` is an integer.
2617
- If `n` is omitted, output the real precision of `x`.
2618
-
2619
- INPUT:
2620
-
2621
- - ``x`` - gen
2622
-
2623
- - ``n`` - (optional) int
2624
-
2625
- OUTPUT: gen
2626
- """
2627
- if n <= 0 :
2628
- return precision(x.g)
2629
- sig_on()
2630
- return new_gen(precision0(x.g, n))
2631
-
2632
2617
def round (x , bint estimate = False ):
2633
2618
"""
2634
2619
round(x,estimate=False): If x is a real number, returns x rounded
@@ -3686,6 +3671,19 @@ cdef class Gen(Gen_base):
3686
3671
[1, 1/10000000019*x]
3687
3672
>>> pari(f).nfbasis(fa=[2,p]) # Equivalent with the above
3688
3673
[1, 1/10000000019*x]
3674
+
3675
+ The following alternative syntax closer to PARI/GP can be used
3676
+
3677
+ >>> pari.nfbasis([f, 1])
3678
+ [1, x]
3679
+ >>> pari.nfbasis(f)
3680
+ [1, 1/10000000019*x]
3681
+ >>> pari.nfbasis([f, 10**6])
3682
+ [1, x]
3683
+ >>> pari.nfbasis([f, "[2,2; %s ,2]"%p ])
3684
+ [1, 1/10000000019*x]
3685
+ >>> pari.nfbasis([f, [2,p]])
3686
+ [1, 1/10000000019*x]
3689
3687
"""
3690
3688
cdef Gen t0
3691
3689
cdef GEN g0
@@ -3697,7 +3695,7 @@ cdef class Gen(Gen_base):
3697
3695
else :
3698
3696
g0 = NULL
3699
3697
sig_on()
3700
- return new_gen(nfbasis (self .g, NULL , g0))
3698
+ return new_gen(old_nfbasis (self .g, NULL , g0))
3701
3699
3702
3700
def nfbasis_d (self , long flag = 0 , fa = None ):
3703
3701
"""
@@ -3731,7 +3729,7 @@ cdef class Gen(Gen_base):
3731
3729
else :
3732
3730
g0 = NULL
3733
3731
sig_on()
3734
- ans = nfbasis (self .g, & disc, g0)
3732
+ ans = old_nfbasis (self .g, & disc, g0)
3735
3733
return new_gens2(ans, disc)
3736
3734
3737
3735
def nfbasistoalg_lift (nf , x ):
@@ -4115,38 +4113,6 @@ cdef class Gen(Gen_base):
4115
4113
sig_on()
4116
4114
return new_gen(factorpadic(self .g, t0.g, r))
4117
4115
4118
- def poldegree (self , var = None ):
4119
- """
4120
- Return the degree of this polynomial.
4121
- """
4122
- sig_on()
4123
- n = poldegree(self .g, get_var(var))
4124
- sig_off()
4125
- return n
4126
-
4127
- def polisirreducible (self ):
4128
- """
4129
- f.polisirreducible(): Returns True if f is an irreducible
4130
- non-constant polynomial, or False if f is reducible or constant.
4131
- """
4132
- sig_on()
4133
- t = polisirreducible(self .g)
4134
- clear_stack()
4135
- return t != 0
4136
-
4137
- def polroots (self , unsigned long precision = 0 ):
4138
- """
4139
- Complex roots of the given polynomial using Schonhage's method,
4140
- as modified by Gourdon.
4141
- """
4142
- sig_on()
4143
- return new_gen(cleanroots(self .g, prec_bits_to_words(precision)))
4144
-
4145
- def rnfisnorm (self , T , long flag = 0 ):
4146
- cdef Gen t0 = objtogen(T)
4147
- sig_on()
4148
- return new_gen(rnfisnorm(t0.g, self .g, flag))
4149
-
4150
4116
def ncols (self ):
4151
4117
"""
4152
4118
Return the number of columns of self.
@@ -4699,20 +4665,14 @@ cpdef Gen objtogen(s):
4699
4665
4700
4666
Conversion from reals uses the real's own precision:
4701
4667
4702
- >>> a = pari(1.2); a, a.type()
4703
- (1.20000000000000, 't_REAL')
4704
- >>> import sys
4705
- >>> bitness = '64' if sys.maxsize > (1 << 32) else '32'
4706
- >>> a.precision() == (4 if bitness == '32' else 3)
4707
- True
4668
+ >>> a = pari(1.2); a, a.type(), a.bitprecision()
4669
+ (1.20000000000000, 't_REAL', 64)
4708
4670
4709
4671
Conversion from strings uses the current PARI real precision.
4710
4672
By default, this is 64 bits:
4711
4673
4712
- >>> a = pari('1.2'); a, a.type()
4713
- (1.20000000000000, 't_REAL')
4714
- >>> a.precision() == (4 if bitness == '32' else 3)
4715
- True
4674
+ >>> a = pari('1.2'); a, a.type(), a.bitprecision()
4675
+ (1.20000000000000, 't_REAL', 64)
4716
4676
4717
4677
Unicode and bytes work fine:
4718
4678
@@ -4725,11 +4685,10 @@ cpdef Gen objtogen(s):
4725
4685
4726
4686
>>> pari.set_real_precision(35) # precision in decimal digits
4727
4687
15
4728
- >>> a = pari('1.2'); a, a.type()
4729
- (1.2000000000000000000000000000000000, 't_REAL')
4730
- >>> bitness = '64' if sys.maxsize > (1 << 32) else '32'
4731
- >>> a.precision() == (6 if bitness == '32' else 4)
4732
- True
4688
+ >>> a = pari('Pi'); a, a.type(), a.bitprecision()
4689
+ (3.1415926535897932384626433832795029, 't_REAL', 128)
4690
+ >>> a = pari('1.2'); a, a.type(), a.bitprecision()
4691
+ (1.2000000000000000000000000000000000, 't_REAL', 128)
4733
4692
4734
4693
Set the precision to 15 digits for the remaining tests:
4735
4694
0 commit comments