Skip to content

Commit a668bbe

Browse files
authored
Merge pull request #102 from videlec
bnf_get_fu and bnf_get_tu
2 parents 03c41c5 + 9ef0d64 commit a668bbe

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed

cypari2/gen.pyx

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,76 @@ cdef class Gen(Gen_base):
893893
sig_on()
894894
return clone_gen(member_zk(self.g))
895895

896+
def bnf_get_fu(self):
897+
"""
898+
Return the fundamental units
899+
900+
Examples:
901+
902+
>>> from cypari2 import Pari
903+
>>> pari = Pari()
904+
905+
>>> x = pari('x')
906+
907+
>>> (x**2 - 65).bnfinit().bnf_get_fu()
908+
[Mod(x - 8, x^2 - 65)]
909+
>>> (x**4 - x**2 + 1).bnfinit().bnf_get_fu()
910+
[Mod(x - 1, x^4 - x^2 + 1)]
911+
>>> p = x**8 - 40*x**6 + 352*x**4 - 960*x**2 + 576
912+
>>> len(p.bnfinit().bnf_get_fu())
913+
7
914+
"""
915+
sig_on()
916+
return clone_gen(member_fu(self.g))
917+
918+
def bnf_get_tu(self):
919+
r"""
920+
Return the torsion unit
921+
922+
Examples:
923+
924+
>>> from cypari2 import Pari
925+
>>> pari = Pari()
926+
927+
>>> x = pari('x')
928+
929+
>>> for p in [x**2 - 65, x**4 - x**2 + 1, x**8 - 40*x**6 + 352*x**4 - 960*x**2 + 576]:
930+
... bnf = p.bnfinit()
931+
... n, z = bnf.bnf_get_tu()
932+
... if pari.version() < (2,11,0) and z.lift().poldegree() == 0: z = z.lift()
933+
... print([p, n, z])
934+
[x^2 - 65, 2, -1]
935+
[x^4 - x^2 + 1, 12, Mod(x, x^4 - x^2 + 1)]
936+
[x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576, 2, -1]
937+
"""
938+
sig_on()
939+
return clone_gen(member_tu(self.g))
940+
941+
def bnfunit(self):
942+
r"""
943+
Deprecated in cypari 2.1.2
944+
945+
Examples:
946+
947+
>>> from cypari2 import Pari
948+
>>> pari = Pari()
949+
950+
951+
>>> x = pari('x')
952+
953+
>>> import warnings
954+
>>> with warnings.catch_warnings(record=True) as w:
955+
... warnings.simplefilter('always')
956+
... funits = (x**2 - 65).bnfinit().bnfunit()
957+
... assert len(w) == 1
958+
... assert issubclass(w[0].category, DeprecationWarning)
959+
>>> funits
960+
[Mod(x - 8, x^2 - 65)]
961+
"""
962+
from warnings import warn
963+
warn("'bnfunit' in cypari2 is deprecated, use 'bnf_get_fu'", DeprecationWarning)
964+
return self.bnf_get_fu()
965+
896966
def bnf_get_no(self):
897967
"""
898968
Returns the class number of ``self``, a "big number field" (``bnf``).
@@ -969,10 +1039,6 @@ cdef class Gen(Gen_base):
9691039
sig_on()
9701040
return clone_gen(bnf_get_reg(self.g))
9711041

972-
def bnfunit(self):
973-
sig_on()
974-
return clone_gen(bnf_get_fu(self.g))
975-
9761042
def idealmoddivisor(self, Gen ideal):
9771043
"""
9781044
Return a 'small' ideal equivalent to ``ideal`` in the

0 commit comments

Comments
 (0)