ARB
NJ.hxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : NJ.hxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #ifndef NJ_HXX
12 #define NJ_HXX
13 
14 #ifndef ARB_ASSERT_H
15 #include <arb_assert.h>
16 #endif
17 #ifndef ARBTOOLS_H
18 #include <arbtools.h>
19 #endif
20 #ifndef AP_MATRIX_HXX
21 #include <AP_matrix.hxx>
22 #endif
23 
24 #define ph_assert(cond) arb_assert(cond)
25 
26 typedef double AP_FLOAT;
27 
29  long i, j;
31 
33 
35 
36  void remove() {
37  ph_assert(previous); // already removed
38  if (next) { next->previous = previous; }
39  previous->next = next; previous = NULp;
40  };
41 
42  void add(PH_NEIGHBOUR_DIST *root) {
43  next = root->next;
44  root->next = this;
45  previous = root;
46  if (next) next->previous = this;
47  };
48 };
49 
51  PH_NEIGHBOUR_DIST **dist_matrix;
52  PH_NEIGHBOUR_DIST *dist_list; // array of dist_list lists
53  long dist_list_size;
54  AP_FLOAT dist_list_corr;
55  AP_FLOAT *net_divergence;
56 
57  long size;
58  long *swap_tab;
59  long swap_size;
60 
61  void remove_taxa_from_dist_list(long i);
62  void add_taxa_to_dist_list(long j);
63  AP_FLOAT get_max_net_divergence();
64  void remove_taxa_from_swap_tab(long i);
65 
66 public:
67 
68  PH_NEIGHBOURJOINING(const AP_smatrix& smatrix);
70 
71  void join_nodes(long i, long j, AP_FLOAT &leftl, AP_FLOAT& rightlen);
72  AP_FLOAT get_min_ij(long& i, long& j);
73  void get_last_ij(long& i, long& j);
74  AP_FLOAT get_dist(long i, long j);
75 
76 #if defined(UNIT_TESTS) // UT_DIFF
77  // test inspection
78  AP_FLOAT get_net_divergence(long i) { return net_divergence[i]; }
79 #endif
80 };
81 
82 #else
83 #error NJ.hxx included twice
84 #endif // NJ_HXX
PH_NEIGHBOURJOINING(const AP_smatrix &smatrix)
Definition: NJ.cxx:91
AP_FLOAT get_min_ij(long &i, long &j)
Definition: NJ.cxx:129
double AP_FLOAT
Definition: AP_matrix.hxx:30
~PH_NEIGHBOURJOINING()
Definition: NJ.cxx:121
AP_FLOAT val
Definition: NJ.hxx:30
PH_NEIGHBOUR_DIST()
Definition: NJ.cxx:17
PH_NEIGHBOUR_DIST * next
Definition: NJ.hxx:32
void get_last_ij(long &i, long &j)
Definition: NJ.cxx:195
AP_FLOAT get_dist(long i, long j)
Definition: NJ.cxx:200
void join_nodes(long i, long j, AP_FLOAT &leftl, AP_FLOAT &rightlen)
Definition: NJ.cxx:161
PH_NEIGHBOUR_DIST * previous
Definition: NJ.hxx:32
void add(PH_NEIGHBOUR_DIST *root)
Definition: NJ.hxx:42
#define NULp
Definition: cxxforward.h:116
#define ph_assert(cond)
Definition: NJ.hxx:24
double AP_FLOAT
Definition: NJ.hxx:26