Optimised Cython code for counting congruence solutions
This is an internal routine, which is called by sage.quadratic_forms.quadratic_form.QuadraticForm.count_congruence_solutions_by_type QuadraticForm.count_congruence_solutions_by_type(). See the documentation of that method for more details.
INPUT:
EXAMPLES:
sage: from sage.quadratic_forms.count_local_2 import CountAllLocalTypesNaive
sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3])
sage: CountAllLocalTypesNaive(Q, 3, 1, 1, None, None)
[6, 6, 0, 0, 0, 0]
sage: CountAllLocalTypesNaive(Q, 3, 1, 2, None, None)
[6, 6, 0, 0, 0, 0]
sage: CountAllLocalTypesNaive(Q, 3, 1, 0, None, None)
[15, 12, 1, 2, 0, 2]
Returns the number of solutions of Q(x) = m over the finite field Z/pZ, where p is a prime number > 2 and Q is a non-degenerate quadratic form of dimension n >= 1 and has Gram determinant Qdet.
INPUT:
EXAMPLES:
sage: from sage.quadratic_forms.count_local_2 import count_modp__by_gauss_sum
sage: count_modp__by_gauss_sum(3, 3, 0, 1) ## for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3)
9
sage: count_modp__by_gauss_sum(3, 3, 1, 1) ## for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3)
6
sage: count_modp__by_gauss_sum(3, 3, 2, 1) ## for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3)
12
sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
sage: [Q.count_congruence_solutions(3, 1, m, None, None) == count_modp__by_gauss_sum(3, 3, m, 1) for m in range(3)]
[True, True, True]
sage: count_modp__by_gauss_sum(3, 3, 0, 2) ## for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3)
9
sage: count_modp__by_gauss_sum(3, 3, 1, 2) ## for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3)
12
sage: count_modp__by_gauss_sum(3, 3, 2, 2) ## for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3)
6
sage: Q = DiagonalQuadraticForm(ZZ, [1,1,2])
sage: [Q.count_congruence_solutions(3, 1, m, None, None) == count_modp__by_gauss_sum(3, 3, m, 2) for m in range(3)]
[True, True, True]
Returns the indices of Biglist which index the entries of Smalllist appearing in Biglist. (Note that Smalllist may not be a sublist of Biglist.)
NOTE 1: This is an internal routine which deals with re-indexing lists, and is not exported to the QuadraticForm namespace!
NOTE 2: This should really by applied only when BigList has no repeated entries.
TO DO: * Please revisit this routine, and eliminate it! *
EXAMPLES:
sage: from sage.quadratic_forms.count_local_2 import extract_sublist_indices
sage: biglist = [1,3,5,7,8,2,4]
sage: sublist = [5,3,2]
sage: sublist == [biglist[i] for i in extract_sublist_indices(biglist, sublist)] ## Ok whenever Smalllist is a sublist of Biglist
True
sage: extract_sublist_indices([1,2,3,6,9,11], [1,3,2,9])
[0, 2, 1, 4]
sage: extract_sublist_indices([1,2,3,6,9,11], [1,3,10,2,9,0])
[0, 2, 1, 4]
sage: extract_sublist_indices([1,3,5,3,8], [1,5])
Traceback (most recent call last):
...
TypeError: Biglist must not have repeated entries!