本文整理汇总了Python中sage.matrix.constructor.Matrix.right_kernel方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.right_kernel方法的具体用法?Python Matrix.right_kernel怎么用?Python Matrix.right_kernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.right_kernel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Conic
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import right_kernel [as 别名]
#.........这里部分代码省略.........
if names is None:
names = F
F = base_field
base_field = None
if isinstance(F, (list,tuple)):
if len(F) == 1:
return Conic(base_field, F[0], names)
if names == None:
names = 'x,y,z'
if len(F) == 5:
L=[]
for f in F:
if isinstance(f, SchemeMorphism_point_affine):
C = Sequence(f, universe = base_field)
if len(C) != 2:
raise TypeError, "points in F (=%s) must be planar"%F
C.append(1)
elif isinstance(f, SchemeMorphism_point_projective_field):
C = Sequence(f, universe = base_field)
elif isinstance(f, (list, tuple)):
C = Sequence(f, universe = base_field)
if len(C) == 2:
C.append(1)
else:
raise TypeError, "F (=%s) must be a sequence of planar " \
"points" % F
if len(C) != 3:
raise TypeError, "points in F (=%s) must be planar" % F
P = C.universe()
if not is_IntegralDomain(P):
raise TypeError, "coordinates of points in F (=%s) must " \
"be in an integral domain" % F
L.append(Sequence([C[0]**2, C[0]*C[1], C[0]*C[2], C[1]**2,
C[1]*C[2], C[2]**2], P.fraction_field()))
M=Matrix(L)
if unique and M.rank() != 5:
raise ValueError, "points in F (=%s) do not define a unique " \
"conic" % F
con = Conic(base_field, Sequence(M.right_kernel().gen()), names)
con.point(F[0])
return con
F = Sequence(F, universe = base_field)
base_field = F.universe().fraction_field()
temp_ring = PolynomialRing(base_field, 3, names)
(x,y,z) = temp_ring.gens()
if len(F) == 3:
return Conic(F[0]*x**2 + F[1]*y**2 + F[2]*z**2)
if len(F) == 6:
return Conic(F[0]*x**2 + F[1]*x*y + F[2]*x*z + F[3]*y**2 + \
F[4]*y*z + F[5]*z**2)
raise TypeError, "F (=%s) must be a sequence of 3 or 6" \
"coefficients" % F
if is_QuadraticForm(F):
F = F.matrix()
if is_Matrix(F) and F.is_square() and F.ncols() == 3:
if names == None:
names = 'x,y,z'
temp_ring = PolynomialRing(F.base_ring(), 3, names)
F = vector(temp_ring.gens()) * F * vector(temp_ring.gens())
if not is_MPolynomial(F):
raise TypeError, "F (=%s) must be a three-variable polynomial or " \
"a sequence of points or coefficients" % F
if F.total_degree() != 2:
raise TypeError, "F (=%s) must have degree 2" % F
if base_field == None:
base_field = F.base_ring()
if not is_IntegralDomain(base_field):
raise ValueError, "Base field (=%s) must be a field" % base_field
base_field = base_field.fraction_field()
if names == None:
names = F.parent().variable_names()
pol_ring = PolynomialRing(base_field, 3, names)
if F.parent().ngens() == 2:
(x,y,z) = pol_ring.gens()
F = pol_ring(F(x/z,y/z)*z**2)
if F == 0:
raise ValueError, "F must be nonzero over base field %s" % base_field
if F.total_degree() != 2:
raise TypeError, "F (=%s) must have degree 2 over base field %s" % \
(F, base_field)
if F.parent().ngens() == 3:
P2 = ProjectiveSpace(2, base_field, names)
if is_PrimeFiniteField(base_field):
return ProjectiveConic_prime_finite_field(P2, F)
if is_FiniteField(base_field):
return ProjectiveConic_finite_field(P2, F)
if is_RationalField(base_field):
return ProjectiveConic_rational_field(P2, F)
if is_NumberField(base_field):
return ProjectiveConic_number_field(P2, F)
return ProjectiveConic_field(P2, F)
raise TypeError, "Number of variables of F (=%s) must be 2 or 3" % F
示例2: HarmonicCocycles
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import right_kernel [as 别名]
#.........这里部分代码省略.........
- Cameron Franc (2012-02-20)
- Marc Masdeu (2012-02-20)
"""
try: return self.__matrix
except AttributeError: pass
nV=len(self._V)
nE=len(self._E)
stab_conds=[]
S=self._X.get_edge_stabs()
p=self._X._p
d=self._k-1
for e in self._E:
try:
g=filter(lambda g:g[2],S[e.label])[0]
C=self._U.l_matrix_representation(self.embed_quaternion(g[0]))
C-=self._U.l_matrix_representation(Matrix(QQ,2,2,p**g[1]))
stab_conds.append([e.label,C])
except IndexError: pass
n_stab_conds=len(stab_conds)
self._M=Matrix(self._R,(nV+n_stab_conds)*d,nE*d,0,sparse=True)
for v in self._V:
for e in filter(lambda e:e.parity==0,v.leaving_edges):
C=sum([self._U.l_matrix_representation(self.embed_quaternion(x[0])) for x in e.links],Matrix(self._R,d,d,0))
self._M.set_block(v.label*d,e.label*d,C)
for e in filter(lambda e:e.parity==0,v.entering_edges):
C=sum([self._U.l_matrix_representation(self.embed_quaternion(x[0])) for x in e.opposite.links],Matrix(self._R,d,d,0))
self._M.set_block(v.label*d,e.opposite.label*d,C)
for kk in range(n_stab_conds):
v=stab_conds[kk]
self._M.set_block((nV+kk)*d,v[0]*d,v[1])
x1=self._M.right_kernel().matrix()
if x1.nrows() != self.rank():
raise RuntimeError, 'The computed dimension does not agree with the expectation. Consider increasing precision!'
K=[c for c in x1.rows()]
if not self._R.is_exact():
for ii in range(len(K)):
s=min([t.valuation() for t in K[ii]])
for jj in range(len(K[ii])):
K[ii][jj]=(p**(-s))*K[ii][jj]
self.__matrix=Matrix(self._R,len(K),nE*d,K)
self.__matrix.set_immutable()
return self.__matrix
def __apply_atkin_lehner(self,q,f):
r"""
This function applies an Atkin-Lehner involution to a harmonic cocycle
INPUT:
- ``q`` - an integer dividing the full level p*Nminus*Nplus
- ``f`` - a harmonic cocycle
OUTPUT:
The harmonic cocycle obtained by hitting f with the Atkin-Lehner at q
EXAMPLES:
::