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

Commit

Permalink
switched to powcomputer_
Browse files Browse the repository at this point in the history
  • Loading branch information
saraedum committed Jan 4, 2014
1 parent 02ffe57 commit 52010f3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
64 changes: 32 additions & 32 deletions src/sage/libs/linkages/padics/mpz.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import sage.rings.finite_rings.integer_mod
cdef Integer holder = PY_NEW(Integer)
cdef Integer holder2 = PY_NEW(Integer)

cdef inline int cconstruct(mpz_t value, PowComputer_class prime_pow) except -1:
cdef inline int cconstruct(mpz_t value, PowComputer_ prime_pow) except -1:
"""
Construct a new element.
Expand All @@ -44,7 +44,7 @@ cdef inline int cconstruct(mpz_t value, PowComputer_class prime_pow) except -1:
"""
mpz_init(value)

cdef inline int cdestruct(mpz_t value, PowComputer_class prime_pow) except -1:
cdef inline int cdestruct(mpz_t value, PowComputer_ prime_pow) except -1:
"""
Deallocate an element.
Expand All @@ -55,7 +55,7 @@ cdef inline int cdestruct(mpz_t value, PowComputer_class prime_pow) except -1:
"""
mpz_clear(value)

cdef inline int ccmp(mpz_t a, mpz_t b, long prec, bint reduce_a, bint reduce_b, PowComputer_class prime_pow) except -2:
cdef inline int ccmp(mpz_t a, mpz_t b, long prec, bint reduce_a, bint reduce_b, PowComputer_ prime_pow) except -2:
"""
Comparison of two elements.
Expand Down Expand Up @@ -88,7 +88,7 @@ cdef inline int ccmp(mpz_t a, mpz_t b, long prec, bint reduce_a, bint reduce_b,
return -1
return 0

cdef inline int cneg(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cneg(mpz_t out, mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Negation.
Expand All @@ -103,7 +103,7 @@ cdef inline int cneg(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow)
"""
mpz_neg(out, a)

