Ticket #6911: trac_6911-referee_followup_that_fixes_some_bugs.patch
File trac_6911-referee_followup_that_fixes_some_bugs.patch, 3.8 KB (added by , 13 years ago) |
---|
-
sage/matrix/matrix_integer_dense.pyx
# HG changeset patch # User William Stein <wstein@gmail.com> # Date 1253360524 25200 # Node ID aa8a28413ee8d60a439e05bb2979051f3b0461c8 # Parent 5db2f54f62e9661195a7d8f84ee767232bc2cda2 trac 6911 -- discriminants of Hecke algebras diff --git a/sage/matrix/matrix_integer_dense.pyx b/sage/matrix/matrix_integer_dense.pyx
a b 955 955 # * Specialized echelon form 956 956 ######################################################################## 957 957 958 def _clear_denom(self): 959 """ 960 INPUT: 961 962 - ``self`` - a matrix 963 964 OUTPUT: self, 1 965 966 EXAMPLES:: 967 968 sage: a = matrix(ZZ,2,[1,2,3,4]) 969 sage: a._clear_denom() 970 ([1 2] 971 [3 4], 1) 972 """ 973 return self, ZZ(1) 974 958 975 def charpoly(self, var='x', algorithm='linbox'): 959 976 """ 960 977 INPUT: -
sage/modular/hecke/algebra.py
diff --git a/sage/modular/hecke/algebra.py b/sage/modular/hecke/algebra.py
a b 473 473 level = self.level() 474 474 bound = self.__M.hecke_bound() 475 475 dim = self.__M.rank() 476 span = [self.hecke_operator(n) for n in range(1, bound+1) if not self.is_anemic() or gcd(n, level) == 1] 477 rand_max = 5 478 while True: 479 # Project the full Hecke module to a random submodule to ease the HNF reduction. 480 v = (ZZ**dim).random_element(x=rand_max) 481 proj_span = matrix([T.matrix()*v for T in span])._clear_denom()[0] 482 proj_basis = proj_span.hermite_form() 483 if proj_basis[dim-1] == 0: 484 # We got unlucky, choose another projection. 485 rand_max *= 2 486 continue 487 # Lift the projected basis to a basis in the Hecke algebra. 488 trans = proj_span.solve_left(proj_basis) 489 self.__basis_cache = [sum(c*T for c,T in zip(row,span) if c != 0) for row in trans[:dim]] 490 return self.__basis_cache 476 if dim == 0: 477 basis = [] 478 elif dim == 1: 479 basis = [self.hecke_operator(1)] 480 else: 481 span = [self.hecke_operator(n) for n in range(1, bound+1) if not self.is_anemic() or gcd(n, level) == 1] 482 rand_max = 5 483 while True: 484 # Project the full Hecke module to a random submodule to ease the HNF reduction. 485 v = (ZZ**dim).random_element(x=rand_max) 486 proj_span = matrix([T.matrix()*v for T in span])._clear_denom()[0] 487 proj_basis = proj_span.hermite_form() 488 if proj_basis[dim-1] == 0: 489 # We got unlucky, choose another projection. 490 rand_max *= 2 491 continue 492 # Lift the projected basis to a basis in the Hecke algebra. 493 trans = proj_span.solve_left(proj_basis) 494 basis = [sum(c*T for c,T in zip(row,span) if c != 0) for row in trans[:dim]] 495 break 496 497 self.__basis_cache = tuple(basis) 498 return basis 491 499 492 500 def discriminant(self): 493 501 r""" … … 507 515 1 508 516 sage: ModularSymbols(65, sign=1).cuspidal_submodule().hecke_algebra().discriminant() 509 517 6144 518 sage: ModularSymbols(1,4,sign=1).cuspidal_submodule().hecke_algebra().discriminant() 519 1 510 520 """ 511 521 try: 512 522 return self.__disc 513 523 except AttributeError: 514 524 pass 515 525 basis = self.basis() 516 d = len(self.basis()) 526 d = len(basis) 527 if d <= 1: 528 self.__disc = ZZ(1) 529 return self.__disc 517 530 trace_matrix = matrix(ZZ, d) 518 531 for i in range(d): 519 532 for j in range(i+1):