本文整理汇总了Python中sage.rings.complex_field.is_ComplexField函数的典型用法代码示例。如果您正苦于以下问题:Python is_ComplexField函数的具体用法?Python is_ComplexField怎么用?Python is_ComplexField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_ComplexField函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: can_convert_to_singular
def can_convert_to_singular(R):
"""
Returns True if this ring's base field or ring can be
represented in Singular, and the polynomial ring has at
least one generator. If this is True then this polynomial
ring can be represented in Singular.
The following base rings are supported: finite fields, rationals, number
fields, and real and complex fields.
EXAMPLES::
sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
sage: can_convert_to_singular(PolynomialRing(QQ, names=['x']))
True
sage: can_convert_to_singular(PolynomialRing(QQ, names=[]))
False
"""
if R.ngens() == 0:
return False;
base_ring = R.base_ring()
return ( sage.rings.finite_rings.constructor.is_FiniteField(base_ring)
or is_RationalField(base_ring)
or (base_ring.is_prime_field() and base_ring.characteristic() <= 2147483647)
or is_RealField(base_ring)
or is_ComplexField(base_ring)
or is_RealDoubleField(base_ring)
or is_ComplexDoubleField(base_ring)
or number_field.all.is_NumberField(base_ring)
or ( sage.rings.fraction_field.is_FractionField(base_ring) and ( base_ring.base_ring().is_prime_field() or base_ring.base_ring() is ZZ ) )
or base_ring is ZZ
or is_IntegerModRing(base_ring) )
示例2: can_convert_to_singular
def can_convert_to_singular(R):
"""
Returns True if this ring's base field or ring can be
represented in Singular, and the polynomial ring has at
least one generator. If this is True then this polynomial
ring can be represented in Singular.
The following base rings are supported: finite fields, rationals, number
fields, and real and complex fields.
EXAMPLES::
sage: from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
sage: can_convert_to_singular(PolynomialRing(QQ, names=['x']))
True
sage: can_convert_to_singular(PolynomialRing(QQ, names=[]))
False
TESTS:
Avoid non absolute number fields (see :trac:`23535`)::
sage: K.<a,b> = NumberField([x^2-2,x^2-5])
sage: can_convert_to_singular(K['s,t'])
False
"""
if R.ngens() == 0:
return False;
base_ring = R.base_ring()
if (base_ring is ZZ
or sage.rings.finite_rings.finite_field_constructor.is_FiniteField(base_ring)
or is_RationalField(base_ring)
or is_IntegerModRing(base_ring)
or is_RealField(base_ring)
or is_ComplexField(base_ring)
or is_RealDoubleField(base_ring)
or is_ComplexDoubleField(base_ring)):
return True
elif base_ring.is_prime_field():
return base_ring.characteristic() <= 2147483647
elif number_field.number_field_base.is_NumberField(base_ring):
return base_ring.is_absolute()
elif sage.rings.fraction_field.is_FractionField(base_ring):
B = base_ring.base_ring()
return B.is_prime_field() or B is ZZ or is_FiniteField(B)
elif is_RationalFunctionField(base_ring):
return base_ring.constant_field().is_prime_field()
else:
return False
示例3: 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())
示例4: _evalf_
def _evalf_(self, n, x, **kwds):
"""
Evaluate :class:`chebyshev_U` numerically with mpmath.
EXAMPLES::
sage: chebyshev_U(5,-4+3.*I)
98280.0000000000 - 11310.0000000000*I
sage: chebyshev_U(10,3).n(75)
4.661117900000000000000e7
sage: chebyshev_U._evalf_(1.5, Mod(8,9))
Traceback (most recent call last):
...
TypeError: cannot evaluate chebyshev_U with parent Ring of integers modulo 9
"""
try:
real_parent = kwds["parent"]
except KeyError:
real_parent = parent(x)
if not is_RealField(real_parent) and not is_ComplexField(real_parent):
# parent is not a real or complex field: figure out a good parent
if x in RR:
x = RR(x)
real_parent = RR
elif x in CC:
x = CC(x)
real_parent = CC
if not is_RealField(real_parent) and not is_ComplexField(real_parent):
raise TypeError("cannot evaluate chebyshev_U with parent {}".format(real_parent))
from sage.libs.mpmath.all import call as mpcall
from sage.libs.mpmath.all import chebyu as mpchebyu
return mpcall(mpchebyu, n, x, parent=real_parent)
示例5: __call__
def __call__(self, g):
"""
Evaluate ``self`` on a group element ``g``.
OUTPUT:
An element in
:meth:`~sage.groups.abelian_gps.dual_abelian_group.DualAbelianGroup_class.base_ring`.
EXAMPLES::
sage: F = AbelianGroup(5, [2,3,5,7,8], names="abcde")
sage: a,b,c,d,e = F.gens()
sage: Fd = F.dual_group(names="ABCDE")
sage: A,B,C,D,E = Fd.gens()
sage: A*B^2*D^7
A*B^2
sage: A(a)
-1
sage: B(b)
zeta840^140 - 1
sage: CC(B(b)) # abs tol 1e-8
-0.499999999999995 + 0.866025403784447*I
sage: A(a*b)
-1
"""
F = self.parent().base_ring()
expsX = self.exponents()
expsg = g.exponents()
order = self.parent().gens_orders()
N = LCM(order)
if is_ComplexField(F):
from sage.symbolic.constants import pi
I = F.gen()
PI = F(pi)
ans = prod([(2*PI*I*expsX[i]*expsg[i]/order[i]).exp() for i in range(len(expsX))])
return ans
ans = F(1) ## assumes F is the cyclotomic field
zeta = F.gen()
for i in range(len(expsX)):
order_noti = N/order[i]
ans = ans*zeta**(expsX[i]*expsg[i]*order_noti)
return ans
示例6: __call__
def __call__(self,g):
"""
Computes the value of a character self on a group element
g (g must be an element of self.group())
EXAMPLES:
sage: F = AbelianGroup(5, [2,3,5,7,8], names="abcde")
sage: a,b,c,d,e = F.gens()
sage: Fd = DualAbelianGroup(F, names="ABCDE")
sage: A,B,C,D,E = Fd.gens()
sage: A*B^2*D^7
A*B^2
sage: A(a) ## random last few digits
-1.0000000000000000 + 0.00000000000000013834419720915037*I
sage: B(b) ## random last few digits
-0.49999999999999983 + 0.86602540378443871*I
sage: A(a*b) ## random last few digits
-1.0000000000000000 + 0.00000000000000013834419720915037*I
"""
F = self.parent().base_ring()
expsX = list(self.list())
expsg = list(g.list())
invs = self.parent().invariants()
N = LCM(invs)
if is_ComplexField(F):
from sage.symbolic.constants import pi
I = F.gen()
PI = F(pi)
ans = prod([exp(2*PI*I*expsX[i]*expsg[i]/invs[i]) for i in range(len(expsX))])
return ans
ans = F(1) ## assumes F is the cyclotomic field
zeta = F.gen()
#print F,zeta
for i in range(len(expsX)):
inv_noti = N/invs[i]
ans = ans*zeta**(expsX[i]*expsg[i]*inv_noti)
return ans
示例7: isogenies_prime_degree
#.........这里部分代码省略.........
Elliptic Curve defined by y^2 = x^3 + 1.00000000000000*x + 18.0000000000000 over Complex Field with 53 bits of precision
sage: E.isogenies_prime_degree(11)
Traceback (most recent call last):
...
NotImplementedError: This code could be implemented for general complex fields, but has not been yet.
Examples over finite fields::
sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8])
sage: E.isogenies_prime_degree()
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003, Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 347438*x + 594729 over Finite Field of size 1000003, Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 674846*x + 7392 over Finite Field of size 1000003, Isogeny of degree 23 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 390065*x + 605596 over Finite Field of size 1000003]
sage: E.isogenies_prime_degree(2)
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003]
sage: E.isogenies_prime_degree(3)
[]
sage: E.isogenies_prime_degree(5)
[]
sage: E.isogenies_prime_degree(7)
[]
sage: E.isogenies_prime_degree(13)
[Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003,
Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003]
sage: E.isogenies_prime_degree([2, 3, 5, 7, 13])
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 29783*x + 206196 over Finite Field of size 1000003, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003]
sage: E.isogenies_prime_degree([2, 4])
Traceback (most recent call last):
...
ValueError: 4 is not prime.
sage: E.isogenies_prime_degree(4)
Traceback (most recent call last):
...
ValueError: 4 is not prime.
sage: E.isogenies_prime_degree(11)
[]
sage: E = EllipticCurve(GF(17),[2,0])
sage: E.isogenies_prime_degree(3)
[]
sage: E.isogenies_prime_degree(2)
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 9*x over Finite Field of size 17, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 5*x + 9 over Finite Field of size 17, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 5*x + 8 over Finite Field of size 17]
sage: E = EllipticCurve(GF(13^4, 'a'),[2,8])
sage: E.isogenies_prime_degree(2)
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field in a of size 13^4, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + (8*a^3+2*a^2+7*a+5)*x + (12*a^3+3*a^2+4*a+4) over Finite Field in a of size 13^4, Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + (5*a^3+11*a^2+6*a+11)*x + (a^3+10*a^2+9*a) over Finite Field in a of size 13^4]
sage: E.isogenies_prime_degree(3)
[Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 9*x + 11 over Finite Field in a of size 13^4]
Example to show that separable isogenies of degree equal to the characteristic are now implemented::
sage: E.isogenies_prime_degree(13)
[Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in a of size 13^4 to Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field in a of size 13^4]
Examples over number fields (other than QQ)::
sage: QQroot2.<e> = NumberField(x^2-2)
sage: E = EllipticCurve(QQroot2, j=8000)
sage: E.isogenies_prime_degree()
[Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-602112000)*x + 5035261952000 over Number Field in e with defining polynomial x^2 - 2,
Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (903168000*e-1053696000)*x + (14161674240000*e-23288086528000) over Number Field in e with defining polynomial x^2 - 2,
Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-903168000*e-1053696000)*x + (-14161674240000*e-23288086528000) over Number Field in e with defining polynomial x^2 - 2]
sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E
Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2
sage: E.isogenies_prime_degree(2)
[Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-36)*x + (-70) over Number Field in e with defining polynomial x^2 - 2]
sage: E.isogenies_prime_degree(3)
[Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-128/3)*x + 5662/27 over Number Field in e with defining polynomial x^2 - 2, Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-171)*x + (-874) over Number Field in e with defining polynomial x^2 - 2]
"""
F = self.base_ring()
if is_RealField(F):
raise NotImplementedError("This code could be implemented for general real fields, but has not been yet.")
if is_ComplexField(F):
raise NotImplementedError("This code could be implemented for general complex fields, but has not been yet.")
if F == rings.QQbar:
raise NotImplementedError("This code could be implemented for QQbar, but has not been yet.")
from isogeny_small_degree import isogenies_prime_degree
if l is None:
from sage.rings.all import prime_range
l = prime_range(max_l+1)
if not isinstance(l, list):
try:
l = rings.ZZ(l)
except TypeError:
raise ValueError("%s is not prime."%l)
if l.is_prime():
return isogenies_prime_degree(self, l)
else:
raise ValueError("%s is not prime."%l)
L = list(set(l))
try:
L = [rings.ZZ(l) for l in L]
except TypeError:
raise ValueError("%s is not a list of primes."%l)
L.sort()
return sum([isogenies_prime_degree(self,l) for l in L],[])
示例8: has_rational_point
#.........这里部分代码省略.........
sage: K.coerce_embedding()
Generic morphism:
From: Number Field in i with defining polynomial x^2 + 1
To: Complex Lazy Field
Defn: i -> 1*I
sage: Conic(K, [1,1,1]).rational_point(algorithm='magma') # optional - magma
(-i : 1 : 0)
sage: x = QQ['x'].gen()
sage: L.<i> = NumberField(x^2+1, embedding=None)
sage: Conic(L, [1,1,1]).rational_point(algorithm='magma') # optional - magma
(-i : 1 : 0)
sage: L == K
False
"""
if read_cache:
if self._rational_point is not None:
if point:
return True, self._rational_point
else:
return True
B = self.base_ring()
if algorithm == 'magma':
from sage.interfaces.magma import magma
M = magma(self)
b = M.HasRationalPoint().sage()
if not point:
return b
if not b:
return False, None
M_pt = M.HasRationalPoint(nvals=2)[1]
# Various attempts will be made to convert `pt` to
# a Sage object. The end result will always be checked
# by self.point().
pt = [M_pt[1], M_pt[2], M_pt[3]]
# The first attempt is to use sequences. This is efficient and
# succeeds in cases where the Magma interface fails to convert
# number field elements, because embeddings between number fields
# may be lost on conversion to and from Magma.
# This should deal with all absolute number fields.
try:
return True, self.point([B(c.Eltseq().sage()) for c in pt])
except TypeError:
pass
# The second attempt tries to split Magma elements into
# numerators and denominators first. This is neccessary
# for the field of rational functions, because (at the moment of
# writing) fraction field elements are not converted automatically
# from Magma to Sage.
try:
return True, self.point( \
[B(c.Numerator().sage()/c.Denominator().sage()) for c in pt])
except (TypeError, NameError):
pass
# Finally, let the Magma interface handle conversion.
try:
return True, self.point([B(c.sage()) for c in pt])
except (TypeError, NameError):
pass
raise NotImplementedError("No correct conversion implemented for converting the Magma point %s on %s to a correct Sage point on self (=%s)" % (M_pt, M, self))
if algorithm != 'default':
raise ValueError("Unknown algorithm: %s" % algorithm)
if is_ComplexField(B):
if point:
[_,_,_,d,e,f] = self._coefficients
if d == 0:
return True, self.point([0,1,0])
return True, self.point([0, ((e**2-4*d*f).sqrt()-e)/(2*d), 1],
check = False)
return True
if is_RealField(B):
D, T = self.diagonal_matrix()
[a, b, c] = [D[0,0], D[1,1], D[2,2]]
if a == 0:
ret = True, self.point(T*vector([1,0,0]), check = False)
elif a*c <= 0:
ret = True, self.point(T*vector([(-c/a).sqrt(),0,1]),
check = False)
elif b == 0:
ret = True, self.point(T*vector([0,1,0]), check = False)
elif b*c <= 0:
ret = True, self.point(T*vector([0,(-c/b).sqrt(),0,1]),
check = False)
else:
ret = False, None
if point:
return ret
return ret[0]
raise NotImplementedError("has_rational_point not implemented for " \
"conics over base field %s" % B)
示例9: _singular_init_
def _singular_init_(self, singular=singular_default):
"""
Return a newly created Singular ring matching this ring.
EXAMPLES::
sage: PolynomialRing(QQ,'u_ba')._singular_init_()
// characteristic : 0
// number of vars : 1
// block 1 : ordering lp
// : names u_ba
// block 2 : ordering C
"""
if not can_convert_to_singular(self):
raise TypeError, "no conversion of this ring to a Singular ring defined"
if self.ngens()==1:
_vars = '(%s)'%self.gen()
if "*" in _vars: # 1.000...000*x
_vars = _vars.split("*")[1]
order = 'lp'
else:
_vars = str(self.gens())
order = self.term_order().singular_str()
base_ring = self.base_ring()
if is_RealField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
precision = base_ring.precision()
digits = sage.rings.arith.integer_ceil((2*precision - 2)/7.0)
self.__singular = singular.ring("(real,%d,0)"%digits, _vars, order=order, check=False)
elif is_ComplexField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
precision = base_ring.precision()
digits = sage.rings.arith.integer_ceil((2*precision - 2)/7.0)
self.__singular = singular.ring("(complex,%d,0,I)"%digits, _vars, order=order, check=False)
elif is_RealDoubleField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
self.__singular = singular.ring("(real,15,0)", _vars, order=order, check=False)
elif is_ComplexDoubleField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
self.__singular = singular.ring("(complex,15,0,I)", _vars, order=order, check=False)
elif base_ring.is_prime_field():
self.__singular = singular.ring(self.characteristic(), _vars, order=order, check=False)
elif sage.rings.finite_rings.constructor.is_FiniteField(base_ring):
# not the prime field!
gen = str(base_ring.gen())
r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
self.__minpoly = (str(base_ring.modulus()).replace("x",gen)).replace(" ","")
if singular.eval('minpoly') != "(" + self.__minpoly + ")":
singular.eval("minpoly=%s"%(self.__minpoly) )
self.__minpoly = singular.eval('minpoly')[1:-1]
self.__singular = r
elif number_field.all.is_NumberField(base_ring) and base_ring.is_absolute():
# not the rationals!
gen = str(base_ring.gen())
poly=base_ring.polynomial()
poly_gen=str(poly.parent().gen())
poly_str=str(poly).replace(poly_gen,gen)
r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
self.__minpoly = (poly_str).replace(" ","")
if singular.eval('minpoly') != "(" + self.__minpoly + ")":
singular.eval("minpoly=%s"%(self.__minpoly) )
self.__minpoly = singular.eval('minpoly')[1:-1]
self.__singular = r
elif sage.rings.fraction_field.is_FractionField(base_ring) and (base_ring.base_ring() is ZZ or base_ring.base_ring().is_prime_field()):
if base_ring.ngens()==1:
gens = str(base_ring.gen())
else:
gens = str(base_ring.gens())
self.__singular = singular.ring( "(%s,%s)"%(base_ring.characteristic(),gens), _vars, order=order, check=False)
elif is_IntegerModRing(base_ring):
ch = base_ring.characteristic()
if ch.is_power_of(2):
exp = ch.nbits() -1
self.__singular = singular.ring("(integer,2,%d)"%(exp,), _vars, order=order, check=False)
else:
self.__singular = singular.ring("(integer,%d)"%(ch,), _vars, order=order, check=False)
elif base_ring is ZZ:
self.__singular = singular.ring("(integer)", _vars, order=order, check=False)
else:
raise TypeError, "no conversion to a Singular ring defined"
return self.__singular
示例10: schmidt_t5_eigenvalue_numerical
trans_value = trans_value + self[k] * (e_tau1p**a * e_zp**b * e_tau2p**c)
return trans_value / self_value
def schmidt_t5_eigenvalue_numerical(self, (tau1, z, tau2)) :
from sage.libs.mpmath import mp
from sage.libs.mpmath.mp import exp, pi
from sage.libs.mpmath.mp import j as i
if not Integer(self.__level()).is_prime() :
raise ValueError, "T_5 is only unique if the level is a prime"
precision = ParamodularFormD2Filter_trace(self.precision())
s = Sequence([tau1, z, tau2])
if not is_ComplexField(s) :
mp_precision = 30
else :
mp_precision = ceil(3.33 * s.universe().precision())
mp.dps = mp_precision
p1list = P1List(self.level())
## Prepare the operation for d_1(N)
## We have to invert the lifts since we will later use apply_GL_to_form
d1_matrices = [p1list.lift_to_sl2z(i) for i in xrange(len(p1list))]
d1_matrices = map(lambda (a,b,c,d): (d,-b,-c,a), d1_matrices)
## Prepare the evaluation points corresponding to d_02(N)
d2_points = list()
for i in xrange(len(p1list())) :
示例11: _singular_init_
def _singular_init_(self, singular=singular):
"""
Return a newly created Singular ring matching this ring.
EXAMPLES::
sage: PolynomialRing(QQ,'u_ba')._singular_init_()
polynomial ring, over a field, global ordering
// coefficients: QQ
// number of vars : 1
// block 1 : ordering lp
// : names u_ba
// block 2 : ordering C
"""
if not can_convert_to_singular(self):
raise TypeError("no conversion of this ring to a Singular ring defined")
if self.ngens()==1:
_vars = '(%s)'%self.gen()
if "*" in _vars: # 1.000...000*x
_vars = _vars.split("*")[1]
order = 'lp'
else:
_vars = str(self.gens())
order = self.term_order().singular_str()
base_ring = self.base_ring()
if is_RealField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
precision = base_ring.precision()
digits = sage.arith.all.integer_ceil((2*precision - 2)/7.0)
self.__singular = singular.ring("(real,%d,0)"%digits, _vars, order=order, check=False)
elif is_ComplexField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
precision = base_ring.precision()
digits = sage.arith.all.integer_ceil((2*precision - 2)/7.0)
self.__singular = singular.ring("(complex,%d,0,I)"%digits, _vars, order=order, check=False)
elif is_RealDoubleField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
self.__singular = singular.ring("(real,15,0)", _vars, order=order, check=False)
elif is_ComplexDoubleField(base_ring):
# singular converts to bits from base_10 in mpr_complex.cc by:
# size_t bits = 1 + (size_t) ((float)digits * 3.5);
self.__singular = singular.ring("(complex,15,0,I)", _vars, order=order, check=False)
elif base_ring.is_prime_field():
self.__singular = singular.ring(self.characteristic(), _vars, order=order, check=False)
elif sage.rings.finite_rings.finite_field_constructor.is_FiniteField(base_ring):
# not the prime field!
gen = str(base_ring.gen())
r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
self.__minpoly = (str(base_ring.modulus()).replace("x",gen)).replace(" ","")
if singular.eval('minpoly') != "(" + self.__minpoly + ")":
singular.eval("minpoly=%s"%(self.__minpoly) )
self.__minpoly = singular.eval('minpoly')[1:-1]
self.__singular = r
elif number_field.number_field_base.is_NumberField(base_ring) and base_ring.is_absolute():
# not the rationals!
gen = str(base_ring.gen())
poly=base_ring.polynomial()
poly_gen=str(poly.parent().gen())
poly_str=str(poly).replace(poly_gen,gen)
r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
self.__minpoly = (poly_str).replace(" ","")
if singular.eval('minpoly') != "(" + self.__minpoly + ")":
singular.eval("minpoly=%s"%(self.__minpoly) )
self.__minpoly = singular.eval('minpoly')[1:-1]
self.__singular = r
elif sage.rings.fraction_field.is_FractionField(base_ring) and (base_ring.base_ring() is ZZ or base_ring.base_ring().is_prime_field() or is_FiniteField(base_ring.base_ring())):
if base_ring.ngens()==1:
gens = str(base_ring.gen())
else:
gens = str(base_ring.gens())
if not (not base_ring.base_ring().is_prime_field() and is_FiniteField(base_ring.base_ring())) :
self.__singular = singular.ring( "(%s,%s)"%(base_ring.characteristic(),gens), _vars, order=order, check=False)
else:
ext_gen = str(base_ring.base_ring().gen())
_vars = '(' + ext_gen + ', ' + _vars[1:];
R = self.__singular = singular.ring( "(%s,%s)"%(base_ring.characteristic(),gens), _vars, order=order, check=False)
self.base_ring().__minpoly = (str(base_ring.base_ring().modulus()).replace("x",ext_gen)).replace(" ","")
singular.eval('setring '+R._name);
from sage.misc.stopgap import stopgap
stopgap("Denominators of fraction field elements are sometimes dropped without warning.", 17696)
#.........这里部分代码省略.........