Matrix stream input operator

release/4.3a0
Richard Roberts 2012-06-04 13:44:21 +00:00
parent ec29518456
commit 318dd96dfb
2 changed files with 30 additions and 0 deletions

View File

@ -235,6 +235,29 @@ void save(const Matrix& A, const string &s, const string& filename) {
stream.close();
}
/* ************************************************************************* */
//istream& operator>>(istream& inputStream, Matrix& destinationMatrix) {
// destinationMatrix.resize(0,0);
// string line;
// bool first = true;
// while(getline(inputStream, line)) {
// // Read coefficients from file
// vector<double> coeffs;
// std::copy(istream_iterator<double>(stringstream(line)), istream_iterator<double>(), coeffs.end());
// if(first) {
// destinationMatrix.resize(1,
// }
// if(coeffs.size() != dimLatent()) {
// cout << "Error reading motion file, latent variable dimension does not match file" << endl;
// exit(1);
// }
//
// // Copy coefficients to alignment matrix
// alignment_.conservativeResize(alignment_.rows() + 1, dimLatent());
// alignment_.row(alignment_.rows() - 1) = Eigen::Map<Vector>(&coeffs[0], dimLatent()).transpose();
// }
//}
/* ************************************************************************* */
void insertSub(Matrix& fullMatrix, const Matrix& subMatrix, size_t i, size_t j) {
fullMatrix.block(i, j, subMatrix.rows(), subMatrix.cols()) = subMatrix;

View File

@ -183,6 +183,13 @@ void print(const Matrix& A, const std::string& s = "", std::ostream& stream = st
*/
void save(const Matrix& A, const std::string &s, const std::string& filename);
/**
* Read a matrix from an input stream, such as a file. Entries can be either
* tab-, space-, or comma-separated, similar to the format read by the MATLAB
* dlmread command.
*/
//istream& operator>>(istream& inputStream, Matrix& destinationMatrix);
/**
* extract submatrix, slice semantics, i.e. range = [i1,i2[ excluding i2
* @param A matrix