Skip to content

Commit 8bd7ca3

Browse files
committed
remove various autogenerated functions in gen.pyx
- various pol functions - precision
1 parent f4889b3 commit 8bd7ca3

File tree

2 files changed

+21
-88
lines changed

2 files changed

+21
-88
lines changed

cypari2/gen.pyx

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,24 +2611,6 @@ cdef class Gen(Gen_base):
26112611
"""
26122612
return self.new_ref(gel(self.fixGEN(), 2))
26132613

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-
26322614
def round(x, bint estimate=False):
26332615
"""
26342616
round(x,estimate=False): If x is a real number, returns x rounded
@@ -3686,6 +3668,19 @@ cdef class Gen(Gen_base):
36863668
[1, 1/10000000019*x]
36873669
>>> pari(f).nfbasis(fa=[2,p]) # Equivalent with the above
36883670
[1, 1/10000000019*x]
3671+
3672+
The following alternative syntax closer to PARI/GP can be used
3673+
3674+
>>> pari.nfbasis([f, 1])
3675+
[1, x]
3676+
>>> pari.nfbasis(f)
3677+
[1, 1/10000000019*x]
3678+
>>> pari.nfbasis([f, 10**6])
3679+
[1, x]
3680+
>>> pari.nfbasis([f, "[2,2; %s,2]"%p])
3681+
[1, 1/10000000019*x]
3682+
>>> pari.nfbasis([f, [2,p]])
3683+
[1, 1/10000000019*x]
36893684
"""
36903685
cdef Gen t0
36913686
cdef GEN g0
@@ -4115,38 +4110,6 @@ cdef class Gen(Gen_base):
41154110
sig_on()
41164111
return new_gen(factorpadic(self.g, t0.g, r))
41174112

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-
41504113
def ncols(self):
41514114
"""
41524115
Return the number of columns of self.
@@ -4699,20 +4662,14 @@ cpdef Gen objtogen(s):
46994662
47004663
Conversion from reals uses the real's own precision:
47014664
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
4665+
>>> a = pari(1.2); a, a.type(), a.bitprecision()
4666+
(1.20000000000000, 't_REAL', 64)
47084667
47094668
Conversion from strings uses the current PARI real precision.
47104669
By default, this is 64 bits:
47114670
4712-
>>> a = pari('1.2'); a, a.type()
4713-
(1.20000000000000, 't_REAL')
4714-
>>> a.precision() == (4 if bitness == '32' else 3)
4715-
True
4671+
>>> a = pari('1.2'); a, a.type(), a.bitprecision()
4672+
(1.20000000000000, 't_REAL', 64)
47164673
47174674
Unicode and bytes work fine:
47184675
@@ -4725,11 +4682,10 @@ cpdef Gen objtogen(s):
47254682
47264683
>>> pari.set_real_precision(35) # precision in decimal digits
47274684
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
4685+
>>> a = pari('Pi'); a, a.type(), a.bitprecision()
4686+
(3.1415926535897932384626433832795029, 't_REAL', 128)
4687+
>>> a = pari('1.2'); a, a.type(), a.bitprecision()
4688+
(1.2000000000000000000000000000000000, 't_REAL', 128)
47334689
47344690
Set the precision to 15 digits for the remaining tests:
47354691

tests/test_backward.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,5 @@ def test_poldegree(self):
2727
self.assertEqual(pari('x*y^2 + 1').poldegree(pari('x')), 1)
2828
self.assertEqual(pari('x*y^2 + 1').poldegree(pari('y')), 2)
2929

30-
def test_nfbasis(self):
31-
pari = cypari2.Pari()
32-
x = pari('x')
33-
third = pari('1/3')
34-
self.assertEqual(pari(x**3 - 17).nfbasis(), [1, x, third*x**2 - third*x + third])
35-
36-
p = pari(10**10).nextprime()
37-
q = (p+1).nextprime()
38-
x = pari('x')
39-
f = x**2 + p**2*q
40-
# Correct result
41-
frac = pari('1/10000000019')
42-
self.assertEqual(pari(f).nfbasis(), [1, frac*x])
43-
44-
# Wrong result
45-
self.assertEqual(pari.nfbasis([f,1]), [1, x])
46-
# Check primes up to 10^6: wrong result
47-
self.assertEqual(pari.nfbasis([f, 10**6]), [1, x])
48-
# Correct result and faster
49-
self.assertEqual(pari.nfbasis([f, pari("[2,2; %s,2]"%p)]), [1, frac*x])
50-
# Equivalent with the above
51-
self.assertEqual(pari.nfbasis([f, [2,p]]), [1, frac*x])
52-
5330
if __name__ == '__main__':
5431
unittest.main()

0 commit comments

Comments
 (0)