#ifndef BASIS_INCLUDED #define BASIS_INCLUDED #include "group.h" /* function prototypes and definitions associated with basis construction. This includes definitions of the storage format for states. */ typedef unsigned short partype; /* Data type to hold one particle in a state. */ /* The lowest bits of the partype store momentum and the higher bits store the direction, spin, and flavor indices. HSHIFT specifies the number of bits reserved for momentum. For 3+1, HSHIFT must leave at least two bits for the "helicity" index. */ #define HSHIFT 10 /* 6 is maximum possible for partype=char*/ #define HOLE ((partype) -1) /* No more particles in state */ /* structure for returning a basis of states including a pointer and the number of states. Optionally, chunk contains the memory allocated in units of partype. */ #include typedef struct {partype *e; size_t length; } kbase; typedef struct {partype *s; size_t length;} cbase; /* Structures to store a basis of states. reduced_basis is a basis of states reduced by the symmetries specified */ enum state_type { /* typedef does not work for enum */ TYPE_GLUE, /* glueball */ TYPE_MESON, /* meson, ht[0]=999 */ TYPE_SOURCE, /* heavy source, kt is a maximum value. */ TYPE_HEAVY_LIGHT /* open string with heavy source on one end and light quark on the other, kt is a maximum value. */ }; char *state_type_string(enum state_type t); /* string containing state type */ typedef struct { size_t length; /* number of states in basis */ enum state_type type; int ht[HINDEX]; /* total winding number */ unsigned int kt; /* The total discretized momentum, rounded down. */ int charge; /* charge conjugation */ int o; /* orientation reversal: having definite charge conjugation and orientation reversal is redundant */ int subgroup; /* subgroup of lattice symmetries */ int nptrunc; /* number of particles in truncation */ partype *s; /* nptrunc*length array containing all the states */ } reduced_basis; /* full_basis is a basis of states for a given multiplet with the number of particles included for each state. It is initialized with length=0. */ typedef struct { size_t length; /* number of states in basis */ enum state_type type; int ht[HINDEX]; /* total winding number */ unsigned int kt; /* The total discretized momentum, rounded down. */ int charge; /* charge conjugation */ int o; /* orientation reversal: having definite charge conjugation and orientation reversal is redundant */ int multi; /* multiplet of lattice symmetries */ int nptrunc; /* number of particles in truncation */ partype *s; /* nptrunc*length array containing all the states */ unsigned char *np; /* number of particles in each state in basis */ unsigned char *inner; /* norm squared of state */ #if 0 /*this may not be necessary */ element *innerno; /* 1/sqrt(norm) of state */ #endif } full_basis; /* structure to hold basis of states that are stored as a binary tree. */ typedef struct { partype s[NPMAX]; size_t lower; size_t upper; } tree_basis; /* ------ Function prototypes for basis.c --------------------- */ int makereduced(reduced_basis **x, enum state_type type, int ht[HINDEX], int nptrunc, unsigned int kt, int charge, int o, int subgroup); int link_k(unsigned int kt); /* allowed values of link momentum */ int zeromodetest(partype *s, enum state_type type, int nptrunc); void initbasis(full_basis *x, enum state_type type, int ht[HINDEX], int nptrunc, unsigned int kt, int charge, int o, int multi); /*make a basis of states with the full_basis format. */ void makebasis(full_basis *x); void free_basis(full_basis *x); /* clear memory in basis */ int innerproduct(partype *left, partype *right, enum state_type type, int np, int charge, int o, int multi); void wellorder(partype *state, enum state_type type, int np, int charge, int o,int subgroup); /* Give state a canoncial order */ /*Make a basis with helicity and/or momentum*/ void free_reduced(void); /* delete all but the first i bases */ size_mem reduced_basis_memory; /* bytes of memory used by makereduced for basis states, value may be passed in the mpi case, hence the type size_mem. */ /* find the rest of the states in the basis after the given state */ int iswinding(int *ht); /* Flag to say if ht is nonzero winding */ partype glueencode(partype, int *); partype quarkdecode(partype p, int *spin); partype quarkencode(int spin, unsigned int k2); partype gluelat(partype z, latype p); partype quarklat(partype z, int *phase, latype p); partype antiquarklat(partype z, int *phase, latype p); int statelat(partype *out, partype *in, enum state_type type, int np, latype p); /* lattice group element acting on a whole state */ int orientation(partype *out, partype *in, enum state_type type, int np); int charge_conjugation(partype *out, partype *in, enum state_type type, int np); void printstate(partype *state, enum state_type type, int np); void phasemultiply(complex_element *z,int phase); /* multiply complex number by i^(phase/2) */ /* ------ Function prototypes for basis_add.c --------------------- */ void addterms(element *, int *,int,element *,int);/*add terms to sorted list */ size_t addstate(partype *, partype *, size_t, int np); /* Add a state to a basis */ size_t findnext(partype *, partype *,size_t, int np); int order_states(partype *s1, partype *s2, int np); tree_basis *tree_realloc(tree_basis *tree, size_t length, int np); size_t tree_addstate(tree_basis *tree, partype *state, size_t length, int np); partype *tree_sort(tree_basis *tree, size_t length, int np); /* -------------------- Macro Definitions --------------------------------*/ #define KMASK ((1< 1<>(HSHIFT+1)]= \ X&(1<>(HSHIFT+1)] = X&(1<