CMS 3D CMS Logo

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.

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

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 268 of file MatrixMeschach.cc.

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

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

269 {
270  if ( lin >= _Mat->m || col >= _Mat->n ) {
271  std::cerr << "EXITING: matrix has only " << _NoLines << " lines and "
272  << _NoColumns << " columns " << std::endl;
273  std::cerr << "EXITING: matrix has only " << _Mat->m << " lines and "
274  << _Mat->n << " columns " << std::endl;
275  std::cerr << " You tried to add data in line " << lin << " and column "
276  << col << std::endl;
277  std::exception();
278  }
279  _Mat->me[lin][col] = data;
280 
281 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
col
Definition: cuy.py:1009
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
col
Definition: cuy.py:1009
void MatrixMeschach::Dump ( const ALIstring mtext)
void MatrixMeschach::EliminateColumns ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 328 of file MatrixMeschach.cc.

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

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

Definition at line 294 of file MatrixMeschach.cc.

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

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

Definition at line 254 of file MatrixMeschach.cc.

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

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

255 {
256  if(ALIUtils::debug >= 9) std::cout << "inverse" << _NoLines << "C" << _NoColumns << std::endl;
257  MAT* tempmat = m_get(_NoLines, _NoColumns);
258  ALIdouble factor = 1000.;
259  (*this) *= 1./factor;
260  m_inverse( _Mat, tempmat );
261  m_copy( tempmat, _Mat );
262  (*this) *= 1./factor;
263  M_FREE(tempmat);
264 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:36
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 285 of file MatrixMeschach.cc.

References _Mat, and mps_fire::i.

286 {
287  return _Mat->me[i][j];
288 }
void MatrixMeschach::operator*= ( const MatrixMeschach mat)

Definition at line 81 of file MatrixMeschach.cc.

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

82 {
83  // std::cout << " multiply matrices " << std::endl;
84 
85  if( _NoColumns != mat.NoLines() ){
86  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;
87  std::cout << " multiplying matrix " << _NoLines << " x " << _NoColumns << " and " << mat.NoLines() << " x " << mat.NoColumns() << " results in " << _NoLines << " x " << mat.NoColumns() << std::endl;
88  }
89  _NoColumns = mat.NoColumns();
90 
91  MAT* tempmat = m_get( _NoColumns, _NoLines );
92  m_transp( _Mat, tempmat);
93  // M_FREE( _Mat );
94  _Mat = m_get( _NoLines, mat.NoColumns() );
95  mtrm_mlt( tempmat, mat._Mat, _Mat);
96 
97  // _NoColumns = mat.NoColumns();
98  // M_FREE(tempmat);
99 }
ALIint NoLines() const
ALIint NoColumns() const
void MatrixMeschach::operator*= ( const ALIdouble  num)

Definition at line 121 of file MatrixMeschach.cc.

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

122 {
123  for (ALIuint ii=0; ii<_Mat->m; ii++) {
124  for (ALIuint jj=0; jj<_Mat->n; jj++) {
125  _Mat->me[ii][jj] *= num;
126  }
127  }
128 
129 }
ii
Definition: cuy.py:589
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void MatrixMeschach::operator+= ( const MatrixMeschach mat)

Definition at line 103 of file MatrixMeschach.cc.

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

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

Definition at line 66 of file MatrixMeschach.cc.

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

67 {
68  if ( mat._Mat != _Mat ) {
69  _NoLines = mat._Mat->m;
70  _NoColumns = mat._Mat->n;
71  M_FREE( _Mat );
72  _Mat = m_get( mat.NoLines(), mat.NoColumns() );
73  copy( mat );
74  }
75  if(ALIUtils::debug >= 9) std::cout << "operator=" << mat._Mat << _Mat << NoLines() << NoColumns() << Mat()->m << Mat()->n <<std::endl;
76  return *this;
77 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
static ALIint debug
Definition: ALIUtils.h:36
ALIint NoColumns() const
const MAT * Mat() const
void MatrixMeschach::ostrDump ( std::ostream &  fout,
const ALIstring mtext 
)

Definition at line 367 of file MatrixMeschach.cc.

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

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

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

Definition at line 384 of file MatrixMeschach.cc.

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

Referenced by Fit::setCorrelationFromParamFitted().

385 {
386  AddData(i1,i2,corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) );
387  AddData(i2,i1,corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) );
388  if(ALIUtils::debug >= 9) std::cout << i1<< i2<< corr << "CORR" << (*this)(i1,i1) << " " << (*this)(i2,i2) << std::endl;
389  //- std::cout << (*this)(i1,i1)*(*this)(i2,i2) << std::endl;
390  //- std::cout << sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) << std::endl;
391  if(ALIUtils::debug >= 9) std::cout << corr * sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) << std::endl;
392 
393 }
static ALIint debug
Definition: ALIUtils.h:36
T sqrt(T t)
Definition: SSEVec.h:18
JetCorrectorParameters corr
Definition: classes.h:5
void AddData(ALIuint col, ALIuint lin, ALIdouble data)
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, and create_public_lumi_plots::ncol.

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

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 212 of file MatrixMeschach.cc.

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

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

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

Member Data Documentation

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