FFPopSim  2.0
Library for Population Genetics
 All Classes Files Functions Variables Macros Pages
ffpopsim_generic.h
Go to the documentation of this file.
1 
25 #ifndef FFPOPGEN_GENERIC_H_
26 #define FFPOPGEN_GENERIC_H_
27 
28 #include <time.h>
29 #include <cmath>
30 #include <vector>
31 #include <bitset>
32 #include <string>
33 #include <sstream>
34 #include <iostream>
35 #include <fstream>
36 #include <iomanip>
37 #include <gsl/gsl_sf.h>
38 #include <gsl/gsl_randist.h>
39 #include <gsl/gsl_rng.h>
40 #include <gsl/gsl_histogram.h>
41 #include <gsl/gsl_histogram2d.h>
42 #include <gsl/gsl_matrix.h>
43 #include <gsl/gsl_vector.h>
44 #include <gsl/gsl_eigen.h>
45 #include <boost/dynamic_bitset.hpp>
46 
47 #define MIN(a,b) (a<b)?a:b
48 #define MAX(a,b) (a>b)?a:b
49 #define RNG gsl_rng_taus2 //choose the random number generator algorithm, see http://www.gnu.org/software/gsl/manual/html_node/Random-number-generator-algorithms.html
50 
51 #define FREE_RECOMBINATION 1
52 #define CROSSOVERS 2
53 #define SINGLE_CROSSOVER 3
54 
55 using namespace std;
56 
61  size_t index;
62  double val;
63  index_value_pair_t(int index_in=0, double val_in=0) : index(index_in), val(val_in) {};
64 };
65 
70  boost::dynamic_bitset<> genotype;
71  double val;
72  genotype_value_pair_t(boost::dynamic_bitset<> genotype_in=boost::dynamic_bitset<>(0), double val_in=0) : genotype(genotype_in), val(val_in) {};
73 };
74 
78 struct stat_t {
79  double mean;
80  double variance;
81  stat_t(double mean_in=0, double variance_in=0) : mean(mean_in), variance(variance_in) {};
82 };
83 
84 #define SAMPLE_ERROR -12312154
85 
92 class sample {
93 public:
95  double *values;
96  double mean;
97  double variance;
98 
99  int bins;
100  bool mem_dis;
102  gsl_histogram *distribution;
103 
105  double range_min;
106  double range_max;
107 
108  sample();
109  virtual ~sample();
110  int set_up(int n);
111  int set_distribution(int bins=100);
112  void set_range(double min, double max) {range_min=min; range_max=max; with_range=true;}
113  int calc_mean();
114  int calc_variance();
115  int calc_distribution();
116  int print_distribution(ostream &out);
117 };
118 
119 #endif /* FFPOPGEN_GENERIC_H_ */