#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <memory>
#include <cassert>
#include "CLHEP/Matrix/GenMatrix.h"
#include "CLHEP/Matrix/Matrix.h"
#include "CLHEP/Matrix/Vector.h"
#include "Calibration/Tools/interface/matrixSaver.h"
Go to the source code of this file.
Functions | |
std::ostream & | operator<< (std::ostream &outputFile, const CLHEP::HepGenMatrix *saveMe) |
std::istream & | operator>> (std::istream &input, CLHEP::HepGenMatrix &matrix) |
std::ostream& operator<< | ( | std::ostream & | outputFile, | |
const CLHEP::HepGenMatrix * | saveMe | |||
) |
Definition at line 29 of file matrixSaver.cc.
References parsecf::pyparsing::col(), and row.
00031 { 00032 00033 int numRow = saveMe->num_row () ; 00034 int numCol = saveMe->num_col () ; 00035 00036 // write out the matrix dimensions 00037 outputFile << numRow << '\t' 00038 << numCol << '\n' ; 00039 00040 // write the elements in the file 00041 for (int row=0 ; row<numRow ; ++row) 00042 { 00043 for (int col=0 ; col<numCol ; ++col) 00044 { 00045 assert (row < numRow) ; 00046 assert (col < numCol) ; 00047 outputFile << (*saveMe)[row][col] << '\t' ; 00048 } 00049 outputFile << '\n' ; 00050 } 00051 00052 return outputFile ; 00053 }
std::istream& operator>> | ( | std::istream & | input, | |
CLHEP::HepGenMatrix & | matrix | |||
) |
Definition at line 111 of file matrixSaver.cc.
References parsecf::pyparsing::col(), and row.
00112 { 00113 int numRow = 0 ; 00114 int numCol = 0 ; 00115 00116 //PG read the matrix dimension 00117 input >> numRow ; 00118 input >> numCol ; 00119 00120 //PG check whether the matrices have the right dimension 00121 assert ( numRow == matrix.num_row () ) ; 00122 assert ( numCol == matrix.num_col () ) ; 00123 00124 //PG get the matrix elements from the file 00125 for (int row=0 ; row<numRow ; ++row) 00126 { 00127 for (int col=0 ; col<numCol ; ++col) 00128 { 00129 input >> matrix[row][col] ; 00130 assert (col*row < numRow*numCol) ; 00131 } 00132 } 00133 00134 return input ; 00135 }