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 30 of file MatrixMeschach.h.

Constructor & Destructor Documentation

◆ MatrixMeschach() [1/3]

MatrixMeschach::MatrixMeschach ( )

Definition at line 14 of file MatrixMeschach.cc.

14  {
15  //- std::cout << "creating matrix0 " << std::endl;
16 }

◆ MatrixMeschach() [2/3]

MatrixMeschach::MatrixMeschach ( ALIint  NoCol,
ALIint  NoLin 
)

Definition at line 25 of file MatrixMeschach.cc.

References _Mat, _NoColumns, and _NoLines.

25  {
26  //- std::cout << "creating matrix " << std::endl;
27  _NoLines = NoLin;
28  _NoColumns = NoCol;
29  _Mat = m_get(NoLin, NoCol);
30  //_data = new ALIdouble[NoCol][NoLin];
31 }

◆ MatrixMeschach() [3/3]

MatrixMeschach::MatrixMeschach ( const MatrixMeschach mat)

Definition at line 34 of file MatrixMeschach.cc.

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

34  {
35  //- std::cout << "creating matrixc " << std::endl;
36  _NoLines = mat._Mat->m;
37  _NoColumns = mat._Mat->n;
38  _Mat = m_get(mat.NoLines(), mat.NoColumns());
39  // std::cout << "copy const" << mat._Mat << _Mat << NoLines() << NoColumns() << Mat()->m << Mat()->n <<std::endl;
40  copy(mat);
41 }
void copy(const MatrixMeschach &mat)
ALIint NoLines() const
ALIint NoColumns() const

◆ ~MatrixMeschach()

MatrixMeschach::~MatrixMeschach ( )

Definition at line 19 of file MatrixMeschach.cc.

References _Mat.

19  {
20  //- std::cout << "deleting matrix " << std::endl;
21  M_FREE(_Mat);
22 }

Member Function Documentation

◆ AddData()

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

Definition at line 237 of file MatrixMeschach.cc.

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

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

