24 #ifndef FFPOPSIM_LOWD_H_
25 #define FFPOPSIM_LOWD_H_
28 #define HC_MEMERR -131545 //memory error code
29 #define HC_BADARG -131546 //bad argument error code
30 #define HC_VERBOSE 0 //debugging: if set to one, each function prints out a message into the error stream
31 #define HC_FUNC 1 //hypercube_lowd.func is up-to-date
32 #define HC_COEFF -1 //hypercube_lowd.coeff is up-to-date
33 #define HC_FUNC_EQ_COEFF 0 //hypercube_lowd.func equal hypercube_lowd.coeff
67 int set_up(
int dim_in,
int s=0);
70 int gaussian_coefficients(
double* vark,
bool add=
false);
71 int additive(
double* additive_effects,
bool add=
false);
72 int init_rand_gauss(
double sigma,
bool add=
false);
73 int init_list(vector<index_value_pair_t> iv,
bool add=
false);
74 int init_coeff_list(vector <index_value_pair_t> iv,
bool add=
false);
79 int read_coeff(istream &in);
80 int write_func(ostream &out);
81 int write_coeff(ostream &in,
bool label=
false);
82 int read_func(istream &out);
83 int read_func_labeled(istream &in);
86 int signature(
int point);
89 int fft_func_to_coeff();
90 int fft_coeff_to_func();
96 double get_func(
int point) {
if (state==
HC_COEFF) {fft_coeff_to_func();}
return func[point]; }
97 double get_coeff(
int point) {
if (state==
HC_FUNC) {fft_func_to_coeff();}
return coeff[point]; }
102 void func_set(
int point,
double f) {func[point]=f; }
104 int normalize(
double targetnorm=1.0);
106 int scale(
double scale);
107 int shift(
double shift);
124 #define HG_LONGTIMEGEN 1000000
125 #define HG_CONTINUOUS 10000
126 #define HG_NOTHING 1e-15
127 #define HG_EXTINCT -9287465
128 #define HG_BADARG -879564
129 #define HG_MEMERR -32656845
157 int L(){
return number_of_loci;}
159 double N(){
return population_size;}
165 double get_recombination_rate(
int locus);
168 int set_allele_frequencies(
double* frequencies,
unsigned long N);
169 int set_genotypes(vector <index_value_pair_t> gt);
170 int set_wildtype(
unsigned long N);
173 int set_recombination_model(
int rec_model);
174 int set_recombination_rates(
double *rec_rates,
int rec_model=-1);
175 int set_mutation_rates(
double m);
176 int set_mutation_rates(
double m1,
double m2);
177 int set_mutation_rates(
double* m);
178 int set_mutation_rates(
double** m);
181 int evolve(
int gen=1);
182 int evolve_norec(
int gen=1);
183 int evolve_deterministic(
int gen=1);
195 double get_pair_frequency(
int locus1,
int locus2){
return 0.25 * (get_moment(locus1, locus2) - 1) + 0.5 * (get_allele_frequency(locus1) + get_allele_frequency(locus2));}
197 double get_chi(
int locus){
return (1<<number_of_loci)*population.get_coeff(1<<locus);}
198 double get_chi2(
int locus1,
int locus2){
return get_moment(locus1, locus2)-get_chi(locus1)*get_chi(locus2);}
199 double get_LD(
int locus1,
int locus2){
return 0.25 * get_chi2(locus1, locus2);}
200 double get_moment(
int locus1,
int locus2){
return (1<<number_of_loci)*population.get_coeff((1<<locus1)+(1<<locus2));}
203 double genotype_entropy();
204 double allele_entropy();
207 double get_fitness(
int genotype) {
return fitness.get_func(genotype);}
208 stat_t get_fitness_statistics();
214 int get_random_seed();
237 int set_recombination_rates_general(
double *rec_rates);
238 int set_recombination_patterns(vector<index_value_pair_t> iv);
239 int marginalize_recombination_patterns();
240 int set_recombination_rates_single_crossover(
double *rec_rates);
241 int calculate_recombinants_free();
242 int calculate_recombinants_single();
243 int calculate_recombinants_general();
250 int allocate_recombination_mem(
int rec_model);
251 int free_recombination_mem();
254 static size_t number_of_instances;