# 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 was, 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 #    * Specialized echelon form ######################################################################## def _clear_denom(self): """ INPUT: -  ``self`` - a matrix OUTPUT:  self, 1 EXAMPLES:: sage: a = matrix(ZZ,2,[1,2,3,4]) sage: a._clear_denom() ([1 2] [3 4], 1) """ return self, ZZ(1) def charpoly(self, var='x', algorithm='linbox'): """ INPUT:
• ## sage/modular/hecke/algebra.py

`diff --git a/sage/modular/hecke/algebra.py b/sage/modular/hecke/algebra.py`
 a level = self.level() bound = self.__M.hecke_bound() dim = self.__M.rank() span = [self.hecke_operator(n) for n in range(1, bound+1) if not self.is_anemic() or gcd(n, level) == 1] rand_max = 5 while True: # Project the full Hecke module to a random submodule to ease the HNF reduction. v = (ZZ**dim).random_element(x=rand_max) proj_span = matrix([T.matrix()*v for T in span])._clear_denom()[0] proj_basis = proj_span.hermite_form() if proj_basis[dim-1] == 0: # We got unlucky, choose another projection. rand_max *= 2 continue # Lift the projected basis to a basis in the Hecke algebra. trans = proj_span.solve_left(proj_basis) self.__basis_cache = [sum(c*T for c,T in zip(row,span) if c != 0) for row in trans[:dim]] return self.__basis_cache if dim == 0: basis = [] elif dim == 1: basis = [self.hecke_operator(1)] else: span = [self.hecke_operator(n) for n in range(1, bound+1) if not self.is_anemic() or gcd(n, level) == 1] rand_max = 5 while True: # Project the full Hecke module to a random submodule to ease the HNF reduction. v = (ZZ**dim).random_element(x=rand_max) proj_span = matrix([T.matrix()*v for T in span])._clear_denom()[0] proj_basis = proj_span.hermite_form() if proj_basis[dim-1] == 0: # We got unlucky, choose another projection. rand_max *= 2 continue # Lift the projected basis to a basis in the Hecke algebra. trans = proj_span.solve_left(proj_basis) basis = [sum(c*T for c,T in zip(row,span) if c != 0) for row in trans[:dim]] break self.__basis_cache = tuple(basis) return basis def discriminant(self): r""" 1 sage: ModularSymbols(65, sign=1).cuspidal_submodule().hecke_algebra().discriminant() 6144 sage: ModularSymbols(1,4,sign=1).cuspidal_submodule().hecke_algebra().discriminant() 1 """ try: return self.__disc except AttributeError: pass basis = self.basis() d = len(self.basis()) d = len(basis) if d <= 1: self.__disc = ZZ(1) return self.__disc trace_matrix = matrix(ZZ, d) for i in range(d): for j in range(i+1):