Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Local Normal Form """
#***************************************************************************** # Copyright (C) 2007 William Stein and Jonathan Hanke # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #*****************************************************************************
import copy from sage.rings.infinity import Infinity from sage.rings.integer_ring import IntegerRing, ZZ from sage.rings.rational_field import QQ from sage.arith.all import GCD, valuation, is_prime
def find_entry_with_minimal_scale_at_prime(self, p): """ Finds the entry of the quadratic form with minimal scale at the prime p, preferring diagonal entries in case of a tie. (I.e. If we write the quadratic form as a symmetric matrix M, then this entry M[i,j] has the minimal valuation at the prime p.)
Note: This answer is independent of the kind of matrix (Gram or Hessian) associated to the form.
INPUT:
`p` -- a prime number > 0
OUTPUT:
a pair of integers >= 0
EXAMPLES::
sage: Q = QuadraticForm(ZZ, 2, [6, 2, 20]); Q Quadratic form in 2 variables over Integer Ring with coefficients: [ 6 2 ] [ * 20 ] sage: Q.find_entry_with_minimal_scale_at_prime(2) (0, 1) sage: Q.find_entry_with_minimal_scale_at_prime(3) (1, 1) sage: Q.find_entry_with_minimal_scale_at_prime(5) (0, 0)
"""
## Compute the valuation of the entry else:
## Check if it's any smaller than what we have
## Return the result
def local_normal_form(self, p): """ Returns the a locally integrally equivalent quadratic form over the p-adic integers Z_p which gives the Jordan decomposition. The Jordan components are written as sums of blocks of size <= 2 and are arranged by increasing scale, and then by increasing norm. (This is equivalent to saying that we put the 1x1 blocks before the 2x2 blocks in each Jordan component.)
INPUT:
`p` -- a positive prime number.
OUTPUT:
a quadratic form over ZZ
WARNING: Currently this only works for quadratic forms defined over ZZ.
EXAMPLES::
sage: Q = QuadraticForm(ZZ, 2, [10,4,1]) sage: Q.local_normal_form(5) Quadratic form in 2 variables over Integer Ring with coefficients: [ 1 0 ] [ * 6 ]
::
sage: Q.local_normal_form(3) Quadratic form in 2 variables over Integer Ring with coefficients: [ 10 0 ] [ * 15 ]
sage: Q.local_normal_form(2) Quadratic form in 2 variables over Integer Ring with coefficients: [ 1 0 ] [ * 6 ]
""" ## Sanity Checks raise NotImplementedError("Oops! This currently only works for quadratic forms defined over IntegerRing(). =(") raise TypeError("Oops! p is not a positive prime number. =(")
## Some useful local variables
## Prepare the final form to return
## Step 1: Find the minimally p-divisible matrix entry, preferring diagonals ## ------------------------------------------------------------------------- else:
## Error if we still haven't seen non-zero coefficients! raise RuntimeError("Oops! The original matrix is degenerate. =(")
## Step 2: Arrange for the upper leftmost entry to have minimal valuation ## ---------------------------------------------------------------------- else: ## Work in the upper-left 2x2 block, and replace it by its 2-adic equivalent form
## 1x1 => make upper left the smallest ## 2x2 => replace it with the appropriate 2x2 matrix else:
## DIAGNOSTIC #print "\n Finished Step 2 \n"; #print "\n Q is: \n" + str(Q) + "\n"; #print " p is: " + str(p) #print " min_val is: " + str( min_val) #print " block_size is: " + str(block_size) #print "\n Starting Step 3 \n"
## Step 3: Clear out the remaining entries ## ---------------------------------------
##DIAGNOSTIC #print "Starting Step 3:" #print "----------------" #print " min_scale is: " + str(min_scale)
## Perform cancellation over Z by ensuring divisibility
## DIAGNSOTIC #print "Cancelling from a 1x1 block:" #print "----------------------------" #print " Cancelling entry with index (" + str(upper_left) + ", " + str(j) + ")" #print " entry = " + str(b) #print " gcd = " + str(g) #print " a = " + str(a) #print " b = " + str(b) #print " a/g = " + str(a/g) + " (used for stretching)" #print " -b/g = " + str(-b/g) + " (used for cancelling)"
## Sanity Check: a/g is a p-unit raise RuntimeError("Oops! We have a problem with our rescaling not preserving p-integrality!")
## Cancels out the rows/columns of the 2x2 block
## Ensures an integral result (scale jth row/column by big_det)
## Performs the cancellation (by producing -big_det * jth row/column)
## Now remove the extra factor (non p-unit factor) in big_det we introduced above
## DIAGNOSTIC #print "Cancelling out a 2x2 block:" #print "---------------------------" #print " a1 = " + str(a1) #print " a2 = " + str(a2) #print " b1 = " + str(b1) #print " b2 = " + str(b2) #print " big_det = " + str(big_det) #print " min_scale = " + str(min_scale) #print " small_det = " + str(small_det) #print " Q = \n", Q
## Uses Cassels's proof to replace the remaining 2 x 2 block else: raise RuntimeError("Error in LocalNormal: Impossible behavior for a 2x2 block! \n")
## Check that the cancellation worked, extract the upper-left block, and trim Q to handle the next block. raise RuntimeError("Oops! The cancellation didn't work properly at entry (" + str(i) + ", " + str(j) + ").")
def jordan_blocks_by_scale_and_unimodular(self, p, safe_flag=True): """ Return a list of pairs `(s_i, L_i)` where `L_i` is a maximal `p^{s_i}`-unimodular Jordan component which is further decomposed into block diagonals of block size `\le 2`.
For each `L_i` the 2x2 blocks are listed after the 1x1 blocks (which follows from the convention of the :meth:`local_normal_form` method).
.. NOTE::
The decomposition of each `L_i` into smaller blocks is not unique!
The ``safe_flag`` argument allows us to select whether we want a copy of the output, or the original output. By default ``safe_flag = True``, so we return a copy of the cached information. If this is set to ``False``, then the routine is much faster but the return values are vulnerable to being corrupted by the user.
INPUT:
- `p` -- a prime number > 0.
OUTPUT:
A list of pairs `(s_i, L_i)` where:
- `s_i` is an integer, - `L_i` is a block-diagonal unimodular quadratic form over `\ZZ_p`.
.. note::
These forms `L_i` are defined over the `p`-adic integers, but by a matrix over `\ZZ` (or `\QQ`?).
EXAMPLES::
sage: Q = DiagonalQuadraticForm(ZZ, [1,9,5,7]) sage: Q.jordan_blocks_by_scale_and_unimodular(3) [(0, Quadratic form in 3 variables over Integer Ring with coefficients: [ 1 0 0 ] [ * 5 0 ] [ * * 7 ]), (2, Quadratic form in 1 variables over Integer Ring with coefficients: [ 1 ])]
::
sage: Q2 = QuadraticForm(ZZ, 2, [1,1,1]) sage: Q2.jordan_blocks_by_scale_and_unimodular(2) [(-1, Quadratic form in 2 variables over Integer Ring with coefficients: [ 2 2 ] [ * 2 ])] sage: Q = Q2 + Q2.scale_by_factor(2) sage: Q.jordan_blocks_by_scale_and_unimodular(2) [(-1, Quadratic form in 2 variables over Integer Ring with coefficients: [ 2 2 ] [ * 2 ]), (0, Quadratic form in 2 variables over Integer Ring with coefficients: [ 2 2 ] [ * 2 ])] """ ## Try to use the cached result else: ## Initialize the global dictionary if it doesn't exist
## Deal with zero dim'l forms return []
## Find the Local Normal form of Q at p
## Parse this into Jordan Blocks else:
## Determine the size of the current block else:
## Determine the valuation of the current block else:
## Process the previous block if the valuation increased
## Increment the index
## Add the last block
## Cache the result
## Return the result
def jordan_blocks_in_unimodular_list_by_scale_power(self, p): """ Returns a list of Jordan components, whose component at index i should be scaled by the factor p^i.
This is only defined for integer-valued quadratic forms (i.e. forms with base_ring ZZ), and the indexing only works correctly for p=2 when the form has an integer Gram matrix.
INPUT:
self -- a quadratic form over ZZ, which has integer Gram matrix if p == 2 `p` -- a prime number > 0
OUTPUT:
a list of p-unimodular quadratic forms
EXAMPLES::
sage: Q = QuadraticForm(ZZ, 3, [2, -2, 0, 3, -5, 4]) sage: Q.jordan_blocks_in_unimodular_list_by_scale_power(2) Traceback (most recent call last): ... TypeError: Oops! The given quadratic form has a Jordan component with a negative scale exponent! This routine requires an integer-matrix quadratic form for the output indexing to work properly!
sage: Q.scale_by_factor(2).jordan_blocks_in_unimodular_list_by_scale_power(2) [Quadratic form in 2 variables over Integer Ring with coefficients: [ 0 2 ] [ * 0 ], Quadratic form in 0 variables over Integer Ring with coefficients: , Quadratic form in 1 variables over Integer Ring with coefficients: [ 345 ]]
sage: Q.jordan_blocks_in_unimodular_list_by_scale_power(3) [Quadratic form in 2 variables over Integer Ring with coefficients: [ 2 0 ] [ * 10 ], Quadratic form in 1 variables over Integer Ring with coefficients: [ 2 ]] """ ## Sanity Check raise TypeError("Oops! This method only makes sense for integer-valued quadratic forms (i.e. defined over ZZ).")
## Deal with zero dim'l forms return []
## Find the Jordan Decomposition + "This routine requires an integer-matrix quadratic form for the output indexing to work properly!")
## Make the new list of unimodular Jordan components
## Return the new list |