Skip to content

Commit

Permalink
updated parsing to match new output of non-lift computation
Browse files Browse the repository at this point in the history
  • Loading branch information
assaferan committed Jun 20, 2023
1 parent 658b020 commit 40c7a8a
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 9 deletions.
138 changes: 138 additions & 0 deletions include/genus.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,158 @@ typedef struct

typedef genus_struct genus_t[1];

/**********************************************************************
*
* Function: genus_init_square_matrix
*
* Description: Initializes a genus from the gram matrix of a lattice.
* It uses Kneser's neighbors method to produce other
* lattices in the genus, and the mass formula for
* completeness.
*
* Arguments:
* + Q (const square_matrix_t) - the gram matrix of the lattice
* + h (int) - the number of genus representatives
* If h is unknown in advance, set h = -1
*
* Returns:
* + genus (genus_t) - the resulting genus structure
*
**********************************************************************
*/


/* compute the genus of a quadratic form */
void genus_init_square_matrix(genus_t genus, const square_matrix_t Q, int h);

/**************************************************************************
*
* Function: genus_init_square_matrix_vec
*
* Description: Initializes a genus from a list of
* gram matrices of genus representatives.
*
* Arguments:
* + reps (const square_matrix_t*) - the gram matrices of the lattices
* + genus_size (size_t) - the number of genus representatives
*
* Returns:
* + genus (genus_t) - the resulting genus structure
*
**************************************************************************
*/

/* set the genus from a list */
void genus_init_set_square_matrix_vec(genus_t genus, const square_matrix_t* reps, size_t genus_size);


/**************************************************************************
*
* Function: genus_init_square_matrix_vec_and_isoms
*
* Description: Initializes a genus from a list of
* gram matrices of genus representatives,
* together with specified isometries (over Q) between them.
* Useful for consistency checks.
*
* Arguments:
* + reps (const square_matrix_t*) - the gram matrices of the lattices
* + isoms (const isometry_t*) - the isometries between the lattices
* + genus_size (size_t) - the number of genus representatives
*
* Returns:
* + genus (genus_t) - the resulting genus structure
*
**************************************************************************
*/

void genus_init_set_square_matrix_vec_and_isoms(genus_t genus, const square_matrix_t* reps,
const isometry_t* isoms, size_t genus_size);

/**************************************************************************
*
* Function: genus_init_empty
*
* Description: Initializes an empty genus from the discriminant.
* Suffices for figuring out the possible conductors
* and spinor norm data, without computing the genus
* representatives.
*
* Arguments:
* + disc (size_t) - the discriminant of the lattice
*
* Returns:
* + genus (genus_t) - the resulting genus structure
*
**************************************************************************
*/

void genus_init_empty(genus_t genus, size_t disc);

/********************************************************************************
*
* Function: genus_init_file
*
* Description: Initializes a genus from a file.
*
* Arguments:
* + genus_fname (const char*) - the name of the file containing the genus.
* If has_isoms is true, the file is assumed
* to be a list of pairs of lists of matrices,
* the first corresponding to gram matrices
* of the genus representatives, and the second
* to the isometries, indexed by the level.
* If has_isoms is false, the file is assumed
* to consist of a list of lists of numbers,
* each list corresponding to a symmetric matrix
* by listing its lower triangular part,
* so that each list describes the genus
* representatives.
* The list is again indexed by level.
* + disc (size_t) - the discriminant of the lattice
* + has_isoms (bool) - whether the genus file contains the isometries
*
* Returns:
* + genus (genus_t) - the resulting genus structure
*
******************************************************************************
*/

void genus_init_file(genus_t genus, const char* genus_fname, size_t disc, bool has_isoms);

/**************************************************************************
*
* Function: genus_clear
*
* Description: Clears memory allocated to initialize genus.
*
* Arguments:
* + genus (genus_t) - the genus structure
*
**************************************************************************
*/

void genus_clear(genus_t genus);

/**************************************************************************
*
* Function: genus_is_trivial_cond
*
* Description: Checks whether the spaces of orthogonal modular forms
* for this genus with non-trivial spinor norm are all
* zero-dimensional. In such a case, we do not have to
* record the isometries.
*
* Arguments:
* + genus (genus_t) - the genus structure
*
* Returns:
* + (bool) - True if spaces for all non-trivial conductors
* are zero-dimensional.
*
**************************************************************************
*/

bool genus_is_trivial_cond(const genus_t genus);

#endif // __GENUS_H__
7 changes: 5 additions & 2 deletions scripts/parse_omf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ def to_list(elt):
return list(elt)
return [ list(sum([to_list(elt)[i]*inv_basis[i] for i in range(d)])) if type(elt) != str else elt for elt in elts]

def parse_omf5(k,j,N,folder,suffix="_nl_200_",hecke_ring=True,B=200,max_deg=13):
def parse_omf5(k,j,N,folder,suffix="_nl_200_",hecke_ring=True,B=200,max_deg=13,skip_lines=0):
fname = folder + "hecke_ev_%d_%d%s%d.dat" %(k,j,suffix,N)
Qx = PolynomialRing(QQ, name="x")
x = Qx.gens()[0]

fl = open(fname)
al_signs = eval(fl.read())
r = fl.readlines()
fl.close()
if (len(r) <= skip_lines):
return []
al_signs = eval(r[skip_lines])
ret = []
bad_ps = [p for p in prime_range(B) if N % p == 0]
ps = prime_range(B)
Expand Down
55 changes: 48 additions & 7 deletions src/genus.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
/**********************************************************
*
* Package : omf5 - orthogonal modular forms of rank 5
* Filename : genus.c
*
* Description: Genus of a lattice.
* Used also to record relevant data about
* the space of orthogonal modular forms
* supported on this genus with different
* conductors.
*
**********************************************************
*/

