Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
added an _new_fmpz_poly method
Browse files Browse the repository at this point in the history
  • Loading branch information
saraedum committed Jan 4, 2014
1 parent 52010f3 commit 13a2d60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/sage/rings/padics/pow_computer_flint.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ cdef class PowComputer_flint_1step(PowComputer_flint):
cdef fmpz_poly_t* _moduli
cdef fmpz_poly_t* get_modulus(self, unsigned long n)
cdef fmpz_poly_t* get_modulus_capdiv(self, unsigned long n)
cdef _new_fmpz_poly(self, fmpz_poly_t value, var=*)

cdef class PowComputer_flint_unram(PowComputer_flint_1step):
# WARNING:
# These variables are modified by the linkage and must no be used anywhere else
# (other than in __(c)init__)
cdef fmpz_t fmpz_ccmp, fmpz_cval, fmpz_cinv, fmpz_cinv2, fmpz_clist, fmpz_clist2, fmpz_ctm, fmpz_cconv
cdef fmpz_poly_t poly_cconv, poly_ctm, poly_ccmp, poly_cinv, poly_cisunit, poly_cinv2
cdef fmpz_poly_t poly_cconv, poly_ctm, poly_ccmp, poly_cinv, poly_cisunit, poly_cinv2, poly_flint_rep
cdef mpz_t mpz_cpow, mpz_ctm, mpz_cconv

cdef class PowComputer_flint_eis(PowComputer_flint_1step):
Expand Down
28 changes: 22 additions & 6 deletions src/sage/rings/padics/pow_computer_flint.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from sage.libs.flint.fmpz_poly cimport *
from sage.libs.flint.nmod_vec cimport *
from sage.libs.flint.fmpz_vec cimport *
from sage.rings.integer cimport Integer
from sage.rings.all import ZZ
from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint

cdef class PowComputer_flint(PowComputer_class):
Expand Down Expand Up @@ -368,7 +369,6 @@ cdef class PowComputer_flint_1step(PowComputer_flint):
sage: A.polynomial(2)
x^3 + 17*x + 23
"""
from sage.rings.all import ZZ
R = ZZ[var]
x = R.gen()
cdef Polynomial_integer_dense_flint ans = (<Polynomial_integer_dense_flint?>x)._new()
Expand All @@ -378,6 +378,17 @@ cdef class PowComputer_flint_1step(PowComputer_flint):
fmpz_poly_set(ans.__poly, self.get_modulus(_n)[0])
return ans

cdef _new_fmpz_poly(self, fmpz_poly_t value, var='x'):
"""
Returns a polynomial with the value stored in ``value`` and
variable name ``var``.
"""
R = ZZ[var]
x = R.gen()
cdef Polynomial_integer_dense_flint ans = (<Polynomial_integer_dense_flint?>x)._new()
fmpz_poly_set(ans.__poly, value)
return ans

cdef class PowComputer_flint_unram(PowComputer_flint_1step):
"""
A PowComputer for a `p`-adic extension defined by an unramified polynomial.
Expand Down Expand Up @@ -428,16 +439,21 @@ cdef class PowComputer_flint_unram(PowComputer_flint_1step):
try:
fmpz_poly_init(self.poly_cinv2)
try:
mpz_init(self.mpz_cpow)
fmpz_poly_init(self.poly_flint_rep)
try:
mpz_init(self.mpz_ctm)
mpz_init(self.mpz_cpow)
try:
mpz_init(self.mpz_cconv)
mpz_init(self.mpz_ctm)
try:
mpz_init(self.mpz_cconv)
except:
mpz_clear(self.mpz_ctm)
raise
except:
mpz_clear(self.mpz_ctm)
mpz_clear(self.mpz_cpow)
raise
except:
mpz_clear(self.mpz_cpow)
fmpz_poly_clear(self.poly_flint_rep)
raise
except:
fmpz_poly_clear(self.poly_cinv2)
Expand Down

0 comments on commit 13a2d60

Please sign in to comment.