From 5875eaf16f042b843564b104459e27ac0437bc3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 6 Dec 2024 21:14:17 +0100 Subject: [PATCH] linting : some fixes for pyx files in modular --- src/sage/modular/arithgroup/congroup.pyx | 16 +++--- src/sage/modular/arithgroup/farey_symbol.pyx | 32 +++++------ src/sage/modular/modsym/heilbronn.pyx | 44 +++++++-------- src/sage/modular/modsym/manin_symbol.pyx | 5 +- src/sage/modular/modsym/p1list.pxd | 8 +-- src/sage/modular/modsym/p1list.pyx | 57 ++++++++++---------- src/sage/modular/pollack_stevens/dist.pyx | 28 +++++----- 7 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/sage/modular/arithgroup/congroup.pyx b/src/sage/modular/arithgroup/congroup.pyx index d55c0c0ce7c..4972b39f435 100644 --- a/src/sage/modular/arithgroup/congroup.pyx +++ b/src/sage/modular/arithgroup/congroup.pyx @@ -31,7 +31,7 @@ from sage.rings.integer_ring import ZZ Mat2Z = MatrixSpace(ZZ, 2) cdef Matrix_integer_dense genS, genT, genI -genS = Matrix_integer_dense(Mat2Z, [0,-1, 1, 0], True, True) +genS = Matrix_integer_dense(Mat2Z, [0, -1, 1, 0], True, True) genT = Matrix_integer_dense(Mat2Z, [1, 1, 0, 1], True, True) genI = Matrix_integer_dense(Mat2Z, [1, 0, 0, 1], True, True) @@ -123,7 +123,7 @@ def degeneracy_coset_representatives_gamma0(int N, int M, int t): # try to find another coset representative. cc = M*random.randrange(-halfmax, halfmax+1) dd = random.randrange(-halfmax, halfmax+1) - g = arith_int.c_xgcd_int(-cc,dd,&bb,&aa) + g = arith_int.c_xgcd_int(-cc, dd, &bb, &aa) if g == 0: continue cc = cc // g @@ -297,22 +297,24 @@ def generators_helper(coset_reps, level): [21 5], [ 7 -1], [-7 1] ] """ - cdef Matrix_integer_dense x,y,z,v,vSmod,vTmod + cdef Matrix_integer_dense x, y, z, v, vSmod, vTmod crs = coset_reps.list() try: - reps = [Matrix_integer_dense(Mat2Z,lift_to_sl2z(c, d, level),False,True) for c,d in crs] + reps = [Matrix_integer_dense(Mat2Z, lift_to_sl2z(c, d, level), + False, True) for c, d in crs] except Exception: raise ArithmeticError("Error lifting to SL2Z: level=%s crs=%s" % (level, crs)) ans = [] cdef Py_ssize_t i for i in range(len(crs)): x = reps[i] - v = Matrix_integer_dense(Mat2Z,[crs[i][0],crs[i][1],0,0],False,True) + v = Matrix_integer_dense(Mat2Z, [crs[i][0], crs[i][1], 0, 0], + False, True) vSmod = (v*genS) vTmod = (v*genT) - y_index = coset_reps.normalize(vSmod[0,0],vSmod[0,1]) - z_index = coset_reps.normalize(vTmod[0,0],vTmod[0,1]) + y_index = coset_reps.normalize(vSmod[0, 0], vSmod[0, 1]) + z_index = coset_reps.normalize(vTmod[0, 0], vTmod[0, 1]) y_index = crs.index(y_index) z_index = crs.index(z_index) y = reps[y_index] diff --git a/src/sage/modular/arithgroup/farey_symbol.pyx b/src/sage/modular/arithgroup/farey_symbol.pyx index c965015b41d..af81a0f61fc 100644 --- a/src/sage/modular/arithgroup/farey_symbol.pyx +++ b/src/sage/modular/arithgroup/farey_symbol.pyx @@ -13,15 +13,15 @@ based on the *KFarey* package by Chris Kurth. Implemented as C++ module for speed. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2011 Hartmut Monien # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from cpython.object cimport PyObject_RichCompare from itertools import groupby @@ -206,11 +206,11 @@ cdef class Farey: self.this_ptr = new cpp_farey(data) sig_off() return - ## to accelerate the calculation of the FareySymbol - ## we implement the tests for the standard congruence groups - ## in the c++ module. For a general group the test if an element - ## of SL2Z is in the group the python __contains__ attribute - ## of the group is called + # to accelerate the calculation of the FareySymbol + # we implement the tests for the standard congruence groups + # in the c++ module. For a general group the test if an element + # of SL2Z is in the group the python __contains__ attribute + # of the group is called cdef int p if hasattr(group, "level"): p = group.level() @@ -285,19 +285,19 @@ cdef class Farey: a, b, c, d = pm.matrix().list() newval = gens_dict.get(SL2Z([a, b, c, d])) if newval is not None: - ans.append((newval,1)) + ans.append((newval, 1)) continue newval = gens_dict.get(SL2Z([-a, -b, -c, -d])) if newval is not None: - ans.append((newval,-1)) + ans.append((newval, -1)) continue newval = gens_dict.get(SL2Z([d, -b, -c, a])) if newval is not None: - ans.append((-newval,1)) + ans.append((-newval, 1)) continue newval = gens_dict.get(SL2Z([-d, b, c, -a])) if newval is not None: - ans.append((-newval,-1)) + ans.append((-newval, -1)) continue raise RuntimeError("This should have not happened") return ans @@ -453,7 +453,7 @@ cdef class Farey: result = self.this_ptr.word_problem(a.value, b.value, c.value, d.value, cpp_beta) sig_off() beta = convert_to_SL2Z(cpp_beta[0])**-1 - mbeta = SL2Z([-beta.a(),-beta.b(),-beta.c(),-beta.d()]) + mbeta = SL2Z([-beta.a(), -beta.b(), -beta.c(), -beta.d()]) V = self.pairing_matrices_to_tietze_index() sgn = 1 tietze = [] @@ -500,7 +500,7 @@ cdef class Farey: tietze.reverse() gens = self.generators() if check: - tmp = SL2Z([1,0,0,1]) + tmp = SL2Z([1, 0, 0, 1]) for i in range(len(tietze)): t = tietze[i] tmp = tmp * gens[t-1] if t > 0 else tmp * gens[-t-1]**-1 @@ -1009,7 +1009,7 @@ cdef class Farey: fill=options['fill'], linestyle=options['linestyle'], thickness=options['thickness']) - ## show pairings + # show pairings p = self.pairings() x = self.fractions() if options['show_pairing']: @@ -1033,7 +1033,7 @@ cdef class Farey: return g -#--- conversions ------------------------------------------------------------ +# ----- conversions --------------------------------- cdef public long convert_to_long(n) noexcept: cdef long m = n diff --git a/src/sage/modular/modsym/heilbronn.pyx b/src/sage/modular/modsym/heilbronn.pyx index 82adf9efa20..598e8ccfff9 100644 --- a/src/sage/modular/modsym/heilbronn.pyx +++ b/src/sage/modular/modsym/heilbronn.pyx @@ -202,8 +202,8 @@ cdef class Heilbronn: b[i] = (u * self.list.v[4*i+1]) % N + (v * self.list.v[4*i+3]) % N else: for i in range(self.length): - a[i] = llong_prod_mod(u,self.list.v[4*i],N) + llong_prod_mod(v,self.list.v[4*i+2], N) - b[i] = llong_prod_mod(u,self.list.v[4*i+1],N) + llong_prod_mod(v,self.list.v[4*i+3], N) + a[i] = llong_prod_mod(u, self.list.v[4*i], N) + llong_prod_mod(v, self.list.v[4*i+2], N) + b[i] = llong_prod_mod(u, self.list.v[4*i+1], N) + llong_prod_mod(v, self.list.v[4*i+3], N) sig_off() cdef apply_to_polypart(self, fmpz_poly_t* ans, int i, int k): @@ -283,8 +283,8 @@ cdef class Heilbronn: else: for i in range(self.length): sig_check() - a = llong_prod_mod(u,self.list.v[4*i],N) + llong_prod_mod(v,self.list.v[4*i+2], N) - b = llong_prod_mod(u,self.list.v[4*i+1],N) + llong_prod_mod(v,self.list.v[4*i+3], N) + a = llong_prod_mod(u, self.list.v[4*i], N) + llong_prod_mod(v, self.list.v[4*i+2], N) + b = llong_prod_mod(u, self.list.v[4*i+1], N) + llong_prod_mod(v, self.list.v[4*i+3], N) export.c_p1_normalize_llong(N, a, b, &c, &d, &s, 0) X = (c, d) if X in M: @@ -368,15 +368,15 @@ cdef class HeilbronnCremona(Heilbronn): L = &self.list p = self.p - list_append4(L, 1,0,0,p) + list_append4(L, 1, 0, 0, p) # When p==2, then Heilbronn matrices are # [[1,0,0,2], [2,0,0,1], [2,1,0,1], [1,0,1,2]] # which are not given by the algorithm below. if p == 2: - list_append4(L, 2,0,0,1) - list_append4(L, 2,1,0,1) - list_append4(L, 1,0,1,2) + list_append4(L, 2, 0, 0, 1) + list_append4(L, 2, 1, 0, 1) + list_append4(L, 1, 0, 1, 2) self.length = 4 return @@ -489,20 +489,20 @@ cdef class HeilbronnMerel(Heilbronn): sig_on() for a in range(1, n+1): - ## We have ad-bc=n so c=0 and ad=n, or b=(ad-n)/c - ## Must have ad - n >= 0, so d must be >= Ceiling(n/a). + # We have ad-bc=n so c=0 and ad=n, or b=(ad-n)/c + # Must have ad - n >= 0, so d must be >= Ceiling(n/a). q = n // a if q*a == n: d = q for b in range(a): - list_append4(L, a,b,0,d) + list_append4(L, a, b, 0, d) for c in range(1, d): - list_append4(L, a,0,c,d) + list_append4(L, a, 0, c, d) for d in range(q+1, n+1): bc = (a) * (d) - (n) - ## Divisor c of bc must satisfy Floor(bc/c) lt a and c lt d. - ## c ge (bc div a + 1) <=> Floor(bc/c) lt a (for integers) - ## c le d - 1 <=> c lt d + # Divisor c of bc must satisfy Floor(bc/c) lt a and c lt d. + # c ge (bc div a + 1) <=> Floor(bc/c) lt a (for integers) + # c le d - 1 <=> c lt d for c in range(bc // a + 1, d): if bc % c == 0: list_append4(L, a, bc // c, c, d) @@ -569,7 +569,7 @@ def hecke_images_gamma0_weight2(int u, int v, int N, indices, R): cdef Heilbronn H t = verbose("computing non-reduced images of symbol under Hecke operators", - level=1, caller_name='hecke_images_gamma0_weight2') + level=1, caller_name='hecke_images_gamma0_weight2') for i, n in enumerate(indices): # List the Heilbronn matrices of determinant n defined by Cremona or Merel H = HeilbronnCremona(n) if is_prime(n) else HeilbronnMerel(n) @@ -601,25 +601,25 @@ def hecke_images_gamma0_weight2(int u, int v, int N, indices, R): sig_free(b) t = verbose("finished computing non-reduced images", - t, level=1, caller_name='hecke_images_gamma0_weight2') + t, level=1, caller_name='hecke_images_gamma0_weight2') t = verbose("Now reducing images of symbol", - level=1, caller_name='hecke_images_gamma0_weight2') + level=1, caller_name='hecke_images_gamma0_weight2') # Return the product T * R, whose rows are the image of (u,v) under # the Hecke operators T_n for n in indices. if max(indices) <= 30: # In this case T tends to be very sparse ans = T.sparse_matrix()._matrix_times_matrix_dense(R) verbose("did reduction using sparse multiplication", - t, level=1, caller_name='hecke_images_gamma0_weight2') + t, level=1, caller_name='hecke_images_gamma0_weight2') elif R.is_sparse(): ans = T * R.dense_matrix() verbose("did reduction using dense multiplication", - t, level=1, caller_name='hecke_images_gamma0_weight2') + t, level=1, caller_name='hecke_images_gamma0_weight2') else: ans = T * R verbose("did reduction using dense multiplication", - t, level=1, caller_name='hecke_images_gamma0_weight2') + t, level=1, caller_name='hecke_images_gamma0_weight2') if original_base_ring != QQ: ans = ans.change_ring(original_base_ring) @@ -700,7 +700,7 @@ def hecke_images_nonquad_character_weight2(int u, int v, int N, indices, chi, R) cdef Heilbronn H t = verbose("computing non-reduced images of symbol under Hecke operators", - level=1, caller_name='hecke_images_character_weight2') + level=1, caller_name='hecke_images_character_weight2') # Make a matrix over the rational numbers each of whose columns # are the values of the character chi. diff --git a/src/sage/modular/modsym/manin_symbol.pyx b/src/sage/modular/modsym/manin_symbol.pyx index 726f78c55a6..0a7feaffb5b 100644 --- a/src/sage/modular/modsym/manin_symbol.pyx +++ b/src/sage/modular/modsym/manin_symbol.pyx @@ -401,7 +401,7 @@ cdef class ManinSymbol(Element): N=int(N) if N < 1: raise ArithmeticError("N must be positive") - a,b,c,d = self.lift_to_sl2z() + a, b, c, d = self.lift_to_sl2z() return Cusp(b, d), Cusp(a, c) def weight(self): @@ -453,8 +453,7 @@ cdef class ManinSymbol(Element): # TODO: It would likely be much better to do this slightly more directly from sage.modular.modsym.modular_symbols import ModularSymbol x = ModularSymbol(self.parent(), self.i, 0, Infinity) - a,b,c,d = self.lift_to_sl2z() - return x.apply([a,b,c,d]) + return x.apply(self.lift_to_sl2z()) def _print_polypart(i, j): diff --git a/src/sage/modular/modsym/p1list.pxd b/src/sage/modular/modsym/p1list.pxd index b66f28b8ad6..b559922411c 100644 --- a/src/sage/modular/modsym/p1list.pxd +++ b/src/sage/modular/modsym/p1list.pxd @@ -6,8 +6,8 @@ cdef class export: int compute_s) except -1 cdef int c_p1_normalize_llong(self, int N, int u, int v, - int* uu, int* vv, int* ss, - int compute_s) except -1 + int* uu, int* vv, int* ss, + int compute_s) except -1 cdef class P1List: @@ -22,7 +22,7 @@ cdef class P1List: # for normalizing an element does not need to be used # every time the user calls the normalize function. cdef int (*_normalize)(int N, int u, int v, - int* uu, int* vv, int* ss, - int compute_s) except -1 + int* uu, int* vv, int* ss, + int compute_s) except -1 cpdef index(self, int u, int v) cdef index_and_scalar(self, int u, int v, int* i, int* s) diff --git a/src/sage/modular/modsym/p1list.pyx b/src/sage/modular/modsym/p1list.pyx index 7ceda12d5c8..f7d5f4b209b 100644 --- a/src/sage/modular/modsym/p1list.pyx +++ b/src/sage/modular/modsym/p1list.pyx @@ -75,7 +75,7 @@ cdef int c_p1_normalize_int(int N, int u, int v, v += N if u == 0: uu[0] = 0 - if arith_int.c_gcd_int(v,N) == 1: + if arith_int.c_gcd_int(v, N) == 1: vv[0] = 1 else: vv[0] = 0 @@ -96,7 +96,7 @@ cdef int c_p1_normalize_int(int N, int u, int v, # Adjust s modulo N/g so it is coprime to N. if g != 1: d = N // g - while arith_int.c_gcd_int(s,N) != 1: + while arith_int.c_gcd_int(s, N) != 1: s = (s+d) % N # Multiply [u,v] by s; then [s*u,s*v] = [g,s*v] (mod N) @@ -112,7 +112,7 @@ cdef int c_p1_normalize_int(int N, int u, int v, for k in range(2, g + 1): v = (v + vNg) % N t = (t + Ng) % N - if v N - #if N<=0 or N >= 2**31: - # raise OverflowError("Modulus is too large (must be < 46340)") - # return -1 + # if N <= 0 or N >= 2**31: + # raise OverflowError("Modulus is too large (must be < 46340)") + # return -1 u = u % N v = v % N @@ -333,14 +333,14 @@ cdef int c_p1_normalize_llong(int N, int u, int v, v += N if u == 0: uu[0] = 0 - if arith_int.c_gcd_int(v,N) == 1: + if arith_int.c_gcd_int(v, N) == 1: vv[0] = 1 else: vv[0] = 0 ss[0] = v return 0 - #g = xgcd_int_llong(u, N, &s, &t) + # g = xgcd_int_llong(u, N, &s, &t) g = arith_llong.c_xgcd_longlong(u, N, &ll_s, &ll_t) s = (ll_s % ll_N) t = (ll_t % ll_N) @@ -357,7 +357,7 @@ cdef int c_p1_normalize_llong(int N, int u, int v, # Adjust s modulo N/g so it is coprime to N. if g != 1: d = N // g - while arith_int.c_gcd_int(s,N) != 1: + while arith_int.c_gcd_int(s, N) != 1: s = (s+d) % N # Multiply [u,v] by s; then [s*u,s*v] = [g,s*v] (mod N) @@ -466,7 +466,7 @@ def p1list_llong(int N): if N == 1: return [(0, 0)] - lst = [(0,1)] + lst = [(0, 1)] c = 1 for d in range(N): lst.append((c, d)) @@ -720,7 +720,7 @@ cdef class P1List(): else: raise OverflowError("p1list not defined for such large N.") self.__list.sort() - self.__end_hash = dict([(x,i) for i, x in enumerate(self.__list[N+1:])]) + self.__end_hash = {x: i for i, x in enumerate(self.__list[N+1:])} # Allocate memory for xgcd table. self.g = NULL @@ -870,7 +870,7 @@ cdef class P1List(): cdef int c, d, N if self.__N == 1: - return [1,0,0,1] + return [1, 0, 0, 1] c, d = self.__list[i] N = self.__N @@ -909,9 +909,9 @@ cdef class P1List(): True """ cdef int u, v, uu, vv, ss - u,v = self.__list[i] + u, v = self.__list[i] self._normalize(self.__N, -u, v, &uu, &vv, &ss, 0) - _, j = search(self.__list, (uu,vv)) + _, j = search(self.__list, (uu, vv)) return j def apply_S(self, int i): @@ -941,9 +941,9 @@ cdef class P1List(): True """ cdef int u, v, uu, vv, ss - u,v = self.__list[i] + u, v = self.__list[i] self._normalize(self.__N, -v, u, &uu, &vv, &ss, 0) - _, j = search(self.__list, (uu,vv)) + _, j = search(self.__list, (uu, vv)) return j def apply_T(self, int i): @@ -973,9 +973,9 @@ cdef class P1List(): True """ cdef int u, v, uu, vv, ss - u,v = self.__list[i] + u, v = self.__list[i] self._normalize(self.__N, v, -u-v, &uu, &vv, &ss, 0) - _, j = search(self.__list, (uu,vv)) + _, j = search(self.__list, (uu, vv)) return j cpdef index(self, int u, int v): @@ -1014,7 +1014,7 @@ cdef class P1List(): return -1 return 0 try: - return self.__end_hash[(uu,vv)] + self.__N + 1 + return self.__end_hash[(uu, vv)] + self.__N + 1 except KeyError: return -1 @@ -1053,7 +1053,7 @@ cdef class P1List(): i[0] = 0 return try: - i[0] = self.__end_hash[(uu,vv)] + self.__N + 1 + i[0] = self.__end_hash[(uu, vv)] + self.__N + 1 return except KeyError: i[0] = -1 @@ -1084,7 +1084,7 @@ cdef class P1List(): sage: all(L.index_of_normalized_pair(L[i][0],L[i][1])==i for i in range(len(L))) True """ - t, i = search(self.__list, (u,v)) + t, i = search(self.__list, (u, v)) if t: return i return -1 @@ -1129,7 +1129,7 @@ cdef class P1List(): """ cdef int uu, vv, ss self._normalize(self.__N, u, v, &uu, &vv, &ss, 0) - return (uu,vv) + return (uu, vv) def normalize_with_scalar(self, int u, int v): r""" @@ -1365,11 +1365,10 @@ def lift_to_sl2z(c, d, N): [1, 0, 0, 1] """ if N <= 46340: - return lift_to_sl2z_int(c,d,N) - elif N <= 2147483647: - return lift_to_sl2z_llong(c,d,N) - else: - raise NotImplementedError("N too large") + return lift_to_sl2z_int(c, d, N) + if N <= 2147483647: + return lift_to_sl2z_llong(c, d, N) + raise NotImplementedError("N too large") def _make_p1list(n): diff --git a/src/sage/modular/pollack_stevens/dist.pyx b/src/sage/modular/pollack_stevens/dist.pyx index 85cccd3bb11..9ed53a955c9 100644 --- a/src/sage/modular/pollack_stevens/dist.pyx +++ b/src/sage/modular/pollack_stevens/dist.pyx @@ -43,7 +43,7 @@ from sage.rings.rational_field import QQ from sage.structure.element cimport Element from sage.structure.richcmp cimport richcmp_not_equal, rich_to_bool -#from sage.libs.flint.ulong_extras cimport * +# from sage.libs.flint.ulong_extras cimport * cdef long overflow = 1 << (4 * sizeof(long) - 1) cdef long underflow = -overflow @@ -360,8 +360,8 @@ cdef class Dist(ModuleElement): raise ValueError("self is zero") v = a.valuation(p) relprec = n - i - v -# verbose("p=%s, n-i=%s\nself.moment=%s, other.moment=%s" % (p, n-i, a, other._unscaled_moment(i)),level=2) -## RP: This code was crashing because other may have too few moments -- so I added this bound with other's relative precision + # verbose("p=%s, n-i=%s\nself.moment=%s, other.moment=%s" % (p, n-i, a, other._unscaled_moment(i)),level=2) + # RP: This code was crashing because other may have too few moments -- so I added this bound with other's relative precision if padic: if i < other_pr: alpha = (other._unscaled_moment(i) / a).add_bigoh(n - i) @@ -373,7 +373,7 @@ cdef class Dist(ModuleElement): else: alpha = 0 verbose("alpha = %s" % alpha, level = 2) -## RP: This code was crashing because other may have too few moments -- so I added this bound with other's relative precision + # RP: This code was crashing because other may have too few moments -- so I added this bound with other's relative precision while i < other_pr - 1: i += 1 verbose("comparing p moment %s" % i, level = 2) @@ -656,11 +656,11 @@ cdef class Dist(ModuleElement): zero = R(0) moments.extend([zero] * (M - k - 1)) mu = V(moments) - #val = mu.valuation() - #if val < 0: - # # This seems unnatural - # print("scaling by ", p, "^", -val, " to keep things integral") - # mu *= p**(-val) + # val = mu.valuation() + # if val < 0: + # # This seems unnatural + # print("scaling by ", p, "^", -val, " to keep things integral") + # mu *= p**(-val) return mu def _is_malformed(self): @@ -1129,7 +1129,7 @@ cdef class Dist_vector(Dist): """ # assert self._moments[0][0]==0, "not total measure zero" # print("result accurate modulo p^",self.moment(0).valuation(self.p) ) - #v=[0 for j in range(0,i)]+[binomial(j,i)*bernoulli(j-i) for j in range(i,M)] + # v=[0 for j in range(0,i)]+[binomial(j,i)*bernoulli(j-i) for j in range(i,M)] M = self.precision_relative() R = self.parent().base_ring() K = R.fraction_field() @@ -1361,7 +1361,7 @@ cdef class WeightKAction_vector(WeightKAction): sage: v * D._act.actor()(g) # indirect doctest (-107, 35, -12, 5) """ - #tim = verbose("Starting") + # tim = verbose("Starting") a, b, c, d = self._adjuster(g) # if g.parent().base_ring().is_exact(): # self._check_mat(a, b, c, d) @@ -1378,17 +1378,17 @@ cdef class WeightKAction_vector(WeightKAction): return B.change_ring(self.codomain().base_ring()) R = PowerSeriesRing(base_ring, 'y', default_prec=M) y = R.gen() - #tim = verbose("Checked, made R",tim) + # tim = verbose("Checked, made R",tim) # special case for small precision, large weight scale = (b + d * y) / (a + c * y) t = (a + c * y) ** k # will already have precision M cdef long row, col - #tim = verbose("Made matrix",tim) + # tim = verbose("Made matrix",tim) for col in range(M): for row in range(M): B.set_unsafe(row, col, t[row]) t *= scale - #verbose("Finished loop",tim) + # verbose("Finished loop",tim) # the changering here is annoying, but otherwise we have to # change ring each time we multiply B = B.change_ring(self.codomain().base_ring())