// System dependencies

#include <assert.h>

// Required packages dependencies

#include <carat/matrix.h>

#include <flint/fmpq.h>
#include <flint/fmpz.h>

// Self dependencies

#include "aut_grp.h"
#include "genus.h"
#include "hash.h"
Expand All @@ -16,6 +37,8 @@
#include "square_matrix.h"
#include "typedefs.h"

// a look up table of bit counts for numbers up to 8 bits, for quick popcount

int bitcounts[256] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2,
3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3,
Expand All @@ -30,6 +53,7 @@ int bitcounts[256] = {
6, 7, 6, 7, 7, 8
};

/* computes the popcount of a 64-bit word (number of lit bits) */
int popcnt(W64 x)
{
if (x <= 0xff) return bitcounts[x];
Expand All @@ -43,6 +67,7 @@ int popcnt(W64 x)
return count;
}

/* compute the discriminant of a lattice from its gram matrix */
void disc_init_set(fmpz_t disc, const square_matrix_t q)
{
fmpz_mat_t q_fmpz;
Expand All @@ -57,6 +82,8 @@ void disc_init_set(fmpz_t disc, const square_matrix_t q)
return;
}

/* Estimate the number of genus representatives based on its mass.
This is only a rough estimate, in order to allocate memory initially */
size_t genus_size_estimate(const fmpq_t mass)
{
fmpz_t genus_size_fmpz;
Expand All @@ -71,6 +98,8 @@ size_t genus_size_estimate(const fmpq_t mass)
return genus_size;
}

/* Initialize the possible conductors for the spinor norm (all square-free divisors of the discriminant).
Allocates memory and initializes values for the relevant parts of the genus structure */
void conductors_init(genus_t genus)
{
slong c, value;
Expand Down Expand Up @@ -142,7 +171,9 @@ slong ignore_set(bool* ignore, const genus_t genus, slong genus_idx)

return order;
}


/* Compute the dimensions of each space of orthogonal modular forms based on this genus.
Also initializes the look up tables lut_positions and the number of automorphisms num_auts accordingly. */
void dimensions_init(genus_t genus)
{
slong c, genus_idx, order;
Expand Down Expand Up @@ -391,15 +422,15 @@ void genus_init_square_matrix(genus_t genus, const square_matrix_t q, int h)
#endif // NBR_DATA
current++;
}

}

hash_table_recalibrate(genus->genus_reps, slow_genus);

hash_table_clear(slow_genus);

assert(genus->genus_reps->num_stored > 0);

dimensions_init(genus);

fmpq_clear(mass);
Expand All @@ -411,10 +442,11 @@ void genus_init_square_matrix(genus_t genus, const square_matrix_t q, int h)
fmpz_mat_clear(nbr_fmpz);
fmpz_mat_clear(nbr_isom);
#endif // NBR_DATA

return;
}

/* clear the memory allocated for the genus */
void genus_clear(genus_t genus)
{
slong c;
Expand Down Expand Up @@ -444,6 +476,8 @@ void genus_clear(genus_t genus)
return;
}

/* Check whether two lattices, given by their gram matrices, are isometric over Q.
If so, construct an isometry between them. */
// !! TODO - right now we are doing it very naively, by constructing neighbors
// We should replace it by proper Gram-Schmidt
bool square_matrix_is_Q_isometric(isometry_t isom, const square_matrix_t A, const square_matrix_t B)
Expand Down Expand Up @@ -502,7 +536,9 @@ bool square_matrix_is_Q_isometric(isometry_t isom, const square_matrix_t A, cons

return found;
}


/* Find isometries from the lattice whose gram matrix is A to each of the h lattices whose gram matrices are the
elements of the list B. Return the isometries in isoms, for which memory is assumed to be allocated. */
// for now, this is faster (do one round and collect all)
// assumes isoms are initialized and that B and isoms are the length of the class number
void square_matrix_find_isometries(isometry_t* isoms, const square_matrix_t A, const square_matrix_t* B, int h)
Expand Down Expand Up @@ -538,6 +574,7 @@ void square_matrix_find_isometries(isometry_t* isoms, const square_matrix_t A, c
return;
}

/* Initialize a genus from a list of gram matrices for the genus representatives */
void genus_init_set_square_matrix_vec(genus_t genus, const square_matrix_t* reps, size_t h)
{
#ifdef DEBUG
Expand Down Expand Up @@ -617,6 +654,8 @@ void genus_init_set_square_matrix_vec(genus_t genus, const square_matrix_t* reps
return;
}

/* Initialize a genus from a list of gram matrices for the genus representatives, and a list of specific isometries
from the firt representative to all the others. */
void genus_init_set_square_matrix_vec_and_isoms(genus_t genus, const square_matrix_t* reps,
const isometry_t* isoms, size_t h)
{
Expand Down Expand Up @@ -661,7 +700,7 @@ void genus_init_set_square_matrix_vec_and_isoms(genus_t genus, const square_matr
return;
}


/* Initialize the genus from a file */
void genus_init_file(genus_t genus, const char* genus_fname, size_t disc, bool with_isom)
{
square_matrix_t* genus_reps = NULL;
Expand All @@ -685,6 +724,7 @@ void genus_init_file(genus_t genus, const char* genus_fname, size_t disc, bool w
return;
}

/* Initialize an empty genus, only from the discriminant */
void genus_init_empty(genus_t genus, size_t disc)
{
fmpz_init_set_ui(genus->disc,disc);
Expand All @@ -700,6 +740,7 @@ void genus_init_empty(genus_t genus, size_t disc)
return;
}

/* check whether the genus is trivial */
bool genus_is_trivial_cond(const genus_t genus)
{
bool only_trivial;
Expand Down

0 comments on commit 40c7a8a

Please sign in to comment.