LocARNA-1.9.2
src/LocARNA/fitonoff.hh
00001 #ifndef LOCARNA_FIT_ON_OFF_HH
00002 #define LOCARNA_FIT_ON_OFF_HH
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include <config.h>
00006 #endif
00007 
00008 #include <string>
00009 #include <vector>
00010 
00011 #include <cmath>
00012 
00013 namespace LocARNA {
00014 
00015     typedef std::vector<double> numseq_t;
00016     typedef std::vector<double>::size_type size_type;
00017 
00018     typedef long double pf_t;
00019 
00024     class FitOnOff {
00025         double delta_01;
00026         double delta_10;
00027         numseq_t x;
00028 
00029         double beta;
00030 
00031         pf_t exp_delta_01; 
00032         pf_t exp_delta_10; 
00033 
00034         std::vector<std::vector<pf_t> > v; 
00035 
00036         std::vector<std::vector<bool> > t; 
00037 
00038         std::vector<bool> trace;
00039 
00040     public:
00048         FitOnOff(numseq_t &x_, double delta_01_, double delta_10_, double beta_)
00049             : delta_01(delta_01_), delta_10(delta_10_), x(x_), beta(beta_) {
00050             v.resize(2);
00051             v[0].resize(x.size() + 1);
00052             v[1].resize(x.size() + 1);
00053 
00054             t.resize(2);
00055             t[0].resize(x.size() + 1);
00056             t[1].resize(x.size() + 1);
00057             trace.resize(x.size() + 1);
00058 
00059             exp_delta_01 = exp(-beta * delta_01);
00060             exp_delta_10 = exp(-beta * delta_10);
00061         }
00062 
00070         double
00071         viterbi(double c0, double c1, bool traceback);
00072 
00080         double
00081         best_once_on(double c0, double c1);
00082 
00087         pf_t
00088         forward(double c0, double c1);
00089 
00094         std::pair<double, double>
00095         optimize(double c0, double c1);
00096 
00098         void
00099         write_viterbi_path_compact(std::ostream &out, double c0, double c1);
00100 
00102         void
00103         write_viterbi_path(std::ostream &out, double c0, double c1) const;
00104 
00105         // DEBUGGING
00106 
00113         void
00114         print_table(const std::string &name, const std::vector<bool> &v) const;
00115 
00122         void
00123         print_table(const std::string &name, const std::vector<pf_t> &v) const;
00124 
00129         void
00130         print_tables() const;
00131     };
00132 
00133 } // END namespace LocARNA
00134 
00135 #endif // LOCARNA_FIT_ON_OFF_HH
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends