test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
matrixSaver.cc File Reference
#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)
 

Function Documentation

std::ostream& operator<< ( std::ostream &  outputFile,
const CLHEP::HepGenMatrix *  saveMe 
)

Definition at line 29 of file matrixSaver.cc.

References assert(), cuy::col, and download_sqlite_cfg::outputFile.

31 {
32 
33  int numRow = saveMe->num_row () ;
34  int numCol = saveMe->num_col () ;
35 
36  // write out the matrix dimensions
37  outputFile << numRow << '\t'
38  << numCol << '\n' ;
39 
40  // write the elements in the file
41  for (int row=0 ; row<numRow ; ++row)
42  {
43  for (int col=0 ; col<numCol ; ++col)
44  {
45  assert (row < numRow) ;
46  assert (col < numCol) ;
47  outputFile << (*saveMe)[row][col] << '\t' ;
48  }
49  outputFile << '\n' ;
50  }
51 
52  return outputFile ;
53 }
assert(m_qm.get())
int col
Definition: cuy.py:1008
std::istream& operator>> ( std::istream &  input,
CLHEP::HepGenMatrix &  matrix 
)

Definition at line 111 of file matrixSaver.cc.

References assert(), cuy::col, and input.

112 {
113  int numRow = 0 ;
114  int numCol = 0 ;
115 
116  //PG read the matrix dimension
117  input >> numRow ;
118  input >> numCol ;
119 
120  //PG check whether the matrices have the right dimension
121  assert ( numRow == matrix.num_row () ) ;
122  assert ( numCol == matrix.num_col () ) ;
123 
124  //PG get the matrix elements from the file
125  for (int row=0 ; row<numRow ; ++row)
126  {
127  for (int col=0 ; col<numCol ; ++col)
128  {
129  input >> matrix[row][col] ;
130  assert (col*row < numRow*numCol) ;
131  }
132  }
133 
134  return input ;
135 }
assert(m_qm.get())
static std::string const input
Definition: EdmProvDump.cc:44
int col
Definition: cuy.py:1008