Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/algebras/clifford_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ def _coerce_map_from_(self, V):
Q = self._quadratic_form
try:
return (V.variable_names() == self.variable_names() and
V._quadratic_form.base_change_to(self.base_ring()) == Q)
except Exception:
V._quadratic_form.change_ring(self.base_ring()) == Q)
except (TypeError, AttributeError):
return False

if self.free_module().has_coerce_map_from(V):
Expand Down
17 changes: 3 additions & 14 deletions src/sage/quadratic_forms/count_local_2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ def count_modp__by_gauss_sum(n, p, m, Qdet):
return count






cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec):
"""
This Cython routine is documented in its Python wrapper method
Expand All @@ -104,26 +100,21 @@ cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec):
cdef long ptr # Used to increment the vector
cdef long solntype # Used to store the kind of solution we find


# Some shortcuts and definitions
n = Q.dim()
R = p ** k
Q1 = Q.base_change_to(IntegerModRing(R))

Q1 = Q.change_ring(IntegerModRing(R))

# Cython Variables
cdef IntegerMod_gmp zero, one
zero = IntegerMod_gmp(IntegerModRing(R), 0)
one = IntegerMod_gmp(IntegerModRing(R), 1)



# Initialize the counting vector
count_vector = [0 for i in range(6)]
count_vector = [0 for i in range(6)]

# Initialize v = (0, ... , 0)
v = [Mod(0, R) for i in range(n)]

v = [Mod(0, R) for i in range(n)]

# Some declarations to speed up the loop
R_n = R ** n
Expand All @@ -142,7 +133,6 @@ cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec):
if (ptr > 0):
v[ptr-1] += 1


# Evaluate Q(v) quickly
tmp_val = Mod(0, R)
for a from 0 <= a < n:
Expand All @@ -156,7 +146,6 @@ cdef CountAllLocalTypesNaive_cdef(Q, p, k, m, zvec, nzvec):
if (solntype != 0):
count_vector[solntype] += 1


# Generate the Bad-type and Total counts
count_vector[3] = count_vector[4] + count_vector[5]
count_vector[0] = count_vector[1] + count_vector[2] + count_vector[3]
Expand Down
12 changes: 6 additions & 6 deletions src/sage/quadratic_forms/quadratic_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from sage.quadratic_forms.quadratic_form__evaluate import QFEvaluateVector, QFEvaluateMatrix
from sage.structure.sage_object import SageObject
from sage.combinat.integer_lists.invlex import IntegerListsLex
from sage.misc.superseded import deprecated_function_alias


def QuadraticForm__constructor(R, n=None, entries=None):
"""
Expand Down Expand Up @@ -1554,8 +1556,7 @@ def Gram_det(self):
"""
return self.det() / ZZ(2**self.dim())


def base_change_to(self, R):
def change_ring(self, R):
"""
Alters the quadratic form to have all coefficients
defined over the new base_ring R. Here R must be
Expand All @@ -1580,16 +1581,13 @@ def base_change_to(self, R):
[ 1 0 ]
[ * 1 ]

::

sage: Q1 = Q.base_change_to(IntegerModRing(5)); Q1
sage: Q1 = Q.change_ring(IntegerModRing(5)); Q1
Quadratic form in 2 variables over Ring of integers modulo 5 with coefficients:
[ 1 0 ]
[ * 1 ]

sage: Q1([35,11])
1

"""
# Check that a canonical coercion is possible
if not is_Ring(R):
Expand All @@ -1599,6 +1597,8 @@ def base_change_to(self, R):
# Return the coerced form
return QuadraticForm(R, self.dim(), [R(x) for x in self.coefficients()])

base_change_to = deprecated_function_alias(35248, change_ring)

def level(self):
r"""
Determines the level of the quadratic form over a PID, which is a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _rational_diagonal_form_and_transformation(self):
"""
n = self.dim()
K = self.base_ring().fraction_field()
Q = self.base_change_to(K)
Q = self.change_ring(K)
MS = MatrixSpace(K, n, n)

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Copyright by Jonathan Hanke 2007 <[email protected]>
########################################################################

import copy
from copy import deepcopy

from sage.misc.misc_c import prod
from sage.misc.mrange import mrange
Expand Down Expand Up @@ -192,7 +192,7 @@ def Watson_mass_at_2(self):

"""
# Make a 0-dim'l quadratic form (for initialization purposes)
Null_Form = copy.deepcopy(self)
Null_Form = deepcopy(self)
Null_Form.__init__(ZZ, 0)

# Step 0: Compute Jordan blocks and bounds of the scales to keep track of
Expand Down Expand Up @@ -231,7 +231,7 @@ def Watson_mass_at_2(self):
eps_dict = {}
for j in range(s_min, s_max+3):
two_form = (diag_dict[j-2] + diag_dict[j] + dim2_dict[j]).scale_by_factor(2)
j_form = (two_form + diag_dict[j-1]).base_change_to(IntegerModRing(4))
j_form = (two_form + diag_dict[j-1]).change_ring(IntegerModRing(4))

if j_form.dim() == 0:
eps_dict[j] = 1
Expand Down Expand Up @@ -280,7 +280,7 @@ def Kitaoka_mass_at_2(self):

"""
# Make a 0-dim'l quadratic form (for initialization purposes)
Null_Form = copy.deepcopy(self)
Null_Form = deepcopy(self)
Null_Form.__init__(ZZ, 0)

# Step 0: Compute Jordan blocks and bounds of the scales to keep track of
Expand Down Expand Up @@ -373,7 +373,7 @@ def mass_at_two_by_counting_mod_power(self, k):
4
"""
R = IntegerModRing(2**k)
Q1 = self.base_change_to(R)
Q1 = self.change_ring(R)
n = self.dim()
MS = MatrixSpace(R, n)

Expand Down