source: branches/stable/SL/MATRIX/AP_matrix.hxx

Last change on this file was 18634, checked in by westram, 3 years ago
  • 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_STRING_H
18#include <arb_string.h>
19#endif
20#ifndef MATRIX_H
21#include <matrix.h>
22#endif
23
24#define ap_assert(cond) arb_assert(cond)
25
26CONSTEXPR_INLINE long matrix_halfsize(long entries, bool inclusive_diagonal) {
27    return inclusive_diagonal ? entries*(entries+1)/2L : (entries-1)*entries/2L;
28}
29
30typedef double AP_FLOAT;
31
32class AW_root;
33class AW_window;
34
35struct AP_smatrix : public symmetric_matrix<AP_FLOAT> {
36    AP_smatrix(size_t Size_) : symmetric_matrix<AP_FLOAT>(Size_) {}
37};
38
39class AP_matrix : virtual Noncopyable {
40    AP_FLOAT **m;
41    long       size;
42public:
43    AP_matrix(long si);
44    ~AP_matrix();
45
46    void     set(int i, int j, AP_FLOAT val) { m[i][j] = val; };
47    AP_FLOAT get(int i, int j) { return m[i][j]; };
48
49    long get_size() const { return size; }
50};
51
52class AP_userdef_matrix : public AP_matrix { // derived from Noncopyable
53    char **x_description;                                                         // optional description, strdupped
54    char **y_description;
55    char  *awar_prefix;
56
57    void set_desc(char**& which_desc, int idx, const char *desc);
58
59public:
60    AP_userdef_matrix(long si, const char *awar_prefix_)
61        : AP_matrix(si),
62          x_description(NULp),
63          y_description(NULp),
64          awar_prefix(ARB_strdup(awar_prefix_))
65    {}
66    ~AP_userdef_matrix();
67
68    void normize();                                                                     // set average non diag element to 1.0 (only for described elements)
69
70    void set_x_description(int idx, const char *desc) { set_desc(x_description, idx, desc); }
71    void set_y_description(int idx, const char *desc) { set_desc(y_description, idx, desc); }
72    void set_descriptions(int idx, const char *desc) { set_x_description(idx, desc); set_y_description(idx, desc); }
73
74    void create_awars(AW_root *awr);
75    void update_from_awars(AW_root *awr);
76    void create_input_fields(AW_window *aww);
77};
78
79#else
80#error AP_matrix.hxx included twice
81#endif // AP_MATRIX_HXX
Note: See TracBrowser for help on using the repository browser.