本文整理汇总了Python中sage.matrix.constructor.Matrix.dimension方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.dimension方法的具体用法?Python Matrix.dimension怎么用?Python Matrix.dimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.dimension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_cocycle_from_elliptic_curve
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import dimension [as 别名]
def get_cocycle_from_elliptic_curve(self,E,sign = 1,use_magma = True):
if sign == 0:
return self.get_cocycle_from_elliptic_curve(E,1,use_magma) + self.get_cocycle_from_elliptic_curve(E,-1,use_magma)
if not sign in [1, -1]:
raise NotImplementedError
F = self.group().base_ring()
if F.signature()[1] == 0 or (F.signature() == (0,1) and 'G' not in self.group()._grouptype):
K = (self.hecke_matrix(oo).transpose()-sign).kernel().change_ring(QQ)
else:
K = Matrix(QQ,self.dimension(),self.dimension(),0).kernel()
disc = self.S_arithgroup().Gpn._O_discriminant
discnorm = disc.norm()
try:
N = ZZ(discnorm.gen())
except AttributeError:
N = ZZ(discnorm)
if F == QQ:
x = QQ['x'].gen()
F = NumberField(x,names='a')
E = E.change_ring(F)
def getap(q):
if F == QQ:
return E.ap(q)
else:
Q = F.ideal(q).factor()[0][0]
return ZZ(Q.norm() + 1 - E.reduction(Q).count_points())
q = ZZ(1)
g0 = None
while K.dimension() > 1:
q = q.next_prime()
for qq,e in F.ideal(q).factor():
if ZZ(qq.norm()).is_prime() and not qq.divides(F.ideal(disc.gens_reduced()[0])):
try:
ap = getap(qq)
except (ValueError,ArithmeticError):
continue
try:
K1 = (self.hecke_matrix(qq.gens_reduced()[0],g0 = g0,use_magma = use_magma).transpose()-ap).kernel()
except RuntimeError:
continue
K = K.intersection(K1)
if K.dimension() != 1:
raise ValueError,'Did not obtain a one-dimensional space corresponding to E'
col = [ZZ(o) for o in (K.denominator()*K.matrix()).list()]
return sum([a * self.gen(i) for i,a in enumerate(col) if a != 0],self(0))
示例2: get_rational_cocycle_from_ap
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import dimension [as 别名]
def get_rational_cocycle_from_ap(self,getap,sign = 1,use_magma = True):
F = self.group().base_ring()
if F.signature()[1] == 0 or (F.signature() == (0,1) and 'G' not in self.group()._grouptype):
K = (self.hecke_matrix(oo).transpose()-sign).kernel().change_ring(QQ)
else:
K = Matrix(QQ,self.dimension(),self.dimension(),0).kernel()
disc = self.S_arithgroup().Gpn._O_discriminant
discnorm = disc.norm()
try:
N = ZZ(discnorm.gen())
except AttributeError:
N = ZZ(discnorm)
if F == QQ:
x = QQ['x'].gen()
F = NumberField(x,names='a')
q = ZZ(1)
g0 = None
while K.dimension() > 1:
q = q.next_prime()
for qq,e in F.ideal(q).factor():
if ZZ(qq.norm()).is_prime() and not qq.divides(F.ideal(disc.gens_reduced()[0])):
try:
ap = getap(qq)
except (ValueError,ArithmeticError):
continue
try:
K1 = (self.hecke_matrix(qq.gens_reduced()[0],g0 = g0,use_magma = use_magma).transpose()-ap).kernel()
except RuntimeError:
continue
K = K.intersection(K1)
if K.dimension() != 1:
raise ValueError,'Group does not have the required system of eigenvalues'
col = [ZZ(o) for o in (K.denominator()*K.matrix()).list()]
return sum([ a * self.gen(i) for i,a in enumerate(col) if a != 0], self(0))
示例3: get_twodim_cocycle
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import dimension [as 别名]
def get_twodim_cocycle(self,sign = 1,use_magma = True,bound = 5, hecke_data = None, return_all = False, outfile = None):
F = self.group().base_ring()
if F == QQ:
F = NumberField(PolynomialRing(QQ,'x').gen(),names='r')
component_list = []
good_components = []
if F.signature()[1] == 0 or (F.signature() == (0,1) and 'G' not in self.group()._grouptype):
Tinf = self.hecke_matrix(oo).transpose()
K = (Tinf-sign).kernel().change_ring(QQ)
if K.dimension() >= 2:
component_list.append((K, [(oo,Tinf)]))
fwrite('Too charpoly = %s'%Tinf.charpoly().factor(),outfile)
else:
K = Matrix(QQ,self.dimension(),self.dimension(),0).kernel()
if K.dimension() >= 2:
component_list.append((K, []))
disc = self.S_arithgroup().Gpn._O_discriminant
discnorm = disc.norm()
try:
N = ZZ(discnorm.gen())
except AttributeError:
N = ZZ(discnorm)
if F == QQ:
x = QQ['x'].gen()
F = NumberField(x,names='a')
q = ZZ(1)
g0 = None
num_hecke_operators = 0
if hecke_data is not None:
qq = F.ideal(hecke_data[0])
pol = hecke_data[1]
Aq = self.hecke_matrix(qq.gens_reduced()[0], use_magma = use_magma).transpose().change_ring(QQ)
fwrite('ell = (%s,%s), T_ell charpoly = %s'%(qq.norm(), qq.gens_reduced()[0], Aq.charpoly().factor()),outfile)
U0 = component_list[0][0].intersection(pol.subs(Aq).left_kernel())
if U0.dimension() != 2:
raise ValueError('Hecke data does not suffice to cut out space')
good_component = (U0.denominator() * U0,component_list[0][1] + [(qq.gens_reduced()[0],Aq)])
row0 = good_component[0].matrix().rows()[0]
col0 = [QQ(o) for o in row0.list()]
clcm = lcm([o.denominator() for o in col0])
col0 = [ZZ(clcm * o ) for o in col0]
# phi1 = sum([a * phi for a,phi in zip(col0,self.gens())],self(0))
# phi2 = self.apply_hecke_operator(phi1,qq.gens_reduced()[0], use_magma = use_magma)
# return [phi1, phi2], [(ell, o.restrict(good_component[0])) for ell, o in good_component[1]]
flist = []
for row0 in good_component[0].matrix().rows():
col0 = [QQ(o) for o in row0.list()]
clcm = lcm([o.denominator() for o in col0])
col0 = [ZZ(clcm * o ) for o in col0]
flist.append(sum([a * phi for a,phi in zip(col0,self.gens())],self(0)))
return flist,[(ell, o.restrict(good_component[0])) for ell, o in good_component[1]]
while len(component_list) > 0 and num_hecke_operators < bound:
verbose('num_hecke_ops = %s'%num_hecke_operators)
verbose('len(components_list) = %s'%len(component_list))
q = q.next_prime()
verbose('q = %s'%q)
fact = F.ideal(q).factor()
dfact = F.ideal(disc.gens_reduced()[0]).factor()
for qq,e in fact:
verbose('Trying qq = %s'%qq)
if qq in [o for o,_ in dfact]:
verbose('Skipping because qq divides D...')
continue
if ZZ(qq.norm()).is_prime() and not qq.divides(F.ideal(disc.gens_reduced()[0])):
try:
Aq = self.hecke_matrix(qq.gens_reduced()[0],g0 = g0,use_magma = use_magma).transpose().change_ring(QQ)
except (RuntimeError,TypeError) as e:
verbose('Skipping qq (=%s) because Hecke matrix could not be computed...'%qq.gens_reduced()[0])
continue
except KeyboardInterrupt:
verbose('Skipping qq (=%s) by user request...'%qq.gens_reduced()[0])
num_hecke_operators += 1
sleep(1)
continue
verbose('Computed hecke matrix at qq = %s'%qq)
fwrite('ell = (%s,%s), T_ell charpoly = %s'%(qq.norm(), qq.gens_reduced()[0], Aq.charpoly().factor()),outfile)
old_component_list = component_list
component_list = []
num_hecke_operators += 1
for U,hecke_data in old_component_list:
V = Aq.decomposition_of_subspace(U)
for U0,is_irred in V:
if U0.dimension() == 1:
continue
if U0.dimension() == 2 and is_irred:
good_components.append((U0.denominator() * U0,hecke_data+[(qq.gens_reduced()[0],Aq)]))
else: # U0.dimension() > 2 or not is_irred
component_list.append((U0.denominator() * U0,hecke_data + [(qq.gens_reduced()[0],Aq)]))
if len(good_components) > 0 and not return_all:
flist = []
for row0 in good_components[0][0].matrix().rows():
col0 = [QQ(o) for o in row0.list()]
clcm = lcm([o.denominator() for o in col0])
col0 = [ZZ(clcm * o ) for o in col0]
flist.append(sum([a * phi for a,phi in zip(col0,self.gens())],self(0)))
return flist,[(ell, o.restrict(good_components[0][0])) for ell, o in good_components[0][1]]
if len(component_list) == 0 or num_hecke_operators >= bound:
break
#.........这里部分代码省略.........
示例4: get_rational_cocycle
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import dimension [as 别名]
def get_rational_cocycle(self,sign = 1,use_magma = True,bound = 3, return_all = False):
F = self.group().base_ring()
if F.signature()[1] == 0 or (F.signature()[1] == 1 and 'G' not in self.group()._grouptype):
K = (self.hecke_matrix(oo).transpose()-sign).kernel().change_ring(QQ)
else:
K = Matrix(QQ,self.dimension(),self.dimension(),0).kernel()
component_list = []
good_components = []
if K.dimension() == 1:
good_components.append(K)
else:
component_list.append(K)
disc = self.S_arithgroup().Gpn._O_discriminant
discnorm = disc.norm()
try:
N = ZZ(discnorm.gen())
except AttributeError:
N = ZZ(discnorm)
if F == QQ:
x = QQ['x'].gen()
F = NumberField(x,names='a')
q = ZZ(1)
g0 = None
num_hecke_operators = 0
while len(component_list) > 0 and num_hecke_operators < bound:
verbose('num_hecke_ops = %s'%num_hecke_operators)
verbose('len(components_list) = %s'%len(component_list))
q = q.next_prime()
for qq,e in F.ideal(q).factor():
if ZZ(qq.norm()).is_prime() and not qq.divides(F.ideal(disc.gens_reduced()[0])):
try:
Aq = self.hecke_matrix(qq.gens_reduced()[0],g0 = g0,use_magma = use_magma).transpose().change_ring(QQ)
except (RuntimeError,TypeError) as e:
continue
verbose('Computed hecke matrix at qq = %s'%qq)
old_component_list = component_list
component_list = []
num_hecke_operators += 1
for U in old_component_list:
V = Aq.decomposition_of_subspace(U)
for U0,is_irred in V:
if Aq.restrict(U0).eigenvalues()[0] == ZZ(qq.norm()) + 1:
continue # Do not take Eisenstein classes.
if U0.dimension() == 1:
good_components.append(U0)
elif is_irred:
# Bad
continue
else: # U0.dimension() > 1 and not is_irred
component_list.append(U0)
if len(good_components) > 0 and not return_all:
K = good_components[0]
col = [ZZ(o) for o in (K.denominator()*K.matrix()).list()]
return sum([a*self.gen(i) for i,a in enumerate(col) if a != 0],self(0))
if len(component_list) == 0 or num_hecke_operators >= bound:
break
if len(good_components) == 0:
raise ValueError('Group does not seem to be attached to an elliptic curve')
else:
if return_all:
ans = []
for K in good_components:
col = [ZZ(o) for o in (K.denominator()*K.matrix()).list()]
ans.append( sum([a*self.gen(i) for i,a in enumerate(col) if a != 0],self(0)))
return ans
else:
K = good_components[0]
col = [ZZ(o) for o in (K.denominator()*K.matrix()).list()]
return sum([ a * self.gen(i) for i,a in enumerate(col) if a != 0], self(0))