Optimized counting of congruence solutions¶
- sage.quadratic_forms.count_local_2.CountAllLocalTypesNaive(Q, p, k, m, zvec, nzvec)[source]¶
- 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: - Q– quadratic form over \(\ZZ\)
- p– prime number > 0
- k– integer > 0
- m– integer (depending only on mod \(p^k\))
- zvec,- nzvec– list of integers in- range(Q.dim()), or- None
 - OUTPUT: - a list of six integers \(\ge 0\) representing the solution types: - [All, Good, Zero, Bad, BadI, BadII]- 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] - >>> from sage.all import * >>> from sage.quadratic_forms.count_local_2 import CountAllLocalTypesNaive >>> Q = DiagonalQuadraticForm(ZZ, [Integer(1),Integer(2),Integer(3)]) >>> CountAllLocalTypesNaive(Q, Integer(3), Integer(1), Integer(1), None, None) [6, 6, 0, 0, 0, 0] >>> CountAllLocalTypesNaive(Q, Integer(3), Integer(1), Integer(2), None, None) [6, 6, 0, 0, 0, 0] >>> CountAllLocalTypesNaive(Q, Integer(3), Integer(1), Integer(0), None, None) [15, 12, 1, 2, 0, 2] 
- sage.quadratic_forms.count_local_2.count_all_local_good_types_normal_form(Q, p, k, m, zvec, nzvec)[source]¶
- This is an internal routine, which is called by - sage.quadratic_forms.quadratic_form.QuadraticForm.local_good_density_congruence_even QuadraticForm.local_good_density_congruence_even(). See the documentation of that method for more details.- INPUT: - Q– quadratic form over \(\ZZ\) in local normal form at p with no zero blocks mod \(p^k\)
- p– prime number > 0
- k– integer > 0
- m– non-negative integer (depending only on mod \(p^k\))
- zvec,- nzvec– list of integers in- range(Q.dim()), or- None
 - OUTPUT: - a non-negative integer giving the number of solutions of Good type. - EXAMPLES: - sage: from sage.quadratic_forms.count_local_2 import count_all_local_good_types_normal_form sage: Q = DiagonalQuadraticForm(ZZ, [1,2,3]) sage: Q_local_at2 = Q.local_normal_form(2) sage: Q_local_at3 = Q.local_normal_form(3) sage: count_all_local_good_types_normal_form(Q_local_at2, 2, 3, 3, None, None) 64 sage: count_all_local_good_types_normal_form(Q_local_at2, 2, 3, 3, [0], None) 32 sage: count_all_local_good_types_normal_form(Q_local_at3, 3, 2, 1, None, None) 54 - >>> from sage.all import * >>> from sage.quadratic_forms.count_local_2 import count_all_local_good_types_normal_form >>> Q = DiagonalQuadraticForm(ZZ, [Integer(1),Integer(2),Integer(3)]) >>> Q_local_at2 = Q.local_normal_form(Integer(2)) >>> Q_local_at3 = Q.local_normal_form(Integer(3)) >>> count_all_local_good_types_normal_form(Q_local_at2, Integer(2), Integer(3), Integer(3), None, None) 64 >>> count_all_local_good_types_normal_form(Q_local_at2, Integer(2), Integer(3), Integer(3), [Integer(0)], None) 32 >>> count_all_local_good_types_normal_form(Q_local_at3, Integer(3), Integer(2), Integer(1), None, None) 54 
- sage.quadratic_forms.count_local_2.count_modp__by_gauss_sum(n, p, m, Qdet)[source]¶
- Return the number of solutions of \(Q(x) = m\) over the finite field \(\ZZ/p\ZZ\), where \(p\) is a prime number > 2 and \(Q\) is a non-degenerate quadratic form of dimension \(n \geq 1\) and has Gram determinant - Qdet.- REFERENCE: - These are defined in Table 1 on p363 of Hanke’s “Local Densities…” paper. - INPUT: - n– integer \(\geq 1\)
- p– a prime number > 2
- m– integer
- Qdet– a integer which is nonzero mod \(p\)
 - OUTPUT: integer \(\geq 0\) - 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] - >>> from sage.all import * >>> from sage.quadratic_forms.count_local_2 import count_modp__by_gauss_sum >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(0), Integer(1)) # for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3) 9 >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(1), Integer(1)) # for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3) 6 >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(2), Integer(1)) # for Q = x^2 + y^2 + z^2 => Gram Det = 1 (mod 3) 12 >>> Q = DiagonalQuadraticForm(ZZ, [Integer(1),Integer(1),Integer(1)]) >>> [Q.count_congruence_solutions(Integer(3), Integer(1), m, None, None) ... == count_modp__by_gauss_sum(Integer(3), Integer(3), m, Integer(1)) ... for m in range(Integer(3))] [True, True, True] >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(0), Integer(2)) # for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3) 9 >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(1), Integer(2)) # for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3) 12 >>> count_modp__by_gauss_sum(Integer(3), Integer(3), Integer(2), Integer(2)) # for Q = x^2 + y^2 + 2*z^2 => Gram Det = 2 (mod 3) 6 >>> Q = DiagonalQuadraticForm(ZZ, [Integer(1),Integer(1),Integer(2)]) >>> [Q.count_congruence_solutions(Integer(3), Integer(1), m, None, None) ... == count_modp__by_gauss_sum(Integer(3), Integer(3), m, Integer(2)) ... for m in range(Integer(3))] [True, True, True]