237  {
238  if (lin >= _Mat->m || col >= _Mat->n) {
239  std::cerr << "EXITING: matrix has only " << _NoLines << " lines and " << _NoColumns << " columns " << std::endl;
240  std::cerr << "EXITING: matrix has only " << _Mat->m << " lines and " << _Mat->n << " columns " << std::endl;
241  std::cerr << " You tried to add data in line " << lin << " and column " << col << std::endl;
242  std::exception();
243  }
244  _Mat->me[lin][col] = data;
245 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
col
Definition: cuy.py:1009

◆ copy()

void MatrixMeschach::copy ( const MatrixMeschach mat)
private

Definition at line 44 of file MatrixMeschach.cc.

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

Referenced by SequenceTypes._TaskBase::copyAndAdd(), EliminateColumns(), EliminateLines(), MatrixMeschach(), and operator=().

44  {
45  // 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;
46 
47  for (ALIint lin = 0; lin < _NoLines; lin++) {
48  for (ALIint col = 0; col < _NoColumns; col++) {
49  _Mat->me[lin][col] = mat.MatNonConst()->me[lin][col];
50  }
51  }
52  // m_copy( mat._Mat, _Mat );
53 }
int ALIint
Definition: CocoaGlobals.h:15
MAT * MatNonConst() const
col
Definition: cuy.py:1009

◆ Dump()

void MatrixMeschach::Dump ( const ALIstring mtext)

◆ EliminateColumns()

void MatrixMeschach::EliminateColumns ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 285 of file MatrixMeschach.cc.

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

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

◆ EliminateLines()

void MatrixMeschach::EliminateLines ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 253 of file MatrixMeschach.cc.

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

253  {
254  //- return;
255  if (lin_last < lin_first) {
256  std::cerr << "EXITING: cannot Eliminate Lines in matrix if first line is " << lin_first << " and lastt line is "
257  << lin_last << std::endl;
258  //t std::exception();
259  return;
260  }
261  ALIint dif = (lin_last - lin_first) + 1;
262  ALIint newANolin = NoLines() - dif;
263  ALIint newANocol = NoColumns();
264  MatrixMeschach newmat(newANolin, newANocol);
265  ALIint iin = 0;
266  for (ALIint ii = 0; ii < NoLines(); ii++) {
267  if (ii < lin_first || ii > lin_last) {
268  for (ALIint jj = 0; jj < NoColumns(); jj++) {
269  newmat.AddData(iin, jj, (*this)(ii, jj));
270  if (ALIUtils::debug >= 9)
271  std::cout << iin << jj << "nmat" << newmat.Mat()->me[iin][jj] << std::endl;
272  }
273  iin++;
274  }
275  }
276  M_FREE(_Mat);
277  _Mat = m_get(newANolin, newANocol);
278  copy(newmat);
279  _NoLines = _Mat->m;
280  _NoColumns = _Mat->n;
281  Dump("newnewmat");
282 }
void copy(const MatrixMeschach &mat)
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
ALIint NoLines() const
ALIint NoColumns() const
ii
Definition: cuy.py:589
void Dump(const ALIstring &mtext)

◆ inverse()

void MatrixMeschach::inverse ( )

Definition at line 224 of file MatrixMeschach.cc.

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

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

224  {
225  if (ALIUtils::debug >= 9)
226  std::cout << "inverse" << _NoLines << "C" << _NoColumns << std::endl;
227  MAT* tempmat = m_get(_NoLines, _NoColumns);
228  ALIdouble factor = 1000.;
229  (*this) *= 1. / factor;
230  m_inverse(_Mat, tempmat);
231  m_copy(tempmat, _Mat);
232  (*this) *= 1. / factor;
233  M_FREE(tempmat);
234 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:34

◆ Mat()

const MAT* MatrixMeschach::Mat ( ) const
inline

◆ MatNonConst()

MAT* MatrixMeschach::MatNonConst ( ) const
inline

Definition at line 59 of file MatrixMeschach.h.

References _Mat.

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

59 { return _Mat; }

◆ NoColumns()

ALIint MatrixMeschach::NoColumns ( ) const
inline

◆ NoLines()

ALIint MatrixMeschach::NoLines ( ) const
inline

◆ operator()()

ALIdouble MatrixMeschach::operator() ( int  i,
int  j 
) const

Definition at line 248 of file MatrixMeschach.cc.

References _Mat, mps_fire::i, and dqmiolumiharvest::j.

248 { return _Mat->me[i][j]; }

◆ operator*=() [1/2]

void MatrixMeschach::operator*= ( const MatrixMeschach mat)

Definition at line 70 of file MatrixMeschach.cc.

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

70  {
71  // std::cout << " multiply matrices " << std::endl;
72 
73  if (_NoColumns != mat.NoLines()) {
74  std::cerr << " !! Trying two multiply two matrices when the number of columns of first one is not equal to number "
75  "of files of second one "
76  << std::endl;
77  std::cout << " multiplying matrix " << _NoLines << " x " << _NoColumns << " and " << mat.NoLines() << " x "
78  << mat.NoColumns() << " results in " << _NoLines << " x " << mat.NoColumns() << std::endl;
79  }
80  _NoColumns = mat.NoColumns();
81 
82  MAT* tempmat = m_get(_NoColumns, _NoLines);
83  m_transp(_Mat, tempmat);
84  // M_FREE( _Mat );
85  _Mat = m_get(_NoLines, mat.NoColumns());
86  mtrm_mlt(tempmat, mat._Mat, _Mat);
87 
88  // _NoColumns = mat.NoColumns();
89  // M_FREE(tempmat);
90 }
ALIint NoLines() const
ALIint NoColumns() const

◆ operator*=() [2/2]

void MatrixMeschach::operator*= ( const ALIdouble  num)

Definition at line 108 of file MatrixMeschach.cc.

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

108  {
109  for (ALIuint ii = 0; ii < _Mat->m; ii++) {
110  for (ALIuint jj = 0; jj < _Mat->n; jj++) {
111  _Mat->me[ii][jj] *= num;
112  }
113  }
114 }
ii
Definition: cuy.py:589
unsigned int ALIuint
Definition: CocoaGlobals.h:17

◆ operator+=()

void MatrixMeschach::operator+= ( const MatrixMeschach mat)

Definition at line 93 of file MatrixMeschach.cc.

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

93  {
94  if (_NoLines != mat._NoLines || _NoColumns != mat._NoColumns) {
95  std::cerr << "!!!! cannot sum two matrices with different size" << std::endl
96  << "MATRIX 1:" << _NoLines << " X " << _NoColumns << std::endl
97  << "MATRIX 2:" << mat._NoLines << " X " << mat._NoColumns << std::endl;
98  }
99  MAT* tempmat = m_get(_NoColumns, _NoLines);
100  m_copy(_Mat, tempmat);
101  M_FREE(_Mat);
102  _Mat = m_get(_NoLines, _NoColumns);
103  m_add(tempmat, mat._Mat, _Mat);
104  M_FREE(tempmat);
105 }

◆ operator=()

MatrixMeschach & MatrixMeschach::operator= ( const MatrixMeschach mat)

Definition at line 56 of file MatrixMeschach.cc.

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

56  {
57  if (mat._Mat != _Mat) {
58  _NoLines = mat._Mat->m;
59  _NoColumns = mat._Mat->n;
60  M_FREE(_Mat);
61  _Mat = m_get(mat.NoLines(), mat.NoColumns());
62  copy(mat);
63  }
64  if (ALIUtils::debug >= 9)
65  std::cout << "operator=" << mat._Mat << _Mat << NoLines() << NoColumns() << Mat()->m << Mat()->n << std::endl;
66  return *this;
67 }
void copy(const MatrixMeschach &mat)
static ALIint debug
Definition: ALIUtils.h:34
ALIint NoLines() const
ALIint NoColumns() const
const MAT * Mat() const

◆ ostrDump()

void MatrixMeschach::ostrDump ( std::ostream &  fout,
const ALIstring mtext 
)

Definition at line 320 of file MatrixMeschach.cc.

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

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

320  {
321  fout << "DUMPM@@@@@ " << mtext << " @@@@@" << std::endl;
322  fout << "Matrix is (_Mat)" << _Mat->m << "x" << _Mat->n << std::endl;
323  fout << "Matrix is " << _NoLines << "x" << _NoColumns << std::endl;
324  for (ALIuint ii = 0; ii < _Mat->m; ii++) {
325  for (ALIuint jj = 0; jj < _Mat->n; jj++) {
326  fout << std::setw(8) << _Mat->me[ii][jj] << " ";
327  }
328  fout << std::endl;
329  }
330  // m_output(_Mat);
331 }
ii
Definition: cuy.py:589
unsigned int ALIuint
Definition: CocoaGlobals.h:17

◆ SetCorrelation()

void MatrixMeschach::SetCorrelation ( ALIint  i1,
ALIint  i2,
ALIdouble  corr 
)

Definition at line 334 of file MatrixMeschach.cc.

References AddData(), alignCSCRings::corr, gather_cfg::cout, ALIUtils::debug, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, and mathSSE::sqrt().

Referenced by Fit::setCorrelationFromParamFitted().

334  {
335  AddData(i1, i2, corr * sqrt((*this)(i1, i1) * (*this)(i2, i2)));
336  AddData(i2, i1, corr * sqrt((*this)(i1, i1) * (*this)(i2, i2)));
337  if (ALIUtils::debug >= 9)
338  std::cout << i1 << i2 << corr << "CORR" << (*this)(i1, i1) << " " << (*this)(i2, i2) << std::endl;
339  //- std::cout << (*this)(i1,i1)*(*this)(i2,i2) << std::endl;
340  //- std::cout << sqrt( (*this)(i1,i1)*(*this)(i2,i2) ) << std::endl;
341  if (ALIUtils::debug >= 9)
342  std::cout << corr * sqrt((*this)(i1, i1) * (*this)(i2, i2)) << std::endl;
343 }
static ALIint debug
Definition: ALIUtils.h:34
dictionary corr
T sqrt(T t)
Definition: SSEVec.h:19
void AddData(ALIuint col, ALIuint lin, ALIdouble data)

◆ setMat()

void MatrixMeschach::setMat ( MAT *  mat)
inline

Definition at line 58 of file MatrixMeschach.h.

References _Mat.

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

58 { _Mat = mat; }

◆ setNoColumns()

void MatrixMeschach::setNoColumns ( ALIint  ncol)
inline

Definition at line 55 of file MatrixMeschach.h.

References _NoColumns.

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

55 { _NoColumns = ncol; }

◆ setNoLines()

void MatrixMeschach::setNoLines ( ALIint  nlin)
inline

Definition at line 56 of file MatrixMeschach.h.

References _NoLines.

56 { _NoLines = nlin; }

◆ transpose()

void MatrixMeschach::transpose ( )

Definition at line 185 of file MatrixMeschach.cc.

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

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

185  {
186  // if(ALIUtils::debug >= 9)
187  /* std::cout << "transposed" <<_NoLines<<_NoColumns;
188  MAT* tempmat = m_get(_NoColumns, _NoLines);
189  m_transp( _Mat, tempmat );
190  std::cout << "transposed" <<_NoLines<<_NoColumns;
191  M_FREE( _Mat );
192  _Mat = m_get(_NoColumns, _NoLines);
193  std::cout << "transposed" <<_NoLines<<_NoColumns;
194  m_copy( tempmat, _Mat );
195  std::cout << "transposed" <<_NoLines<<_NoColumns;
196  int ntemp = _NoLines;
197  _NoLines = _NoColumns;
198  _NoColumns = ntemp;
199  M_FREE(tempmat);
200  */
201 
202  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
203  MAT* tempmat = m_get(_NoColumns, _NoLines);
204  m_transp(_Mat, tempmat);
205  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
206  M_FREE(_Mat);
207  _Mat = m_get(_NoColumns, _NoLines);
208  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
209  for (ALIint lin = 0; lin < _NoColumns; lin++) {
210  for (ALIint col = 0; col < _NoLines; col++) {
211  //- std::cout << "setting mat " << lin << " " << col << std::endl;
212  _Mat->me[lin][col] = tempmat->me[lin][col];
213  }
214  }
215  // m_copy( tempmat, _Mat );
216  //- std::cout << "transposed" <<_NoLines<<_NoColumns;
217  int ntemp = _NoLines;
219  _NoColumns = ntemp;
220  M_FREE(tempmat);
221 }
int ALIint
Definition: CocoaGlobals.h:15
col
Definition: cuy.py:1009

Member Data Documentation

◆ _Mat

MAT* MatrixMeschach::_Mat
private

◆ _NoColumns

ALIint MatrixMeschach::_NoColumns
private

◆ _NoLines

ALIint MatrixMeschach::_NoLines
private