CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
MatrixMeschach Class Reference

#include <MatrixMeschach.h>

Public Member Functions

void AddData (ALIuint col, ALIuint lin, ALIdouble data)
 
void Dump (const ALIstring &mtext)
 
void EliminateColumns (ALIint lin_first, ALIint lin_last)
 
void EliminateLines (ALIint lin_first, ALIint lin_last)
 
void inverse ()
 
const MAT * Mat () const
 
MAT * MatNonConst () const
 
 MatrixMeschach ()
 
 MatrixMeschach (ALIint NoCol, ALIint NoLin)
 
 MatrixMeschach (const MatrixMeschach &mat)
 
ALIint NoColumns () const
 
ALIint NoLines () const
 
ALIdouble operator() (int i, int j) const
 
void operator*= (const MatrixMeschach &mat)
 
void operator*= (const ALIdouble num)
 
void operator+= (const MatrixMeschach &mat)
 
MatrixMeschachoperator= (const MatrixMeschach &mat)
 
void ostrDump (std::ostream &fout, const ALIstring &mtext)
 
void SetCorrelation (ALIint i1, ALIint i2, ALIdouble corr)
 
void setMat (MAT *mat)
 
void setNoColumns (ALIint ncol)
 
void setNoLines (ALIint nlin)
 
void transpose ()
 
 ~MatrixMeschach ()
 

Private Member Functions

void copy (const MatrixMeschach &mat)
 

Private Attributes

MAT * _Mat
 
ALIint _NoColumns
 
ALIint _NoLines
 

Detailed Description

Definition at line 31 of file MatrixMeschach.h.

Constructor & Destructor Documentation

MatrixMeschach::MatrixMeschach ( )

Definition at line 16 of file MatrixMeschach.cc.

17 {
18  //- std::cout << "creating matrix0 " << std::endl;
19 }
MatrixMeschach::MatrixMeschach ( ALIint  NoCol,
ALIint  NoLin 
)

Definition at line 29 of file MatrixMeschach.cc.

References _Mat, _NoColumns, and _NoLines.

30 {
31  //- std::cout << "creating matrix " << std::endl;
32  _NoLines = NoLin;
33  _NoColumns = NoCol;
34  _Mat = m_get( NoLin, NoCol );
35  //_data = new ALIdouble[NoCol][NoLin];
36 }
MatrixMeschach::MatrixMeschach ( const MatrixMeschach mat)

Definition at line 40 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, copy(), NoColumns(), and NoLines().

