1 | // $Id: Merge.h 376 2005-08-07 22:32:48Z jari $ |
---|
2 | |
---|
3 | #ifndef _theplu_utility_merge_ |
---|
4 | #define _theplu_utility_merge_ |
---|
5 | |
---|
6 | #include <c++_tools/gslapi/matrix.h> |
---|
7 | |
---|
8 | #include <iostream> |
---|
9 | #include <string.h> |
---|
10 | #include <utility> |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | |
---|
14 | namespace theplu { |
---|
15 | namespace utility { |
---|
16 | |
---|
17 | /// |
---|
18 | /// A merger of datapoints on annotations. Calculates weighted |
---|
19 | /// average (m) of all (i) data points with same annotation: |
---|
20 | /// m=sum(w_i*x_i)sum(w_i) and uncertainty U of new data point: |
---|
21 | /// U=1/(sum(1/u_i))+sum(w_i^2*(x_i-m)^2)/(sum(w_i))^2 w_i is |
---|
22 | /// calculated from errors u_i Missing values have error < 0 |
---|
23 | /// |
---|
24 | |
---|
25 | class Merge |
---|
26 | { |
---|
27 | public: |
---|
28 | |
---|
29 | /// |
---|
30 | /// The default constructor. Not implemented. |
---|
31 | /// |
---|
32 | Merge(void); |
---|
33 | |
---|
34 | /// |
---|
35 | /// istream Constructor, arguments: data(matrix), weights(matrix), |
---|
36 | /// annotations(vector) |
---|
37 | /// |
---|
38 | Merge(std::istream& data, std::istream& error, std::istream& annotations); |
---|
39 | |
---|
40 | /// |
---|
41 | /// matrix Constructor, arguments: data(matrix), weights(matrix), |
---|
42 | /// annotations(vector) |
---|
43 | /// |
---|
44 | Merge(gslapi::matrix& data, gslapi::matrix& error, |
---|
45 | std::vector<std::string>& annotations); |
---|
46 | |
---|
47 | /// |
---|
48 | /// Calculate new weighted data and error values. |
---|
49 | /// |
---|
50 | void do_something(void); |
---|
51 | |
---|
52 | /// |
---|
53 | /// @return Const reference to the data matrix. |
---|
54 | /// |
---|
55 | inline const gslapi::matrix& data_matrix(void) const { return data_; } |
---|
56 | |
---|
57 | /// |
---|
58 | /// @return Const reference to the error matrix. |
---|
59 | /// |
---|
60 | inline const gslapi::matrix& error_matrix(void) const { return error_; } |
---|
61 | |
---|
62 | private: |
---|
63 | gslapi::matrix data_; |
---|
64 | gslapi::matrix error_; |
---|
65 | std::vector<std::string> annots_; |
---|
66 | u_int nof_assays_; |
---|
67 | |
---|
68 | void calculate_weights(gslapi::matrix&); |
---|
69 | void merging(std::vector<u_int>, gslapi::matrix&); |
---|
70 | }; |
---|
71 | |
---|
72 | }} // of namespace utility and namespace theplu |
---|
73 | |
---|
74 | #endif |
---|