本文整理汇总了Python中sage.libs.pari.all.pari函数的典型用法代码示例。如果您正苦于以下问题:Python pari函数的具体用法?Python pari怎么用?Python pari使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pari函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _call_
def _call_(self, v):
r"""
EXAMPLE::
sage: L.<b> = NumberField(x^4 + 3*x^2 + 1)
sage: K = L.relativize(L.subfields(2)[0][1], 'a')
sage: a0 = K.gen(); b0 = K.base_field().gen()
sage: V, fr, to = K.relative_vector_space()
sage: fr(to(a0 + 2*b0)), fr(V([0, 1])), fr(V([b0, 2*b0])) # indirect doctest
(a0 + 2*b0, a0, 2*b0*a0 + b0)
"""
# Given a relative vector space element, we have to
# compute the corresponding number field element, in terms
# of an absolute generator.
w = self.__V(v).list()
# First, construct from w a PARI polynomial in x with coefficients
# that are polynomials in y:
B = self.__B
_, to_B = B.structure()
# Apply to_B, so now each coefficient is in an absolute field,
# and is expressed in terms of a polynomial in y, then make
# the PARI poly in x.
w = [pari(to_B(a).polynomial('y')) for a in w]
h = pari(w).Polrev()
# Next we write the poly in x over a poly in y in terms
# of an absolute polynomial for the rnf.
g = self.__R(self.__rnf.rnfeltreltoabs(h))
return self.__K._element_class(self.__K, g)
开发者ID:sageb0t,项目名称:testsage,代码行数:30,代码来源:maps.py
示例2: _pari_modulus
def _pari_modulus(self):
"""
EXAMPLES:
sage: GF(3^4,'a')._pari_modulus()
Mod(1, 3)*a^4 + Mod(2, 3)*a^3 + Mod(2, 3)
"""
f = pari(str(self.modulus()))
return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic())
开发者ID:dagss,项目名称:sage,代码行数:8,代码来源:finite_field_givaro.py
示例3: _element_constructor_
def _element_constructor_(self, u):
"""
Returns the abstract group element corresponding to the unit u.
INPUT:
- ``u`` -- Any object from which an element of the unit group's number
field `K` may be constructed; an error is raised if an element of `K`
cannot be constructed from u, or if the element constructed is not a
unit.
EXAMPLES::
sage: x = polygen(QQ)
sage: K.<a> = NumberField(x^2-38)
sage: UK = UnitGroup(K)
sage: UK(1)
1
sage: UK(-1)
u0
sage: UK.gens()
(u0, u1)
sage: UK.gens_values()
[-1, 6*a - 37]
sage: UK.ngens()
2
sage: [UK(u) for u in UK.gens()]
[u0, u1]
sage: [UK(u).exponents() for u in UK.gens()]
[(1, 0), (0, 1)]
sage: UK(a)
Traceback (most recent call last):
...
ValueError: a is not a unit
"""
K = self.__number_field
pK = self.__pari_number_field
try:
u = K(u)
except TypeError:
raise ValueError("%s is not an element of %s"%(u,K))
if self.__S:
m = pK.bnfissunit(self.__S_unit_data, pari(u)).mattranspose()
if m.ncols()==0:
raise ValueError("%s is not an S-unit"%u)
else:
if not u.is_integral() or u.norm().abs() != 1:
raise ValueError("%s is not a unit"%u)
m = pK.bnfisunit(pari(u)).mattranspose()
# convert column matrix to a list:
m = [ZZ(m[0,i].python()) for i in range(m.ncols())]
# NB pari puts the torsion after the fundamental units, before
# the extra S-units but we have the torsion first:
m = [m[self.__nfu]] + m[:self.__nfu] + m[self.__nfu+1:]
return self.element_class(self, m)
开发者ID:chiragsinghal283,项目名称:sage,代码行数:58,代码来源:unit_group.py
示例4: exponential_integral_1
def exponential_integral_1(x, n=0):
r"""
Returns the exponential integral `E_1(x)`. If the optional
argument `n` is given, computes list of the first
`n` values of the exponential integral
`E_1(x m)`.
The exponential integral `E_1(x)` is
.. math::
E_1(x) = \int_{x}^{\infty} e^{-t}/t dt
INPUT:
- ``x`` - a positive real number
- ``n`` - (default: 0) a nonnegative integer; if
nonzero, then return a list of values E_1(x\*m) for m =
1,2,3,...,n. This is useful, e.g., when computing derivatives of
L-functions.
OUTPUT:
- ``float`` - if n is 0 (the default) or
- ``list`` - list of floats if n 0
EXAMPLES::
sage: exponential_integral_1(2)
0.04890051070806112
sage: w = exponential_integral_1(2,4); w
[0.04890051070806112, 0.003779352409848906..., 0.00036008245216265873, 3.7665622843924...e-05]
IMPLEMENTATION: We use the PARI C-library functions eint1 and
veceint1.
REFERENCE:
- See page 262, Prop 5.6.12, of Cohen's book "A Course in
Computational Algebraic Number Theory".
REMARKS: When called with the optional argument n, the PARI
C-library is fast for values of n up to some bound, then very very
slow. For example, if x=5, then the computation takes less than a
second for n=800000, and takes "forever" for n=900000.
"""
if n <= 0:
return float(pari(x).eint1())
else:
return [float(z) for z in pari(x).eint1(n)]
开发者ID:bgxcpku,项目名称:sagelib,代码行数:58,代码来源:transcendental.py
示例5: _pari_modulus
def _pari_modulus(self):
"""
Return the modulus of ``self`` in a format for PARI.
EXAMPLES::
sage: GF(3^4,'a')._pari_modulus()
Mod(1, 3)*a^4 + Mod(2, 3)*a^3 + Mod(2, 3)
"""
f = pari(str(self.modulus()))
return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic())
开发者ID:bukzor,项目名称:sage,代码行数:11,代码来源:finite_field_givaro.py
示例6: _pari_modulus
def _pari_modulus(self):
"""
Return PARI object which is equivalent to the
polynomial/modulus of ``self``.
EXAMPLES::
sage: k1.<a> = GF(2^16)
sage: k1._pari_modulus()
Mod(1, 2)*a^16 + Mod(1, 2)*a^5 + Mod(1, 2)*a^3 + Mod(1, 2)*a^2 + Mod(1, 2)
"""
f = pari(str(self.modulus()))
return f.subst('x', 'a') * pari("Mod(1,%s)"%self.characteristic())
开发者ID:mcognetta,项目名称:sage,代码行数:13,代码来源:finite_field_ntl_gf2e.py
示例7: _complex_mpfr_field_
def _complex_mpfr_field_(self, CC):
"""
Return ComplexField element of self.
INPUT:
- ``CC`` -- a Complex or Real Field.
EXAMPLES::
sage: z = gp(1+15*I); z
1 + 15*I
sage: z._complex_mpfr_field_(CC)
1.00000000000000 + 15.0000000000000*I
sage: CC(z) # CC(gp(1+15*I))
1.00000000000000 + 15.0000000000000*I
sage: CC(gp(11243.9812+15*I))
11243.9812000000 + 15.0000000000000*I
sage: ComplexField(10)(gp(11243.9812+15*I))
11000. + 15.*I
"""
# Multiplying by CC(1) is necessary here since
# sage: pari(gp(1+I)).sage().parent()
# Maximal Order in Number Field in i with defining polynomial x^2 + 1
return CC((CC(1)*pari(self))._sage_())
开发者ID:anuragwaliya,项目名称:sage,代码行数:26,代码来源:gp.py
示例8: _sage_
def _sage_(self):
"""
Convert this GpElement into a Sage object, if possible.
EXAMPLES::
sage: gp(I).sage()
i
sage: gp(I).sage().parent()
Number Field in i with defining polynomial x^2 + 1
::
sage: M = Matrix(ZZ,2,2,[1,2,3,4]); M
[1 2]
[3 4]
sage: gp(M)
[1, 2; 3, 4]
sage: gp(M).sage()
[1 2]
[3 4]
sage: gp(M).sage() == M
True
"""
return pari(str(self)).python()
开发者ID:anuragwaliya,项目名称:sage,代码行数:25,代码来源:gp.py
示例9: __init__
def __init__(self, field, num_integer_primes=10000, max_iterations=100):
r"""
Construct a new iterator of small degree one primes.
EXAMPLES::
sage: x = QQ['x'].gen()
sage: K.<a> = NumberField(x^2 - 3)
sage: K.primes_of_degree_one_list(3) # random
[Fractional ideal (2*a + 1), Fractional ideal (-a + 4), Fractional ideal (3*a + 2)]
"""
self._field = field
self._poly = self._field.absolute_field("b").defining_polynomial()
self._poly = ZZ["x"](self._poly.denominator() * self._poly()) # make integer polynomial
# this uses that [ O_K : Z[a] ]^2 = | disc(f(x)) / disc(O_K) |
from sage.libs.pari.all import pari
self._prod_of_small_primes = ZZ(
pari("TEMPn = %s; TEMPps = primes(TEMPn); prod(X = 1, TEMPn, TEMPps[X])" % num_integer_primes)
)
self._prod_of_small_primes //= self._prod_of_small_primes.gcd(self._poly.discriminant())
self._integer_iter = iter(ZZ)
self._queue = []
self._max_iterations = max_iterations
开发者ID:novoselt,项目名称:sage,代码行数:26,代码来源:small_primes_of_degree_one.py
示例10: __mul__
def __mul__(self, right):
"""
Gauss composition of binary quadratic forms. The result is
not reduced.
EXAMPLES:
We explicitly compute in the group of classes of positive
definite binary quadratic forms of discriminant -23.
::
sage: R = BinaryQF_reduced_representatives(-23); R
[x^2 + x*y + 6*y^2, 2*x^2 - x*y + 3*y^2, 2*x^2 + x*y + 3*y^2]
sage: R[0] * R[0]
x^2 + x*y + 6*y^2
sage: R[1] * R[1]
4*x^2 + 3*x*y + 2*y^2
sage: (R[1] * R[1]).reduced_form()
2*x^2 + x*y + 3*y^2
sage: (R[1] * R[1] * R[1]).reduced_form()
x^2 + x*y + 6*y^2
"""
if not isinstance(right, BinaryQF):
raise TypeError, "both self and right must be binary quadratic forms"
# There could be more elegant ways, but qfbcompraw isn't
# wrapped yet in the PARI C library. We may as well settle
# for the below, until somebody simply implements composition
# from scratch in Cython.
v = list(pari('qfbcompraw(%s,%s)'%(self._pari_init_(),
right._pari_init_())))
return BinaryQF(v)
开发者ID:CETHop,项目名称:sage,代码行数:33,代码来源:binary_qf.py
示例11: reduced_form
def reduced_form(self):
"""
Return the unique reduced form equivalent to ``self``. See also
:meth:`~is_reduced`.
EXAMPLES::
sage: a = BinaryQF([33,11,5])
sage: a.is_reduced()
False
sage: b = a.reduced_form(); b
5*x^2 - x*y + 27*y^2
sage: b.is_reduced()
True
sage: a = BinaryQF([15,0,15])
sage: a.is_reduced()
True
sage: b = a.reduced_form(); b
15*x^2 + 15*y^2
sage: b.is_reduced()
True
"""
if self.discriminant() >= 0 or self._a < 0:
raise NotImplementedError, "only implemented for positive definite forms"
if not self.is_reduced():
v = list(pari('Vec(qfbred(Qfb(%s,%s,%s)))'%(self._a,self._b,self._c)))
return BinaryQF(v)
else:
return self
开发者ID:CETHop,项目名称:sage,代码行数:30,代码来源:binary_qf.py
示例12: __float__
def __float__(self):
"""
Return Python float.
EXAMPLES::
sage: float(gp(10))
10.0
"""
return float(pari(str(self)))
开发者ID:anuragwaliya,项目名称:sage,代码行数:10,代码来源:gp.py
示例13: pari
def pari(x):
"""
Return the PARI object constructed from a Sage/Python object.
This is deprecated, import ``pari`` from ``sage.libs.pari.all``.
"""
from sage.misc.superseded import deprecation
deprecation(17451, 'gen_py.pari is deprecated, use sage.libs.pari.all.pari instead')
from sage.libs.pari.all import pari
return pari(x)
开发者ID:Babyll,项目名称:sage,代码行数:10,代码来源:gen_py.py
示例14: representation_number_list
def representation_number_list(self, B):
"""
Return the vector of representation numbers < B.
EXAMPLES::
sage: Q = DiagonalQuadraticForm(ZZ,[1,1,1,1,1,1,1,1])
sage: Q.representation_number_list(10)
[1, 16, 112, 448, 1136, 2016, 3136, 5504, 9328, 12112]
"""
ans = pari(1).concat(self.__pari__().qfrep(B - 1, 1) * 2)
return ans.sage()
开发者ID:mcognetta,项目名称:sage,代码行数:12,代码来源:quadratic_form__ternary_Tornaria.py
示例15: __init__
def __init__(self, K, V):
r"""
EXAMPLE::
sage: L.<b> = NumberField(x^4 + 3*x^2 + 1)
sage: K = L.relativize(L.subfields(2)[0][1], 'a')
sage: V, fr, to = K.relative_vector_space()
sage: to
Isomorphism map:
From: Number Field in a0 with defining polynomial x^2 - b0*x + 1 over its base field
To: Vector space of dimension 2 over Number Field in b0 with defining polynomial x^2 + 1
"""
self.__V = V
self.__K = K
self.__rnf = K.pari_rnf()
self.__zero = QQ(0)
self.__n = K.relative_degree()
self.__x = pari("'x")
self.__y = pari("'y")
self.__B = K.absolute_base_field()
NumberFieldIsomorphism.__init__(self, Hom(K, V))
开发者ID:sageb0t,项目名称:testsage,代码行数:21,代码来源:maps.py
示例16: _pari_
def _pari_(self):
"""
Return PARI list corresponding to this continued fraction.
EXAMPLES::
sage: c = continued_fraction(0.12345); c
[0, 8, 9, 1, 21, 1, 1]
sage: pari(c)
[0, 8, 9, 1, 21, 1, 1]
"""
return pari(self._x)
开发者ID:sageb0t,项目名称:testsage,代码行数:12,代码来源:contfrac.py
示例17: elliptic_j
def elliptic_j(z):
r"""
Returns the elliptic modular `j`-function evaluated at `z`.
INPUT:
- ``z`` (complex) -- a complex number with positive imaginary part.
OUTPUT:
(complex) The value of `j(z)`.
ALGORITHM:
Calls the ``pari`` function ``ellj()``.
AUTHOR:
John Cremona
EXAMPLES::
sage: elliptic_j(CC(i))
1728.00000000000
sage: elliptic_j(sqrt(-2.0))
8000.00000000000
sage: z = ComplexField(100)(1,sqrt(11))/2
sage: elliptic_j(z)
-32768.000...
sage: elliptic_j(z).real().round()
-32768
::
sage: tau = (1 + sqrt(-163))/2
sage: (-elliptic_j(tau.n(100)).real().round())^(1/3)
640320
"""
CC = z.parent()
from sage.rings.complex_field import is_ComplexField
if not is_ComplexField(CC):
CC = ComplexField()
try:
z = CC(z)
except ValueError:
raise ValueError("elliptic_j only defined for complex arguments.")
from sage.libs.all import pari
return CC(pari(z).ellj())
开发者ID:jeromeca,项目名称:sage,代码行数:51,代码来源:special.py
示例18: hypergeometric_U
def hypergeometric_U(alpha, beta, x, algorithm="pari", prec=53):
r"""
Default is a wrap of PARI's hyperu(alpha,beta,x) function.
Optionally, algorithm = "scipy" can be used.
The confluent hypergeometric function `y = U(a,b,x)` is
defined to be the solution to Kummer's differential equation
.. math::
xy'' + (b-x)y' - ay = 0.
This satisfies `U(a,b,x) \sim x^{-a}`, as
`x\rightarrow \infty`, and is sometimes denoted
``x^{-a}2_F_0(a,1+a-b,-1/x)``. This is not the same as Kummer's
`M`-hypergeometric function, denoted sometimes as
``_1F_1(alpha,beta,x)``, though it satisfies the same DE that
`U` does.
.. warning::
In the literature, both are called "Kummer confluent
hypergeometric" functions.
EXAMPLES::
sage: hypergeometric_U(1,1,1,"scipy")
0.596347362323...
sage: hypergeometric_U(1,1,1)
0.59634736232319...
sage: hypergeometric_U(1,1,1,"pari",70)
0.59634736232319407434...
"""
if algorithm == "scipy":
if prec != 53:
raise ValueError("for the scipy algorithm the precision must be 53")
import scipy.special
ans = str(scipy.special.hyperu(float(alpha), float(beta), float(x)))
ans = ans.replace("(", "")
ans = ans.replace(")", "")
ans = ans.replace("j", "*I")
return sage_eval(ans)
elif algorithm == "pari":
from sage.libs.pari.all import pari
R = RealField(prec)
return R(pari(R(alpha)).hyperu(R(beta), R(x), precision=prec))
else:
raise ValueError("unknown algorithm '%s'" % algorithm)
开发者ID:jeromeca,项目名称:sage,代码行数:50,代码来源:special.py
示例19: _pari_order
def _pari_order(self):
"""
Return the pari integer representing the order of this ring.
EXAMPLES::
sage: Zmod(87)._pari_order()
87
"""
try:
return self.__pari_order
except AttributeError:
self.__pari_order = pari(self.order())
return self.__pari_order
开发者ID:sensen1,项目名称:sage,代码行数:14,代码来源:integer_mod_ring.py
示例20: as_hom
def as_hom(self):
r"""
Return the homomorphism L -> L corresponding to self, where L is the
Galois closure of the ambient number field.
EXAMPLE::
sage: G = QuadraticField(-7,'w').galois_group()
sage: G[1].as_hom()
Ring endomorphism of Number Field in w with defining polynomial x^2 + 7
Defn: w |--> -w
"""
L = self.parent().splitting_field()
a = L(self.parent()._pari_data.galoispermtopol(pari(self.domain()).Vecsmall()))
return L.hom(a, L)
开发者ID:NitikaAgarwal,项目名称:sage,代码行数:15,代码来源:galois_group.py
注:本文中的sage.libs.pari.all.pari函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论