Changeset 1930
- Timestamp:
- Apr 30, 2009, 8:04:11 PM (14 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/Matrix.cc
r1928 r1930 103 103 throw utility::GSL_error("Matrix::Matrix failed to allocate memory"); 104 104 105 // if gsl error handler disabled, out of bounds index will not106 // abort the program.107 105 for (size_t i=0; i<data_matrix.size(); ++i) { 108 106 assert(data_matrix[i].size()==columns()); -
trunk/yat/utility/MatrixWeighted.cc
r1890 r1930 65 65 MatrixWeighted::MatrixWeighted(std::istream& is, char sep) 66 66 { 67 Matrix data(is, sep); 68 copy(data); 67 if (!is.good()) 68 throw utility::IO_error("MatrixWeighted: istream is not good"); 69 70 // read the data file and store in stl vectors (dynamically 71 // expandable) 72 std::vector<std::vector<double> > data_matrix; 73 try { 74 load(is, data_matrix, sep, '\n', true); 75 } 76 catch (utility::IO_error& e) { 77 std::stringstream ss(e.what()); 78 ss << "\nMatrixWeighted(std::istream&): invalid dimensions\n"; 79 throw IO_error(ss.str()); 80 } 81 catch (std::runtime_error& e) { 82 std::stringstream ss(e.what()); 83 ss << "\nMatrixWeighted(std::istream&): invalid matrix element\n"; 84 throw IO_error(ss.str()); 85 } 86 87 unsigned int nof_rows = data_matrix.size(); 88 // if stream was empty, create nothing 89 if (!nof_rows) 90 return; 91 92 unsigned int nof_columns=data_matrix[0].size(); 93 94 resize(nof_rows, nof_columns); 95 for (size_t i=0; i<rows(); ++i) { 96 std::copy(data_matrix[i].begin(), data_matrix[i].end(), 97 data_iterator(begin_row(i))); 98 binary_weight(data_matrix[i].begin(), data_matrix[i].end(), 99 weight_iterator(begin_row(i))); 100 } 69 101 } 70 102
Note: See TracChangeset
for help on using the changeset viewer.