Debian Codegraph @

src/Ewens.h

raw
1 #ifndef FREEBAYES_EWENS_H
2 #define FREEBAYES_EWENS_H
3
4 #include <map>
5 #include <cmath>
6 #include "Utility.h"
7
8 using namespace std;
9
10 // genotype priors
11
12 long double alleleFrequencyProbability(const map<int, int>& alleleFrequencyCounts, long double theta);
13 long double alleleFrequencyProbabilityln(const map<int, int>& alleleFrequencyCounts, long double theta);
14 long double impl_alleleFrequencyProbabilityln(const map<int, int>& alleleFrequencyCounts, long double theta);
15
16 class AlleleFrequencyProbabilityCache : public map<map<int, int>, long double> {
17 public:
18 long double alleleFrequencyProbabilityln(const map<int, int>& counts, long double theta) {
19 map<map<int, int>, long double>::iterator p = find(counts);
20 if (p == end()) {
21 long double pln = impl_alleleFrequencyProbabilityln(counts, theta);
22 insert(make_pair(counts, pln));
23 return pln;
24 } else {
25 return p->second;
26 }
27 }
28 };
29
30 #endif