Diana Software
QMatrixC.cc
Go to the documentation of this file.
1 /*
2 *
3 * Class QMatrixC
4 *
5 */
6 
7 #include "QMatrixC.hh"
8 #include "QVectorC.hh"
9 #include "QComplex.hh"
10 #include "QError.hh"
11 #include <TMath.h>
12 #include <cmath>
13 #include <TString.h>
14 #include <gsl/gsl_blas.h>
15 #include <gsl/gsl_linalg.h>
16 #include <gsl/gsl_eigen.h>
17 
18 QObjectImp(Diana::QMatrixC);
19 
20 #ifdef _HAVE_FFTW3_
21 #include <fftw3.h>
22 #endif
23 
25 
26 void QMatrixC::MatrixCopy(double *orig,UInt_t nrow,UInt_t ncol,
27  double *dest,UInt_t origCTda,UInt_t destCTda)
28 {
29  if(nrow == ncol && ncol == 0) return;
30  if(orig && dest){
31 
32  if(origCTda<ncol) origCTda=ncol;
33  if(destCTda<ncol) destCTda=origCTda;
34 
35  if(origCTda==ncol && destCTda==ncol)
36  memcpy(dest,orig,2*nrow*ncol*sizeof(double));
37  else
38  for(UInt_t i=0;i<nrow;i++)
39  memcpy(dest+2*i*destCTda,orig+2*i*origCTda,2*ncol*sizeof(double));
40  }
41  else if (!orig && !dest){
42  // If neither of them are allocated, do nothing?
43  }
44  else
45  DianaThrow(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
46  "Can not copy QMatrixC from origin to destination "
47  "before memory allocation!"));
48 
49 }
50 
52  : fDataOwner(true),
53  fSize(0),
54  fNCol(0),
55  fTda(0),
56  fAllocSize(0),
57  fData(0),
58  fMat(0)
59 {}
60 
61 
62 QMatrixC::QMatrixC(const UInt_t nrow,const UInt_t ncol)
63  : fDataOwner(true),
64  fSize(0),
65  fNCol(0),
66  fTda(0),
67  fAllocSize(0),
68  fData(0),
69  fMat(0)
70 {
71  Resize(nrow,ncol);
72 }
73 
75  : fDataOwner(true),
76  fSize(0),
77  fNCol(0),
78  fTda(0),
79  fAllocSize(0),
80  fData(0),
81  fMat(0)
82 {
83  Resize(vec.Size(),1);
84  if(vec.fStride==1)
86  else{
87  for(UInt_t i=0;i<vec.Size();i++)
88  this->operator()(i,0)=vec[i];
89  }
90 }
91 
93  : fDataOwner(true),
94  fSize(0),
95  fNCol(0),
96  fTda(0),
97  fAllocSize(0),
98  fData(0),
99  fMat(0)
100 {
101  Resize(orig.GetNRow(),orig.GetNCol());
103  MemRowCElements());
104 }
105 
107  : fDataOwner(true),
108  fSize(0),
109  fNCol(0),
110  fTda(0),
111  fAllocSize(0),
112  fData(0),
113  fMat(0)
114 {
115  Resize(orig.GetNRow(),orig.GetNCol());
116  for(UInt_t i = 0; i < orig.GetNRow(); i++) {
117  for(UInt_t j = 0; j < orig.GetNCol(); j++) {
118  this->operator()(i,j).SetRe(orig(i,j));
119  this->operator()(i,j).SetIm(0);
120  }
121  }
122 }
123 QMatrixC::QMatrixC(const gsl_matrix_complex* mat)
124  : fDataOwner(true),
125  fSize(0),
126  fNCol(0),
127  fTda(0),
128  fAllocSize(0),
129  fData(0),
130  fMat(0)
131 {
132  Resize(mat->size1,mat->size2);
133  MatrixCopy(mat->data,GetNRow(),GetNCol(),fData,MemRowCElements(),mat->tda);
134 }
135 
136 QMatrixC::QMatrixC(gsl_complex *data,const UInt_t nrow,const UInt_t ncol,
137  const UInt_t tda)
138  : fDataOwner(false),
139  fSize(2*ncol*nrow),
140  fNCol(ncol),
141  fTda(tda),
142  fAllocSize(2*ncol*nrow),
143  fData((double *)data),
144  fMat(0)
145 {
146  if(fTda<fNCol)
147  fTda = fNCol;
148  else
149  fTda = tda;
150 }
152 {
153  Clear();
154 }
156 {
157  if(fMat) free(fMat);
159  fMat=NULL;
160  fData=NULL;
161  fSize=0;
162  fNCol=0;
163  fTda=0;
164  fAllocSize=0;
165 }
166 
167 void QMatrixC::Resize(const UInt_t nrow,const UInt_t ncol)
168 {
169  if(GetNRow() == nrow && GetNCol() == ncol) return;
170  if(fDataOwner){
171  if(nrow*ncol > fAllocSize/2) {
173  fAllocSize=nrow*ncol*2;
175  }
176  fTda = ncol;
177  fSize = nrow*ncol*2;
178  fNCol = ncol;
179  if(fMat) free(fMat);
180  fMat=NULL;
181  }
182  else
183  DianaThrow(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
184  "Attempt to resize a QMatrixC which does not own "
185  "the memory."));
186 }
188 {
189  for(UInt_t i=0;i<GetNRow();i++) {
190  for(UInt_t j=0;j<(UInt_t)(fNCol);j++) {
191  operator()(i,j)=val;
192  }
193  }
194 }
196 {
197  SetMat();
198  gsl_matrix_complex_set_identity(fMat);
199 }
200 void QMatrixC::SetCol(const UInt_t n,const QVectorC& vec)
201 {
202  if(vec.Size()==GetNRow()){
203  SetMat();
204  vec.SetMathVector();
205  gsl_matrix_complex_set_col(fMat,n,vec.fMathVec);
206  }
207  else {
208  DianaThrow( QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,"You are trying to set a column of a QMatrixC with a different size QVectorC"));
209  }
210 }
211 
212 void QMatrixC::SetRow(const UInt_t n,const QVectorC& vec)
213 {
214  if(vec.Size()==GetNCol()){
215  SetMat();
216  vec.SetMathVector();
217  gsl_matrix_complex_set_row(fMat,n,vec.fMathVec);
218  }
219  else {
220  DianaThrow( QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,"You are trying to set a row of a QMatrixC with a different size QVectorC"));
221  }
222 }
223 QVectorC QMatrixC::GetCol(const UInt_t n) const
224 {
225  QVectorC res(GetNRow());
226  res.SetMathVector();
227  SetMat();
228  gsl_matrix_complex_get_col(res.fMathVec,fMat,n);
229  return res;
230 }
231 
232 QVectorC QMatrixC::GetRow(const UInt_t n) const
233 {
234  QVectorC res(GetNCol());
235  res.SetMathVector();
236  SetMat();
237  gsl_matrix_complex_get_row(res.fMathVec,fMat,n);
238  return res;
239 }
241 {
242  if(GetNCol() != GetNRow()) {
243  DianaThrow( QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,"GetDiagonal can be called only on square matrices"));
244  }
245  QVectorC res(GetNCol());
246  res.SetMathVector();
247  SetMat();
248  for(UInt_t i = 0; i < GetNCol(); i++) {
249  res[i] = this->operator()(i,i);
250  }
251  return res;
252 }
253 QComplex QMatrixC::operator()(const UInt_t i,const UInt_t j)
254 {
255  return GetElement(i,j);
256 }
257 
258 const QComplex QMatrixC::operator()(const UInt_t i,const UInt_t j) const
259 {
260  return GetElement(i,j);
261 }
262 
264 {
265  Resize(orig.GetNRow(),orig.fNCol);
268  if(fMat) free(fMat);
269  fMat = NULL;
270  return *this;
271 }
272 
274 {
275  return (*this)*(-1.);
276 }
277 
279 {
280  SetMat();
281  gsl_matrix_complex_scale(fMat,t.Get_gsl_complex());
282  return *this;
283 }
284 const QMatrixC& QMatrixC::operator*=(const double t)
285 {
286  QComplex tmp(t,0);
287  return operator*=(tmp);
288 }
289 const QMatrixC& QMatrixC::operator*=(const QMatrixC& other) {
290  // multiply a matrix ths=this*other
291  //gsl does not have matrix multiplications?!?
292  // gsl_matrix* tmpM=gsl_matrix_alloc(other.GetNRow(),other.GetNCol());
293 
294  QMatrixC tmp(*this);
295  Resize(GetNRow(),other.GetNCol());
296  gsl_complex uno;
297  uno.dat[0]=1;
298  uno.dat[1]=0;
299  gsl_complex zero;
300  zero.dat[0]=0;
301  zero.dat[1]=0;
302  SetMat();
303  other.SetMat();
304  tmp.SetMat();
305  gsl_blas_zgemm(CblasNoTrans,CblasNoTrans,uno,tmp.fMat,other.fMat,zero,fMat);
306 
307  return *this;
308 }
310 {
311  return operator*=(1/t);
312 }
313 const QMatrixC& QMatrixC::operator/=(const double t)
314 {
315  return operator*=(1/t);
316 }
317 
319 {
320  SetMat();
321  other.SetMat();
322  gsl_matrix_complex_add(fMat,other.fMat);
323  return *this;
324 }
325 
327 {
328  SetMat();
329  other.SetMat();
330  gsl_matrix_complex_sub(fMat,other.fMat);
331  return *this;
332 }
333 
334 const QMatrixC& QMatrixC::Mult(const QMatrixC& other)
335 {
336  SetMat();
337  other.SetMat();
338  gsl_matrix_complex_mul_elements(fMat,other.fMat);
339  return *this;
340 }
341 
342 const QMatrixC& QMatrixC::Div(const QMatrixC& other)
343 {
344  SetMat();
345  other.SetMat();
346  gsl_matrix_complex_div_elements(fMat,other.fMat);
347  return *this;
348 }
350 {
351  QMatrixC tmp(*this);
352  tmp*=mat;
353  return tmp;
354 }
355 QMatrixC QMatrixC::operator*(const double t) const
356 {
357  QMatrixC tmp(*this);
358  tmp*=t;
359  return tmp;
360 }
362 {
363  QMatrixC tmp(*this);
364  return tmp*=t;
365 }
367 {
368  QMatrixC tmp(*this);
369  return tmp/=t;
370 }
371 QMatrixC QMatrixC::operator/(const double t) const
372 {
373  QMatrixC tmp(*this);
374  tmp/=t;
375  return tmp;
376 }
377 
379 {
380  QMatrixC tmp(*this);
381  tmp+=mat;
382  return tmp;
383 }
384 
386 {
387  QMatrixC tmp(mat);
388  tmp-=mat;
389  return tmp;
390 }
392 {
393  QMatrixC v(vec);
394  QMatrixC tmp((*this)*v);
395  return tmp.GetCol(0);
396 }
398 {
399  QMatrixC tmp(*this);
400  tmp.Transpose();
401  return tmp;
402 }
404 {
405  Resize(GetNCol(),GetNRow());
406  SetMat();
407  gsl_matrix_complex_transpose(fMat);
408  return *this;
409 }
411 {
412  Transpose();
413  Conjugate();
414  return *this;
415 }
417  QMatrixC tmp(*this);
418  tmp.H();
419  return tmp;
420 }
422 {
423  for(UInt_t i=0;i<GetNRow();i++){
424  for(UInt_t j=0;j<GetNCol();j++){
425  fData[2*(i*MemRowCElements()+j)+1]*=-1;
426  }
427  }
428  return *this;
429 }
431 {
432  QMatrixC tmp(*this);
433  tmp.Conjugate();
434  return tmp;
435 }
437 {
438  SetMat();
439  QMatrix mag(GetNRow(),GetNCol());
440  for(UInt_t i = 0; i < GetNRow(); i++) {
441  for(UInt_t j = 0; j < GetNCol(); j++) {
442  mag(i,j) = this->operator()(i,j).GetMagnitude();
443  }
444  }
445  return mag;
446 }
448 {
449  QMatrixC tmp(*this);
450  tmp.Invert();
451  return tmp;
452 }
454 {
455  SetMat();
456  int err=0;
457  int sign=0;
458  gsl_permutation * p = gsl_permutation_calloc(GetNRow());
459  gsl_matrix_complex *LU = gsl_matrix_complex_calloc(GetNRow(),fNCol);
460  gsl_matrix_complex_memcpy(LU,fMat);
461  int * signum = &sign;
462  err=gsl_linalg_complex_LU_decomp(LU, p, signum);
463  if(err)std::cout<<" ERROR: failed to decompose matrix "<<err<<std::endl;
464  err=gsl_linalg_complex_LU_invert(LU, p, fMat);
465  if(err)std::cout<<" ERROR: failed to decompose matrix "<<err<<std::endl;
466  gsl_permutation_free(p);
467  gsl_matrix_complex_free(LU);
468  return *this;
469 }
471 {
472  SetMat();
473  int err=0;
474  int sign=0;
475  gsl_permutation * p = gsl_permutation_calloc(GetNRow());
476  gsl_matrix_complex * tmp_ptr = gsl_matrix_complex_calloc(GetNRow(),fNCol);
477  int * signum = &sign;
478  gsl_matrix_complex_memcpy(tmp_ptr, fMat);
479  err=gsl_linalg_complex_LU_decomp(tmp_ptr, p, signum);
480  if(err)std::cout<<" ERROR: failed to compute matrix determinant "<<err<<std::endl;
481  gsl_complex res = gsl_linalg_complex_LU_det(tmp_ptr, *signum);
482  gsl_permutation_free(p);
483  gsl_matrix_complex_free(tmp_ptr);
484  return QComplex(&res);
485 }
487 {
488  if(GetNRow()!=GetNCol())
489  DianaThrow(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
490  "Can not calculate eigen values of non square matrix"
491  " using HermitianEigenValues()."));
492  QVector Ret(GetNCol());
493  QVectorC diag=GetDiagonal();
494  SetMat();
495  Ret.SetMathVector();
496  gsl_eigen_herm_workspace *wSpace = gsl_eigen_herm_alloc(GetNCol());
497  int err = gsl_eigen_herm(fMat,Ret.fMathVec,wSpace);
498  if(err)
499  std::cout << " ERROR: Could not calculate eigenvalues of hermitian "
500  "matrix. " << err << std::endl;
501  for(UInt_t i=0;i<GetNRow();i++){
502  for(UInt_t j=0;j<i;j++){
503  (*this)(i,j)=(*this)(j,i).Conj();
504  }
505  (*this)(i,i)=diag[i];
506  }
507  gsl_eigen_herm_free(wSpace);
508  Ret.Sort(false);
509  return Ret;
510 }
512 {
513  if(GetNRow()!=GetNCol())
514  DianaThrow(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
515  "Can not calculate eigensystem of non square matrix"
516  " using HermitianEigenSystem()."));
517  Val.Resize(GetNRow());
518  Vec.Resize(GetNRow(),GetNCol());
519  QVectorC diag=GetDiagonal();
520  SetMat();
521  Val.SetMathVector();
522  Vec.SetMat();
523  gsl_eigen_hermv_workspace *wSpace = gsl_eigen_hermv_alloc(GetNCol());
524  int err = gsl_eigen_hermv(fMat,Val.fMathVec,Vec.fMat,wSpace);
525  if(err)
526  std::cout << " ERROR: Could not calculate eigenvalues of hermitian "
527  "matrix. " << err << std::endl;
528  for(UInt_t i=0;i<GetNRow();i++){
529  for(UInt_t j=0;j<i;j++){
530  (*this)(i,j)=(*this)(j,i).Conj();
531  }
532  (*this)(i,i)=diag[i];
533  }
534  gsl_eigen_hermv_sort(Val.fMathVec,Vec.fMat,GSL_EIGEN_SORT_ABS_DESC);
535  gsl_eigen_hermv_free(wSpace);
536 }
538  if(GetNRow()!=GetNCol())
539  DianaThrow(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
540  "Can not Cholsky decompose non-square matrix!"));
541  SetMat();
542  int err=gsl_linalg_complex_cholesky_decomp(fMat);
543  if(err) std::cout << " ERROR: Failed to Cholesky decompose matrix! " << err
544  << std::endl;
545  return *this;
546 }
548  QMatrixC out(*this);
549  out.CholeskyDecompose();
550  return out;
551 }
552 void QMatrixC::CholeskySolveX(const QVectorC &Y,QVectorC &X) const {
553  if(Y.Size()!=GetNRow())
554  throw QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
555  "Vector and matrix dimensions do not match "
556  "in CholeskySolveX");
557  X.Resize(Y.Size());
558  SetMat();
559  X.SetMathVector();
560  Y.SetMathVector();
561  int err = gsl_linalg_complex_cholesky_solve(fMat,Y.fMathVec,X.fMathVec);
562  if(err) std::cout << " ERROR: Failed to cholesky solve for X!" << err
563  << std::endl;
564 }
565 void QMatrixC::SetMat() const
566 {
567  if(!fMat) {
568  fMat = (gsl_matrix_complex*) malloc(sizeof(gsl_matrix_complex));
569 
570  fMat->size1=GetNRow();
571  fMat->size2=fNCol;
572  fMat->owner=1;
573  fMat->data=(double *)fData;
574  fMat->block=0;
575  fMat->tda=(fTda>fNCol ? fTda : fNCol);
576  }
577 }
578 
579 QMatrixC QMatrixC::GetSubMatrix(UInt_t nI,UInt_t nJ,UInt_t startI,
580  UInt_t startJ)
581 {
582  if(startI + nI > GetNRow() || startJ + nJ > GetNCol())
583  throw(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
584  Form("Cannot extract a submatrix of size %ix%i starting from"
585  " element %i,%i from a matrix of size %ix%i",
586  nI,nJ,startI,startJ,GetNRow(),GetNCol())));
587  gsl_complex *firstElem =
588  (gsl_complex *)fData+startI*MemRowCElements()+startJ;
589  QMatrixC ret(firstElem,nI,nJ,fTda);
590  return ret;
591 }
592 const QMatrixC QMatrixC::GetSubMatrix(UInt_t nI,UInt_t nJ,UInt_t startI,
593  UInt_t startJ) const
594 {
595  if(startI + nI > GetNRow() || startJ + nJ > GetNCol())
596  throw(QError(QERR_SIZE_NOT_MATCH,__FILE__,__LINE__,
597  Form("Cannot extract a submatrix of size %ix%i starting from"
598  " element %i,%i from a matrix of size %ix%i",
599  nI,nJ,startI,startJ,GetNRow(),GetNCol())));
600  gsl_complex *firstElem =
601  (gsl_complex *)fData+startI*MemRowCElements()+startJ;
602  QMatrixC ret(firstElem,nI,nJ,fTda);
603  return ret;
604 }
605 
607  QMatrixC Ret(*this);
608  for(size_t i=0;i<GetNRow();i++) {
609  for(size_t j=0;j<GetNCol();j++) {
610  if(i>0) Ret(i,j) += Ret(i-1,j);
611  if(j>0) Ret(i,j) += Ret(i,j-1);
612  if(i>0 && j>0) Ret(i,j) -= Ret(i-1,j-1);
613  }
614  }
615  return Ret;
616 }
617 
618 void QMatrixC::Print(const char *opt) const {
619  std::cout << "fSize " << fSize << std::endl;
620  std::cout << "fNRow " << GetNRow() << std::endl;
621  std::cout << "fNCol " << fNCol << std::endl;
622  std::cout << "fTda " << fTda << std::endl;
623  std::cout << "fData " << fData << std::endl;
624  std::cout << "fData ";
625  for(UInt_t i=0;i<TMath::Min(GetNRow(),(UInt_t)3);i++){
626  for(UInt_t j=0;j<TMath::Min(GetNCol(),(UInt_t)3);j++){
627  std::cout << (*this)(i,j) << "\t";
628  }
629  std::cout << std::endl;
630  }
631  std::cout << std::endl;
632 }
633 
635 
636 /*************************************
637  * NON MEMBER FUNCTIONS
638  * **********************************/
639 
640  Diana::QMatrixC operator*(double t, const Diana::QMatrixC&mat){
641  Diana::QMatrixC tmp(mat);
642  tmp*=t;
643  return tmp;
644 }
645 
646 std::ostream& operator<<(std::ostream&s,const Diana::QMatrixC&mat){
647  for (UInt_t i=0;i<mat.GetNRow();i++){
648  for (UInt_t j=0;j<mat.GetNCol();j++) s<<mat(i,j)<<" ";
649  s<<std::endl;
650  }
651  return s;
652 }
653 
654 
err
Definition: CheckOF.C:114
QVector vec(3)
#define DianaThrow(obj)
Definition: QDianaDebug.hh:26
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
@ QERR_SIZE_NOT_MATCH
Definition: QError.hh:31
QObjectImp(Diana::QMatrixC)
std::ostream & operator<<(std::ostream &s, const Diana::QMatrixC &mat)
scalar times QMatrix
Definition: QMatrixC.cc:646
Q_END_NAMESPACE Diana::QMatrixC operator*(double t, const Diana::QMatrixC &mat)
Definition: QMatrixC.cc:640
void SetIm(const double Im)
Definition: QComplex.cc:76
gsl_complex Get_gsl_complex() const
Definition: QComplex.cc:223
void SetRe(const double Re)
Definition: QComplex.cc:75
double GetMagnitude() const
Definition: QComplex.cc:91
error class with error type and description
Definition: QError.hh:115
Interface for complex matrices in Diana analysis.
Definition: QMatrixC.hh:27
UInt_t GetNRow() const
get number rows
Definition: QMatrixC.hh:87
void SetMat() const
Fill the GSL matrix data.
Definition: QMatrixC.cc:565
const QMatrixC & operator-=(const QMatrixC &mat)
subtract a QMatrixC
Definition: QMatrixC.cc:326
const QMatrixC & operator/=(const QComplex &t)
division by scalar
Definition: QMatrixC.cc:309
QComplex GetElement(const UInt_t i, const UInt_t j)
Definition: QMatrixC.hh:446
QMatrixC GetSubMatrix(UInt_t nI, UInt_t nJ, UInt_t startI=0, UInt_t startJ=0)
Get a sub matrix of the matrix.
Definition: QMatrixC.cc:579
void Initialize(const QComplex &val)
initialize all elements (default to 0)
Definition: QMatrixC.cc:187
UInt_t fAllocSize
Definition: QMatrixC.hh:477
virtual ~QMatrixC()
destructor
Definition: QMatrixC.cc:151
const QMatrixC & operator+=(const QMatrixC &mat)
add a QMatrixC
Definition: QMatrixC.cc:318
virtual const QMatrixC & CholeskyDecompose()
Cholesky Decomposition.
Definition: QMatrixC.cc:537
QVectorC GetRow(const UInt_t nrow) const
get row
Definition: QMatrixC.cc:232
QMatrixC GetSummedAreaMatrix() const
Create a summed area matrix.
Definition: QMatrixC.cc:606
gsl_matrix_complex * fMat
Definition: QMatrixC.hh:480
QVectorC GetDiagonal() const
get matrix diagonal
Definition: QMatrixC.cc:240
void Resize(const UInt_t nrow, const UInt_t ncol)
resize a QMatrixC
Definition: QMatrixC.cc:167
UInt_t GetNCol() const
get number of columns
Definition: QMatrixC.hh:92
QVector HermitianEigenValues()
Get a vector of the eigenvalues.
Definition: QMatrixC.cc:486
QMatrix Magnitude() const
return magnitude of each element
Definition: QMatrixC.cc:436
double * fData
Definition: QMatrixC.hh:478
void SetRow(const UInt_t nrow, const QVectorC &vec)
set row to specific vectors
Definition: QMatrixC.cc:212
QMatrixC GetConjugate() const
return conjugate matrix
Definition: QMatrixC.cc:430
UInt_t MemRowCElements() const
Definition: QMatrixC.hh:464
QMatrixC()
default constructor
Definition: QMatrixC.cc:51
static void MatrixCopy(double *orig, UInt_t nrow, UInt_t ncol, double *dest, UInt_t origTda=0, UInt_t destTda=0)
Definition: QMatrixC.cc:26
QMatrixC Inv() const
inverse
Definition: QMatrixC.cc:447
Bool_t fDataOwner
Definition: QMatrixC.hh:473
QMatrixC operator/(const QComplex &t) const
Division by scalar.
Definition: QMatrixC.cc:366
void Clear()
reset members to default values
Definition: QMatrixC.cc:155
const QMatrixC & operator*=(const QComplex &t)
multiplication by scalar
Definition: QMatrixC.cc:278
const QMatrixC & Mult(const QMatrixC &mat)
Multiply element by element.
Definition: QMatrixC.cc:334
QMatrixC operator*(const QMatrixC &mat) const
MatrixC product.
Definition: QMatrixC.cc:349
void SetToIdentity()
initialize to identity
Definition: QMatrixC.cc:195
UInt_t fNCol
Definition: QMatrixC.hh:475
QMatrixC operator+(const QMatrixC &mat) const
sum matrix
Definition: QMatrixC.cc:378
UInt_t fTda
Definition: QMatrixC.hh:476
const QMatrixC & operator=(const QMatrixC &orig)
copy the content of another matrix
Definition: QMatrixC.cc:263
UInt_t fSize
Definition: QMatrixC.hh:474
QVectorC GetCol(const UInt_t ncol) const
get a QMatrix from a map
Definition: QMatrixC.cc:223
QMatrixC GetH() const
compute hermitian conjugate
Definition: QMatrixC.cc:416
QMatrixC T() const
transpose
Definition: QMatrixC.cc:397
virtual void CholeskySolveX(const QVectorC &Y, QVectorC &X) const
Return the inverse, using Cholesky decomposition.
Definition: QMatrixC.cc:552
virtual QMatrixC GetCholeskyDecomposition() const
Cholesky Decomposition.
Definition: QMatrixC.cc:547
QComplex operator()(const UInt_t i, const UInt_t j)
get row matching the integer value val in column col if more than one value is found in column the fi...
Definition: QMatrixC.cc:253
const QMatrixC & H()
compute hermitian conjugate
Definition: QMatrixC.cc:410
void HermitianEigenSystem(QVector &Val, QMatrixC &Vec)
Get the eigen values and vectors.
Definition: QMatrixC.cc:511
QComplex Det() const
Determinant.
Definition: QMatrixC.cc:470
const QMatrixC & Transpose()
transpose
Definition: QMatrixC.cc:403
const QMatrixC & Div(const QMatrixC &mat)
Divide element by element.
Definition: QMatrixC.cc:342
const QMatrixC & Invert()
inverse
Definition: QMatrixC.cc:453
const QMatrixC & Conjugate()
conjugate this matrix
Definition: QMatrixC.cc:421
QMatrixC operator-() const
revert sign to alla components
Definition: QMatrixC.cc:273
void SetCol(const UInt_t ncol, const QVectorC &vec)
set column to specific vector
Definition: QMatrixC.cc:200
Interface for matrices in Diana analysis.
Definition: QMatrix.hh:24
UInt_t GetNRow() const
get number rows
Definition: QMatrix.hh:63
UInt_t GetNCol() const
get number of columns
Definition: QMatrix.hh:68
virtual void Print() const
print content on screen
Definition: QObject.hh:163
Interface for complex vectors in Diana analysis.
Definition: QVectorC.hh:25
void Resize(const UInt_t newsize)
Definition: QVectorC.cc:179
UInt_t Size() const
size of QVector
Definition: QVectorC.hh:82
Interface for vectors in Diana analysis.
Definition: QVector.hh:30
static void ArrayCopy(const double *orig, const UInt_t origStride, double *dest, const UInt_t destStride, const UInt_t size)
Definition: QVector.cc:60
UInt_t Size() const
size of QVector
Definition: QVector.hh:54
static void ArrayFree(double *array)
Definition: QVector.cc:72
void SetMathVector() const
Definition: QVector.cc:207
UInt_t fStride
data stride
Definition: QVector.hh:441
Double_t * fData
array
Definition: QVector.hh:444
static double * ArrayAlloc(const UInt_t size)
Definition: QVector.cc:32
const QVector & Sort(const bool asc=true)
sort this vector
Definition: QVector.cc:434
void Resize(const UInt_t newsize)
resize a QVector
Definition: QVector.cc:170
gsl_vector * fMathVec
temporary gsl_vector to use the gsl library
Definition: QVector.hh:447