CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 30 of file MatrixMeschach.h.

Constructor & Destructor Documentation

MatrixMeschach::MatrixMeschach ( )

Definition at line 14 of file MatrixMeschach.cc.

14  {
15  //- std::cout << "creating matrix0 " << std::endl;
16 }
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::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 ( )

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

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

Definition at line 237 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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:79
int col
Definition: cuy.py:1009
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.Task::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
int col
Definition: cuy.py:1009
void MatrixMeschach::Dump ( const ALIstring mtext)
void MatrixMeschach::EliminateColumns ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 285 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, AddData(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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)
ALIint NoLines() const
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
int ii
Definition: cuy.py:589
ALIint NoColumns() const
tuple cout
Definition: gather_cfg.py:144
void Dump(const ALIstring &mtext)
void MatrixMeschach::EliminateLines ( ALIint  lin_first,
ALIint  lin_last 
)

Definition at line 253 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, AddData(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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)
ALIint NoLines() const
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
int ii
Definition: cuy.py:589
ALIint NoColumns() const
tuple cout
Definition: gather_cfg.py:144
void Dump(const ALIstring &mtext)
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
tuple cout
Definition: gather_cfg.py:144
const MAT* MatrixMeschach::Mat ( ) const
inline
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; }
ALIint MatrixMeschach::NoColumns ( ) const
inline
ALIint MatrixMeschach::NoLines ( ) const
inline
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]; }
void MatrixMeschach::operator*= ( const MatrixMeschach mat)

Definition at line 70 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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
tuple cout
Definition: gather_cfg.py:144
void MatrixMeschach::operator*= ( const ALIdouble  num)

Definition at line 108 of file MatrixMeschach.cc.

References _Mat, cuy::ii, findQualityFiles::jj, and pileupDistInMC::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 }
int ii
Definition: cuy.py:589
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void MatrixMeschach::operator+= ( const MatrixMeschach mat)

Definition at line 93 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, and EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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 }
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)
ALIint NoLines() const
static ALIint debug
Definition: ALIUtils.h:34
ALIint NoColumns() const
const MAT * Mat() const
tuple cout
Definition: gather_cfg.py:144
void MatrixMeschach::ostrDump ( std::ostream &  fout,
const ALIstring mtext 
)

Definition at line 320 of file MatrixMeschach.cc.

References _Mat, _NoColumns, _NoLines, 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 }
int ii
Definition: cuy.py:589
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void MatrixMeschach::SetCorrelation ( ALIint  i1,
ALIint  i2,
ALIdouble  corr 
)

Definition at line 334 of file MatrixMeschach.cc.

References AddData(), gather_cfg::cout, ALIUtils::debug, 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
T sqrt(T t)
Definition: SSEVec.h:19
void AddData(ALIuint col, ALIuint lin, ALIdouble data)
tuple cout
Definition: gather_cfg.py:144
void MatrixMeschach::setMat ( MAT *  mat)
inline

Definition at line 58 of file MatrixMeschach.h.

References _Mat.

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

58 { _Mat = mat; }
void MatrixMeschach::setNoColumns ( ALIint  ncol)
inline

Definition at line 55 of file MatrixMeschach.h.

References _NoColumns.

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

55 { _NoColumns = ncol; }
void MatrixMeschach::setNoLines ( ALIint  nlin)
inline

Definition at line 56 of file MatrixMeschach.h.

References _NoLines.

56 { _NoLines = nlin; }
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
int col
Definition: cuy.py:1009

Member Data Documentation

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