source: tags/arb-6.0-rc1/SL/MATRIX/AP_matrix.hxx

Last change on this file was 11401, checked in by westram, 10 years ago
  • reintegrates 'tree' into 'trunk':
    • consensus trees:
      • support for merging partial trees ("worked" before, but results were crap; implements #65)
      • generated trees are automatically re-rooted and -ordered
      • always list source trees in consensus-tree-comment; show info about partial trees
      • fixed progress bar
    • made GBT_TREE a base class of other tree classes (implements #31)
    • save tree properties in properties (not in DB)
    • new functions 'Remove zombies/marked from ALL trees'
    • tree load/save: layout fixes
    • unit tests
      • added tests for basic tree modifications (PARSIMONY)
    • performance:
      • compute_tree updates tree information in one traversal
      • tree generators are now capable to generate any type of tree (w/o needing to copy it once)
    • bugfixes:
      • NNI (of marked species) was also always performed for colored species
      • centered beautify-order is stable now
      • improved 'search optimal root'
  • adds:
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : AP_matrix.hxx                                     //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef AP_MATRIX_HXX
12#define AP_MATRIX_HXX
13
14#ifndef ARBTOOLS_H
15#include <arbtools.h>
16#endif
17#ifndef ARB_ASSERT_H
18#include <arb_assert.h>
19#endif
20
21#define ap_assert(cond) arb_assert(cond)
22
23typedef double AP_FLOAT;
24
25class AW_root;
26class AW_window;
27
28class AP_smatrix : virtual Noncopyable {
29    // Symmetrical Matrix (upper triangular matrix)
30
31    size_t     Size;
32    AP_FLOAT **m;       // m[i][j]  i <= j !!!!
33
34public:
35
36    explicit AP_smatrix(size_t si);
37    ~AP_smatrix();
38
39    void     set(size_t i, size_t j, AP_FLOAT val) { if (i>j) m[i][j] = val; else m[j][i] = val; };
40
41    AP_FLOAT fast_get(size_t i, size_t j) const { ap_assert(i>=j); return m[i][j]; };
42    AP_FLOAT get(size_t i, size_t j) const { if (i>j) return m[i][j]; else return m[j][i]; };
43
44    AP_FLOAT get_max_value() const;
45
46    size_t size() const { return Size; }
47};
48
49class AP_matrix : virtual Noncopyable {
50    AP_FLOAT **m;
51    long       size;
52    char     **x_description;                                                     // optional description, strdupped
53    char     **y_description;
54
55    void set_desc(char**& which_desc, int idx, const char *desc);
56
57public:
58    AP_matrix(long si);
59    ~AP_matrix();
60
61    void create_awars(AW_root *awr, const char *awar_prefix);
62    void read_awars(AW_root *awr, const char *awar_prefix);
63    void normize();                                                                     // set average non diag element to 1.0 (only for described elements)
64    void create_input_fields(AW_window *aww, const char *awar_prefix);
65
66    void set_x_description(int idx, const char *desc) { set_desc(x_description, idx, desc); }
67    void set_y_description(int idx, const char *desc) { set_desc(y_description, idx, desc); }
68    void set_descriptions(int idx, const char *desc) { set_x_description(idx, desc); set_y_description(idx, desc); }
69
70    void     set(int i, int j, AP_FLOAT val) { m[i][j] = val; };
71    AP_FLOAT get(int i, int j) { return m[i][j]; };
72};
73
74#else
75#error AP_matrix.hxx included twice
76#endif // AP_MATRIX_HXX
Note: See TracBrowser for help on using the repository browser.