]> git.donarmstrong.com Git - rsem.git/blob - Orientation.h
RSEM Source Codes
[rsem.git] / Orientation.h
1 #ifndef ORIENTATION_H_
2 #define ORIENTATION_H_
3
4 #include<cstdio>
5 #include<cstring>
6
7 #include "simul.h"
8
9 class Orientation {
10 public:
11         Orientation(double probF = 0.5) {
12                 prob[0] = probF;
13                 prob[1] = 1.0 - probF;
14         }
15
16         Orientation& operator= (const Orientation& rv) {
17                 if (this == &rv) return *this;
18                 memcpy(prob, rv.prob, sizeof(rv.prob));
19                 return *this;
20         }
21
22         //dir : 0 + 1 -
23         double getProb(int dir) { return prob[dir]; }
24
25         void read(FILE* fi) {
26                 fscanf(fi, "%lf", &prob[0]);
27                 prob[1] = 1.0 - prob[0];
28         }
29
30         void write(FILE* fo) {
31                 fprintf(fo, "%.10g\n", prob[0]);
32         }
33
34
35         int simulate(simul* sampler) { return (sampler->random() < prob[0] ? 0 : 1); }
36
37 private:
38         double prob[2]; //0 + 1 -
39 };
40
41 #endif /* ORIENTATION_H_ */