cdef inline int cadd(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cadd(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_ prime_pow) except -1:
"""
Addition.
Expand All @@ -119,7 +119,7 @@ cdef inline int cadd(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class p
"""
mpz_add(out, a, b)

cdef inline bint creduce(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline bint creduce(mpz_t out, mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Reduce modulo a power of the maximal ideal.
Expand All @@ -137,7 +137,7 @@ cdef inline bint creduce(mpz_t out, mpz_t a, long prec, PowComputer_class prime_
mpz_mod(out, a, prime_pow.pow_mpz_t_tmp(prec)[0])
return mpz_sgn(out) == 0

cdef inline bint creduce_small(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline bint creduce_small(mpz_t out, mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Reduce modulo a power of the maximal ideal.
Expand All @@ -163,7 +163,7 @@ cdef inline bint creduce_small(mpz_t out, mpz_t a, long prec, PowComputer_class
mpz_set(out, a)
return mpz_sgn(out) == 0

cdef inline long cremove(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline long cremove(mpz_t out, mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Extract the maximum power of the uniformizer dividing this
element.
Expand All @@ -185,7 +185,7 @@ cdef inline long cremove(mpz_t out, mpz_t a, long prec, PowComputer_class prime_
return prec
return mpz_remove(out, a, prime_pow.prime.value)

cdef inline long cvaluation(mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline long cvaluation(mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Returns the maximum power of the uniformizer dividing this
element.
Expand All @@ -208,7 +208,7 @@ cdef inline long cvaluation(mpz_t a, long prec, PowComputer_class prime_pow) exc
return prec
return mpz_remove(holder.value, a, prime_pow.prime.value)

cdef inline bint cisunit(mpz_t a, PowComputer_class prime_pow) except -1:
cdef inline bint cisunit(mpz_t a, PowComputer_ prime_pow) except -1:
"""
Returns whether this element has valuation zero.
Expand All @@ -223,7 +223,7 @@ cdef inline bint cisunit(mpz_t a, PowComputer_class prime_pow) except -1:
"""
return mpz_divisible_p(a, prime_pow.prime.value) == 0

cdef inline int cshift(mpz_t out, mpz_t a, long n, long prec, PowComputer_class prime_pow, bint reduce_afterward) except -1:
cdef inline int cshift(mpz_t out, mpz_t a, long n, long prec, PowComputer_ prime_pow, bint reduce_afterward) except -1:
"""
Mulitplies by a power of the uniformizer.
Expand All @@ -249,7 +249,7 @@ cdef inline int cshift(mpz_t out, mpz_t a, long n, long prec, PowComputer_class
if reduce_afterward:
creduce(out, out, prec, prime_pow)

cdef inline int cshift_notrunc(mpz_t out, mpz_t a, long n, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cshift_notrunc(mpz_t out, mpz_t a, long n, long prec, PowComputer_ prime_pow) except -1:
"""
Mulitplies by a power of the uniformizer, assuming that the
valuation of a is at least -n.
Expand All @@ -274,7 +274,7 @@ cdef inline int cshift_notrunc(mpz_t out, mpz_t a, long n, long prec, PowCompute
else:
mpz_set(out, a)

cdef inline int csub(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class prime_pow) except -1:
cdef inline int csub(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_ prime_pow) except -1:
"""
Subtraction.
Expand All @@ -290,7 +290,7 @@ cdef inline int csub(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class p
"""
mpz_sub(out, a, b)

cdef inline int cinvert(mpz_t out, mpz_t a, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cinvert(mpz_t out, mpz_t a, long prec, PowComputer_ prime_pow) except -1:
"""
Inversion.
Expand All @@ -308,7 +308,7 @@ cdef inline int cinvert(mpz_t out, mpz_t a, long prec, PowComputer_class prime_p
if not success:
raise ZeroDivisionError

cdef inline int cmul(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cmul(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_ prime_pow) except -1:
"""
Multiplication.
Expand All @@ -324,7 +324,7 @@ cdef inline int cmul(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class p
"""
mpz_mul(out, a, b)

cdef inline int cdivunit(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cdivunit(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_ prime_pow) except -1:
"""
Division.
Expand All @@ -345,7 +345,7 @@ cdef inline int cdivunit(mpz_t out, mpz_t a, mpz_t b, long prec, PowComputer_cla
raise ZeroDivisionError
mpz_mul(out, a, out)

cdef inline int csetone(mpz_t out, PowComputer_class prime_pow) except -1:
cdef inline int csetone(mpz_t out, PowComputer_ prime_pow) except -1:
"""
Sets to 1.
Expand All @@ -356,7 +356,7 @@ cdef inline int csetone(mpz_t out, PowComputer_class prime_pow) except -1:
"""
mpz_set_ui(out, 1)

cdef inline int csetzero(mpz_t out, PowComputer_class prime_pow) except -1:
cdef inline int csetzero(mpz_t out, PowComputer_ prime_pow) except -1:
"""
Sets to 0.
Expand All @@ -367,7 +367,7 @@ cdef inline int csetzero(mpz_t out, PowComputer_class prime_pow) except -1:
"""
mpz_set_ui(out, 0)

cdef inline bint cisone(mpz_t out, PowComputer_class prime_pow) except -1:
cdef inline bint cisone(mpz_t out, PowComputer_ prime_pow) except -1:
"""
Returns whether this element is equal to 1.
Expand All @@ -382,7 +382,7 @@ cdef inline bint cisone(mpz_t out, PowComputer_class prime_pow) except -1:
"""
return mpz_cmp_ui(out, 1) == 0

cdef inline bint ciszero(mpz_t out, PowComputer_class prime_pow) except -1:
cdef inline bint ciszero(mpz_t out, PowComputer_ prime_pow) except -1:
"""
Returns whether this element is equal to 0.
Expand All @@ -397,7 +397,7 @@ cdef inline bint ciszero(mpz_t out, PowComputer_class prime_pow) except -1:
"""
return mpz_cmp_ui(out, 0) == 0

cdef inline int cpow(mpz_t out, mpz_t a, mpz_t n, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cpow(mpz_t out, mpz_t a, mpz_t n, long prec, PowComputer_ prime_pow) except -1:
"""
Exponentiation.
Expand All @@ -411,7 +411,7 @@ cdef inline int cpow(mpz_t out, mpz_t a, mpz_t n, long prec, PowComputer_class p
"""
mpz_powm(out, a, n, prime_pow.pow_mpz_t_tmp(prec)[0])

cdef inline int ccopy(mpz_t out, mpz_t a, PowComputer_class prime_pow) except -1:
cdef inline int ccopy(mpz_t out, mpz_t a, PowComputer_ prime_pow) except -1:
"""
Copying.
Expand All @@ -423,7 +423,7 @@ cdef inline int ccopy(mpz_t out, mpz_t a, PowComputer_class prime_pow) except -1
"""
mpz_set(out, a)

cdef inline cpickle(mpz_t a, PowComputer_class prime_pow):
cdef inline cpickle(mpz_t a, PowComputer_ prime_pow):
"""
Serialization into objects that Sage knows how to pickle.
Expand All @@ -440,7 +440,7 @@ cdef inline cpickle(mpz_t a, PowComputer_class prime_pow):
mpz_set(pic.value, a)
return pic

cdef inline int cunpickle(mpz_t out, x, PowComputer_class prime_pow) except -1:
cdef inline int cunpickle(mpz_t out, x, PowComputer_ prime_pow) except -1:
"""
Reconstruction from the output of meth:`cpickle`.
Expand All @@ -452,7 +452,7 @@ cdef inline int cunpickle(mpz_t out, x, PowComputer_class prime_pow) except -1:
"""
mpz_set(out, (<Integer?>x).value)

cdef inline long chash(mpz_t a, long ordp, long prec, PowComputer_class prime_pow) except -1:
cdef inline long chash(mpz_t a, long ordp, long prec, PowComputer_ prime_pow) except -1:
"""
Hashing.
Expand Down Expand Up @@ -480,7 +480,7 @@ cdef inline long chash(mpz_t a, long ordp, long prec, PowComputer_class prime_po
return -2
return n

cdef clist(mpz_t a, long prec, bint pos, PowComputer_class prime_pow):
cdef clist(mpz_t a, long prec, bint pos, PowComputer_ prime_pow):
"""
Returns a list of digits in the series expansion.
Expand Down Expand Up @@ -540,7 +540,7 @@ cdef clist(mpz_t a, long prec, bint pos, PowComputer_class prime_pow):
# It could be [] for some other linkages.
_list_zero = Integer(0)

cdef int cteichmuller(mpz_t out, mpz_t value, long prec, PowComputer_class prime_pow) except -1:
cdef int cteichmuller(mpz_t out, mpz_t value, long prec, PowComputer_ prime_pow) except -1:
"""
Teichmuller lifting.
Expand Down Expand Up @@ -584,7 +584,7 @@ cdef int cteichmuller(mpz_t out, mpz_t value, long prec, PowComputer_class prime
mpz_add(holder2.value, holder2.value, out)
mpz_mod(holder2.value, holder2.value, prime_pow.pow_mpz_t_tmp(prec)[0])

cdef int cconv(mpz_t out, x, long prec, long valshift, PowComputer_class prime_pow) except -2:
cdef int cconv(mpz_t out, x, long prec, long valshift, PowComputer_ prime_pow) except -2:
"""
Conversion from other Sage types.
Expand All @@ -604,7 +604,7 @@ cdef int cconv(mpz_t out, x, long prec, long valshift, PowComputer_class prime_p
"""
return cconv_shared(out, x, prec, valshift, prime_pow)

cdef inline long cconv_mpq_t(mpz_t out, mpq_t x, long prec, bint absolute, PowComputer_class prime_pow) except? -10000:
cdef inline long cconv_mpq_t(mpz_t out, mpq_t x, long prec, bint absolute, PowComputer_ prime_pow) except? -10000:
"""
A fast pathway for conversion of rationals that doesn't require
precomputation of the valuation.
Expand All @@ -627,7 +627,7 @@ cdef inline long cconv_mpq_t(mpz_t out, mpq_t x, long prec, bint absolute, PowCo
"""
return cconv_mpq_t_shared(out, x, prec, absolute, prime_pow)

cdef inline int cconv_mpq_t_out(mpq_t out, mpz_t x, long valshift, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cconv_mpq_t_out(mpq_t out, mpz_t x, long valshift, long prec, PowComputer_ prime_pow) except -1:
"""
Converts the underlying `p`-adic element into a rational
Expand All @@ -640,7 +640,7 @@ cdef inline int cconv_mpq_t_out(mpq_t out, mpz_t x, long valshift, long prec, Po
"""
return cconv_mpq_t_out_shared(out, x, valshift, prec, prime_pow)

cdef inline long cconv_mpz_t(mpz_t out, mpz_t x, long prec, bint absolute, PowComputer_class prime_pow) except -2:
cdef inline long cconv_mpz_t(mpz_t out, mpz_t x, long prec, bint absolute, PowComputer_ prime_pow) except -2:
"""
A fast pathway for conversion of integers that doesn't require
precomputation of the valuation.
Expand All @@ -663,7 +663,7 @@ cdef inline long cconv_mpz_t(mpz_t out, mpz_t x, long prec, bint absolute, PowCo
"""
return cconv_mpz_t_shared(out, x, prec, absolute, prime_pow)

cdef inline int cconv_mpz_t_out(mpz_t out, mpz_t x, long valshift, long prec, PowComputer_class prime_pow) except -1:
cdef inline int cconv_mpz_t_out(mpz_t out, mpz_t x, long valshift, long prec, PowComputer_ prime_pow) except -1:
"""
Converts the underlying `p`-adic element into an integer if
possible.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/CA_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ def unpickle_cae_v2(cls, parent, value, absprec):
"""
cdef CAElement ans = PY_NEW(cls)
ans._parent = parent
ans.prime_pow = <PowComputer_class?>parent.prime_pow
ans.prime_pow = <PowComputer_?>parent.prime_pow
cconstruct(ans.value, ans.prime_pow)
cunpickle(ans.value, value, ans.prime_pow)
ans.absprec = absprec
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/CR_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ def unpickle_cre_v2(cls, parent, unit, ordp, relprec):
"""
cdef CRElement ans = PY_NEW(cls)
ans._parent = parent
ans.prime_pow = <PowComputer_class?>parent.prime_pow
ans.prime_pow = <PowComputer_?>parent.prime_pow
cconstruct(ans.unit, ans.prime_pow)
cunpickle(ans.unit, unit, ans.prime_pow)
ans.ordp = ordp
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/FM_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def unpickle_fme_v2(cls, parent, value):
"""
cdef FMElement ans = PY_NEW(cls)
ans._parent = parent
ans.prime_pow = <PowComputer_class?>parent.prime_pow
ans.prime_pow = <PowComputer_?>parent.prime_pow
cconstruct(ans.value, ans.prime_pow)
cunpickle(ans.value, value, ans.prime_pow)
return ans
1 change: 1 addition & 0 deletions src/sage/rings/padics/padic_capped_relative_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include "CR_template.pxi"
from sage.libs.pari.pari_instance cimport PariInstance
cdef PariInstance P = sage.libs.pari.pari_instance.pari
from sage.rings.finite_rings.integer_mod import Mod
from sage.rings.padics.pow_computer cimport PowComputer_class

cdef class PowComputer_(PowComputer_base):
def __init__(self, Integer prime, long cache_limit, long prec_cap, long ram_prec_cap, bint in_field):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/rings/padics/padic_template_element.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement):
<type 'sage.rings.padics.padic_capped_relative_element.pAdicCappedRelativeElement'>
sage: TestSuite(a).run()
"""
self.prime_pow = <PowComputer_class?>parent.prime_pow
self.prime_pow = <PowComputer_?>parent.prime_pow
pAdicGenericElement.__init__(self, parent)
cdef long val, xprec
cdef GEN pari_tmp
Expand Down Expand Up @@ -417,7 +417,7 @@ cdef class pAdicTemplateElement(pAdicGenericElement):
"""
return self.prime_pow

cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowComputer_class prime_pow):
cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowComputer_ prime_pow):
"""
This function is used by exponentiation in both CR_template.pxi
and CA_template.pxi to determine the extra precision gained from
Expand Down Expand Up @@ -457,7 +457,7 @@ cdef Integer exact_pow_helper(long *ansrelprec, long relprec, _right, PowCompute
return right

cdef long padic_pow_helper(celement result, celement base, long base_val, long base_relprec,
celement right_unit, long right_val, long right_relprec, PowComputer_class prime_pow) except -1:
celement right_unit, long right_val, long right_relprec, PowComputer_ prime_pow) except -1:
"""
INPUT:
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/padics/padic_template_element_header.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ AUTHORS:

from sage.structure.element cimport ModuleElement, RingElement
from sage.rings.padics.padic_generic_element cimport pAdicGenericElement
from sage.rings.padics.pow_computer cimport PowComputer_class

cdef class pAdicTemplateElement(pAdicGenericElement):
cdef PowComputer_class prime_pow
cdef PowComputer_ prime_pow
cdef int _set(self, x, long val, long xprec, absprec, relprec) except -1
cdef pAdicTemplateElement _lshift_c(self, long shift)
cdef pAdicTemplateElement _rshift_c(self, long shift)
Expand Down

0 comments on commit 52010f3

Please sign in to comment.