41 {
42  //- std::cout << "creating matrixc " << std::endl;
43  _NoLines = mat._Mat->m;
44  _NoColumns = mat._Mat->n;
45  _Mat = m_get( mat.NoLines(), mat.NoColumns() );
46  // std::cout << "copy const" << mat._Mat << _Mat << NoLines() << NoColumns() << Mat()->m << Mat()->n <<std::endl;
47  copy( mat );
48 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
ALIint NoColumns() const
MatrixMeschach::~MatrixMeschach ( )

Definition at line 22 of file MatrixMeschach.cc.

References _Mat.

23 {
24  //- std::cout << "deleting matrix " << std::endl;
25  M_FREE(_Mat);
26 }

Member Function Documentation

void MatrixMeschach::AddData ( ALIuint  col,
ALIuint  lin,
ALIdouble  data 
)

Definition at line 273 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, dtNoiseDBValidation_cfg::cerr, cuy::col, data, and cppFunctionSkipper::exception.

Referenced by EliminateColumns(), EliminateLines(), Fit::FillMatricesWithCalibratedParameters(), Fit::FillMatricesWithMeasurements(), and SetCorrelation().

274 {
275  if ( lin >= _Mat->m || col >= _Mat->n ) {
276  std::cerr << "EXITING: matrix has only " << _NoLines << " lines and "
277  << _NoColumns << " columns " << std::endl;
278  std::cerr << "EXITING: matrix has only " << _Mat->m << " lines and "
279  << _Mat->n << " columns " << std::endl;
280  std::cerr << " You tried to add data in line " << lin << " and column "
281  << col << std::endl;
282  std::exception();
283  }
284  _Mat->me[lin][col] = data;
285 
286 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int col
Definition: cuy.py:1008
void MatrixMeschach::copy ( const MatrixMeschach mat)
private

Definition at line 52 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, cuy::col, and MatNonConst().

Referenced by EliminateColumns(), EliminateLines(), MatrixMeschach(), and operator=().

53 {
54  // if( ALIUtils::debug >= 5) std::cout << "copy matrix" << mat._Mat << " " << _Mat << " L " << mat.NoLines() << " C " << mat.NoColumns() << " l " << mat.Mat()->m << " c " << mat.Mat()->n <<std::endl;
55 
56  for( ALIint lin=0; lin < _NoLines; lin++ ) {
57  for( ALIint col=0; col < _NoColumns; col++ ) {
58  _Mat->me[lin][col] = mat.MatNonConst()->me[lin][col];
59  }
60  }
61  // m_copy( mat._Mat, _Mat );
62 }
int ALIint
Definition: CocoaGlobals.h:15
MAT * MatNonConst() const
int col
Definition: cuy.py:1008
void MatrixMeschach::Dump ( const ALIstring mtext)
void MatrixMeschach::EliminateColumns ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 333 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, AddData(), dtNoiseDBValidation_cfg::cerr, copy(), gather_cfg::cout, ALIUtils::debug, Dump(), cuy::ii, findQualityFiles::jj, Mat(), NoColumns(), and NoLines().

334 {
335  //- return;
336  if ( lin_last < lin_first ) {
337  std::cerr << "EXITING: cannot Eliminate Lines in matrix if first line is " <<
338  lin_first << " and lastt line is " << lin_last << std::endl;
339  //t std::exception();
340  return;
341  }
342  ALIint dif = (lin_last - lin_first) + 1;
343  ALIint newANolin = NoLines();
344  ALIint newANocol = NoColumns() - dif;
345  MatrixMeschach newmat( newANolin, newANocol );
346  ALIint jjn = 0;
347  for ( ALIint jj=0; jj<NoColumns(); jj++) {
348  if( jj < lin_first || jj > lin_last ) {
349  for ( ALIint ii=0; ii<NoLines(); ii++) {
350  newmat.AddData( ii, jjn, (*this)(ii,jj) );
351  if(ALIUtils::debug >= 9) std::cout << ii << jjn << "nmat" << newmat.Mat()->me[ii][jjn] << std::endl;
352  }
353  jjn++;
354  }
355  }
356  M_FREE( _Mat );
357  _Mat = m_get( newANolin, newANocol );
358  copy( newmat );
359  _NoLines = _Mat->m;
360  _NoColumns = _Mat->n;
361  Dump( "newnewmat" );
362 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:35
int ii
Definition: cuy.py:588
ALIint NoColumns() const
tuple cout
Definition: gather_cfg.py:121
void Dump(const ALIstring &mtext)
void MatrixMeschach::EliminateLines ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 299 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, AddData(), dtNoiseDBValidation_cfg::cerr, copy(), gather_cfg::cout, ALIUtils::debug, Dump(), cuy::ii, findQualityFiles::jj, Mat(), NoColumns(), and NoLines().

300 {
301  //- return;
302  if ( lin_last < lin_first ) {
303  std::cerr << "EXITING: cannot Eliminate Lines in matrix if first line is " <<
304  lin_first << " and lastt line is " << lin_last << std::endl;
305  //t std::exception();
306  return;
307  }
308  ALIint dif = (lin_last - lin_first) + 1;
309  ALIint newANolin = NoLines() - dif;
310  ALIint newANocol = NoColumns();
311  MatrixMeschach newmat( newANolin, newANocol );
312  ALIint iin = 0;
313  for ( ALIint ii=0; ii<NoLines(); ii++) {
314  if( ii < lin_first || ii > lin_last ) {
315  for ( ALIint jj=0; jj<NoColumns(); jj++) {
316  newmat.AddData(iin, jj, (*this)(ii,jj) );
317  if(ALIUtils::debug >= 9) std::cout << iin << jj << "nmat" << newmat.Mat()->me[iin][jj] << std::endl;
318  }
319  iin++;
320  }
321  }
322  M_FREE( _Mat );
323  _Mat = m_get( newANolin, newANocol );
324  copy( newmat );
325  _NoLines = _Mat->m;
326  _NoColumns = _Mat->n;
327  Dump( "newnewmat" );
328 
329 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:35
int ii
Definition: cuy.py:588
ALIint NoColumns() const
tuple cout
Definition: gather_cfg.py:121
void Dump(const ALIstring &mtext)
void MatrixMeschach::inverse ( )

Definition at line 259 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, gather_cfg::cout, and ALIUtils::debug.

Referenced by Fit::multiplyMatrices(), and Fit::PropagateErrors().

260 {
261  if(ALIUtils::debug >= 9) std::cout << "inverse" << _NoLines << "C" << _NoColumns << std::endl;
262  MAT* tempmat = m_get(_NoLines, _NoColumns);
263  ALIdouble factor = 1000.;
264  (*this) *= 1./factor;
265  m_inverse( _Mat, tempmat );
266  m_copy( tempmat, _Mat );
267  (*this) *= 1./factor;
268  M_FREE(tempmat);
269 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:35
tuple cout
Definition: gather_cfg.py:121
const MAT* MatrixMeschach::Mat ( ) const
inline
MAT* MatrixMeschach::MatNonConst ( ) const
inline

Definition at line 74 of file MatrixMeschach.h.

References _Mat.

Referenced by copy(), MatrixByMatrix(), operator*(), and Fit::PropagateErrors().

74  {
75  return _Mat;
76  }
ALIint MatrixMeschach::NoColumns ( ) const
inline
ALIint MatrixMeschach::NoLines ( ) const
inline
ALIdouble MatrixMeschach::operator() ( int  i,
int  j 
) const

Definition at line 290 of file MatrixMeschach.cc.

References _Mat, i, and j.

291 {
292  return _Mat->me[i][j];
293 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
void MatrixMeschach::operator*= ( const MatrixMeschach mat)

Definition at line 86 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, NoColumns(), and NoLines().

87 {
88  // std::cout << " multiply matrices " << std::endl;
89 
90  if( _NoColumns != mat.NoLines() ){
91  std::cerr << " !! Trying two multiply two matrices when the number of columns of first one is not equal to number of files of second one " << std::endl;
92  std::cout << " multiplying matrix " << _NoLines << " x " << _NoColumns << " and " << mat.NoLines() << " x " << mat.NoColumns() << " results in " << _NoLines << " x " << mat.NoColumns() << std::endl;
93  }
94  _NoColumns = mat.NoColumns();
95 
96  MAT* tempmat = m_get( _NoColumns, _NoLines );
97  m_transp( _Mat, tempmat);
98  // M_FREE( _Mat );
99  _Mat = m_get( _NoLines, mat.NoColumns() );
100  mtrm_mlt( tempmat, mat._Mat, _Mat);
101 
102  // _NoColumns = mat.NoColumns();
103  // M_FREE(tempmat);
104 }
ALIint NoLines() const
ALIint NoColumns() const
tuple cout
Definition: gather_cfg.py:121
void MatrixMeschach::operator*= ( const ALIdouble  num)

Definition at line 126 of file MatrixMeschach.cc.

References _Mat, cuy::ii, findQualityFiles::jj, and pileupDistInMC::num.

127 {
128  for (ALIuint ii=0; ii<_Mat->m; ii++) {
129  for (ALIuint jj=0; jj<_Mat->n; jj++) {
130  _Mat->me[ii][jj] *= num;
131  }
132  }
133 
134 }
int ii
Definition: cuy.py:588
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void MatrixMeschach::operator+= ( const MatrixMeschach mat)

Definition at line 108 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, and dtNoiseDBValidation_cfg::cerr.

109 {
110  if(_NoLines != mat._NoLines || _NoColumns != mat._NoColumns ) {
111  std::cerr << "!!!! cannot sum two matrices with different size" << std::endl
112  << "MATRIX 1:" << _NoLines << " X " << _NoColumns << std::endl
113  << "MATRIX 2:" << mat._NoLines << " X " << mat._NoColumns << std::endl;
114  }
115  MAT* tempmat = m_get( _NoColumns, _NoLines );
116  m_copy( _Mat, tempmat);
117  M_FREE( _Mat );
118  _Mat = m_get( _NoLines, _NoColumns );
119  m_add( tempmat, mat._Mat, _Mat);
120  M_FREE(tempmat);
121 
122 }
MatrixMeschach & MatrixMeschach::operator= ( const MatrixMeschach mat)

Definition at line 66 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, dtNoiseDBValidation_cfg::cerr, copy(), gather_cfg::cout, ALIUtils::debug, cppFunctionSkipper::exception, Mat(), NoColumns(), and NoLines().

67 {
68  if ( this == 0 ) {
69  std::cerr << "EXITING: trying to use 'operator=' with an MatrixMeschach for which memory space is not reserved!!!!" << std::endl;
71  }
72 
73  if ( mat._Mat != _Mat ) {
74  _NoLines = mat._Mat->m;
75  _NoColumns = mat._Mat->n;
76  M_FREE( _Mat );
77  _Mat = m_get( mat.NoLines(), mat.NoColumns() );
78  copy( mat );
79  }
80  if(ALIUtils::debug >= 9) std::cout << "operator=" << mat._Mat << _Mat << NoLines() << NoColumns() << Mat()->m << Mat()->n <<std::endl;
81  return *this;
82 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
static ALIint debug
Definition: ALIUtils.h:35
ALIint NoColumns() const
const MAT * Mat() const
tuple cout
Definition: gather_cfg.py:121
void MatrixMeschach::ostrDump ( std::ostream &  fout,
const ALIstring mtext 
)

Definition at line 372 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, cuy::ii, and findQualityFiles::jj.

Referenced by Dump(), and Fit::dumpMatrices().

373 {
374  fout << "DUMPM@@@@@ " << mtext << " @@@@@" << std::endl;
375  fout << "Matrix is (_Mat)" << _Mat->m << "x" << _Mat->n << std::endl;
376  fout << "Matrix is " << _NoLines << "x" << _NoColumns << std::endl;
377  for (ALIuint ii=0; ii<_Mat->m; ii++) {
378  for (ALIuint jj=0; jj<_Mat->n; jj++) {
379  fout << std::setw(8) << _Mat->me[ii][jj] << " ";
380  }
381  fout << std::endl;
382  }
383  // m_output(_Mat);
384 
385 }
int ii
Definition: cuy.py:588
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void MatrixMeschach::SetCorrelation ( ALIint  i1,
ALIint  i2,
ALIdouble  corr 
)

Definition at line 389 of file MatrixMeschach.cc.

References AddData(), gather_cfg::cout, ALIUtils::debug, and mathSSE::sqrt().

Referenced by Fit::setCorrelationFromParamFitted().

390 {
391  AddData(i1,i2,corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) );
392  AddData(i2,i1,corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) );
393  if(ALIUtils::debug >= 9) std::cout << i1<< i2<< corr << "CORR" << (*this)(i1,i1) << " " << (*this)(i2,i2) << std::endl;
394  //- std::cout << (*this)(i1,i1)*(*this)(i2,i2) << std::endl;
395  //- std::cout << sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) << std::endl;
396  if(ALIUtils::debug >= 9) std::cout << corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) << std::endl;
397 
398 }
static ALIint debug
Definition: ALIUtils.h:35
T sqrt(T t)
Definition: SSEVec.h:48
JetCorrectorParameters corr
Definition: classes.h:5
void AddData(ALIuint col, ALIuint lin, ALIdouble data)
tuple cout
Definition: gather_cfg.py:121
void MatrixMeschach::setMat ( MAT *  mat)
inline

Definition at line 71 of file MatrixMeschach.h.

References _Mat.

Referenced by MatrixByMatrix(), and operator*().

71  {
72  _Mat = mat;
73  }
void MatrixMeschach::setNoColumns ( ALIint  ncol)
inline

Definition at line 62 of file MatrixMeschach.h.

References _NoColumns.

Referenced by MatrixByMatrix(), and operator*().

62  {
63  _NoColumns = ncol;
64  }
void MatrixMeschach::setNoLines ( ALIint  nlin)
inline

Definition at line 65 of file MatrixMeschach.h.

References _NoLines.

65  {
66  _NoLines = nlin;
67  }
void MatrixMeschach::transpose ( )

Definition at line 217 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, and cuy::col.

Referenced by Fit::getFitQuality(), Fit::GetSChi2(), and Fit::multiplyMatrices().

218 {
219  // if(ALIUtils::debug >= 9)
220  /* std::cout << "transposed" <<_NoLines<<_NoColumns;
221  MAT* tempmat = m_get(_NoColumns, _NoLines);
222  m_transp( _Mat, tempmat );
223  std::cout << "transposed" <<_NoLines<<_NoColumns;
224  M_FREE( _Mat );
225  _Mat = m_get(_NoColumns, _NoLines);
226  std::cout << "transposed" <<_NoLines<<_NoColumns;
227  m_copy( tempmat, _Mat );
228  std::cout << "transposed" <<_NoLines<<_NoColumns;
229  int ntemp = _NoLines;
230  _NoLines = _NoColumns;
231  _NoColumns = ntemp;
232  M_FREE(tempmat);
233  */
234 
235  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
236  MAT* tempmat = m_get(_NoColumns, _NoLines);
237  m_transp( _Mat, tempmat );
238  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
239  M_FREE( _Mat );
240  _Mat = m_get(_NoColumns, _NoLines);
241  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
242  for( ALIint lin=0; lin < _NoColumns; lin++ ) {
243  for( ALIint col=0; col < _NoLines; col++ ) {
244  //- std::cout << "setting mat " << lin << " " << col << std::endl;
245  _Mat->me[lin][col] = tempmat->me[lin][col];
246  }
247  }
248  // m_copy( tempmat, _Mat );
249  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
250  int ntemp = _NoLines;
252  _NoColumns = ntemp;
253  M_FREE(tempmat);
254 
255 }
int ALIint
Definition: CocoaGlobals.h:15
int col
Definition: cuy.py:1008

Member Data Documentation

MAT* MatrixMeschach::_Mat
private
ALIint MatrixMeschach::_NoColumns
private
ALIint MatrixMeschach::_NoLines
private