Changeset 1384
- Timestamp:
- Jul 17, 2008, 11:26:58 PM (14 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/MatrixWeighted.cc
r1382 r1384 55 55 56 56 57 MatrixWeighted::MatrixWeighted(const Matrix& data) 58 { 59 copy(data); 60 } 61 62 57 63 MatrixWeighted::MatrixWeighted(std::istream& is, char sep) 58 64 { 59 65 Matrix data(is, sep); 60 Matrix weight; 61 nan(data, weight); 62 columns_ = data.columns(); 63 resize(data.columns(), data.rows()); 64 std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin())); 65 std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin())); 66 copy(data); 66 67 } 67 68 … … 106 107 { 107 108 return columns_; 109 } 110 111 112 void MatrixWeighted::copy(const Matrix& data) 113 { 114 Matrix weight; 115 nan(data, weight); 116 copy(data, weight); 117 } 118 119 120 void MatrixWeighted::copy(const Matrix& data, const Matrix& weight) 121 { 122 assert(data.rows()==weight.rows()); 123 assert(data.columns()==weight.columns()); 124 columns_ = data.columns(); 125 resize(data.columns(), data.rows()); 126 std::copy(data.begin(), data.end(), make_data_iterator(vec_.begin())); 127 std::copy(weight.begin(), weight.end(), make_weight_iterator(vec_.begin())); 108 128 } 109 129 -
trunk/yat/utility/MatrixWeighted.h
r1381 r1384 36 36 namespace yat { 37 37 namespace utility { 38 39 class Matrix; 38 40 39 41 /// … … 97 99 MatrixWeighted(const MatrixWeighted&); 98 100 101 99 102 /** 100 103 \brief The istream constructor. 101 104 102 Constructor is reading data values using corresponding 103 constructor in Matrix class. The weights are calculate dusing 105 Data is copied from \a other and weights are calculated using 104 106 the nan function. 107 */ 108 explicit MatrixWeighted(const Matrix& other); 109 110 /** 111 \brief The istream constructor. 112 113 This constructor first creates a Matrix using the istream 114 constructor, and then constructs MatrixWeighted using 115 MatrixWeighted(const Matrix&). 105 116 */ 106 117 explicit MatrixWeighted(std::istream &, char sep='\0'); … … 221 232 222 233 private: 234 void copy(const Matrix&); 235 void copy(const Matrix& data, const Matrix& weight); 236 223 237 std::vector<DataWeight> vec_; 224 238 size_t columns_;
Note: See TracChangeset
for help on using the changeset viewer.