source: tags/arb_5.0/DIST/di_mldist.hxx

Last change on this file was 5392, checked in by westram, 16 years ago
  • changed prefix 'ph' to 'di' ('ph' is used in ../PHYLO, and many identifiers are duplicated)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1const int DI_ML_RESOLUTION   = 1000; // max res
2const int DI_ML_MAX_DIST     = 10; // max dist
3const int DI_ML_MAX_MAT_SIZE = 16;
4
5
6typedef double di_ml_matrix[DI_ML_MAX_MAT_SIZE][DI_ML_MAX_MAT_SIZE];
7typedef double di_pml_matrix[DI_ML_MAX_MAT_SIZE][DI_ML_MAX_MAT_SIZE];
8typedef char   di_bool_matrix[DI_ML_MAX_MAT_SIZE][DI_ML_MAX_MAT_SIZE];
9
10class di_mldist {
11    long spp;                   // number of species
12    long chars;                 // number of characters
13    long n_states;              // << DI_ML_MAX_MAT_SIZE
14
15    /*
16     * spp = number of species chars = number of sites in actual sequences
17     */
18
19    double    fracchange;
20    DI_ENTRY **entries;          // link to entries
21    double    pi[20];
22
23    double       eig[DI_ML_MAX_MAT_SIZE];
24    double       exptteig[DI_ML_MAX_MAT_SIZE];
25    di_ml_matrix prob, eigvecs;
26
27    di_pml_matrix   *(slopes[DI_ML_RESOLUTION*DI_ML_MAX_DIST]);
28    // huge cash for many slopes
29    di_pml_matrix   *(curves[DI_ML_RESOLUTION*DI_ML_MAX_DIST]);
30    di_bool_matrix  *(infs[DI_ML_RESOLUTION*DI_ML_MAX_DIST]);
31
32    di_pml_matrix  *akt_slopes;
33    di_pml_matrix  *akt_curves;
34    di_bool_matrix *akt_infs;
35    double          weight[2];  // weight akt slope 1 -> linear interpolation
36    AP_smatrix     *matrix;     // link to output matrix
37
38    /* Local variables for makedists, propagated globally for c version: */
39    double p, dp, d2p;
40
41
42    void givens(di_ml_matrix a,long i,long j,long n,double ctheta,double stheta,GB_BOOL left);
43    void coeffs(double x,double y,double *c,double *s,double accuracy);
44    void tridiag(di_ml_matrix a,long n,double accuracy);
45    void shiftqr(di_ml_matrix a, long n, double accuracy);
46    void qreigen(di_ml_matrix prob,long n);
47
48    void predict(double tt,long nb1,long  nb2);
49    int tt_2_pos(double tt);        // double to cash index
50    double pos_2_tt(int pos);       // cash index to pos
51    void build_exptteig(double tt);
52    void build_predikt_table(int pos);      // build akt_slopes akt_curves
53    void build_akt_predikt(double tt);      // build akt_slopes akt_curves
54
55    double predict_slope(int b1,int b2) { return akt_slopes[0][b1][b2]; }
56    double predict_curve(int b1,int b2) { return akt_curves[0][b1][b2]; }
57    char predict_infinity(int b1,int b2) { return akt_infs[0][b1][b2]; }
58    void clean_slopes();
59
60public:
61    di_mldist(long nentries, DI_ENTRY **entries, long seq_len, AP_smatrix *matrixi);
62    ~di_mldist();
63   
64    const char *makedists();    // calculate the distance matrix
65};
Note: See TracBrowser for help on using the repository browser.