]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliMatrixSq.cxx
Clearer fatal message.
[u/mrichter/AliRoot.git] / STEER / STEER / AliMatrixSq.cxx
1 /**********************************************************************************************/
2 /*                                                                                            */ 
3 /* Abstract class for matrix used for                                                         */
4 /* millepede2 operation.                                                                      */
5 /* Works for expandable square matrices                                                       */ 
6 /* of arbitrary dimension                                                                     */
7 /* Author: ruben.shahoyan@cern.ch                                                             */
8 /*                                                                                            */ 
9 /*                                                                                            */ 
10 /**********************************************************************************************/
11
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <iostream>
15 //
16 #include "TClass.h"
17 #include "TMath.h"
18 #include "AliMatrixSq.h"
19 //
20
21 ClassImp(AliMatrixSq)
22
23 AliMatrixSq & AliMatrixSq::operator=(const AliMatrixSq &src)
24 {
25   // = operator
26   if (this == &src) return *this;
27   TMatrixDBase::operator=(src);
28   fSymmetric = src.fSymmetric; 
29   return *this;
30 }
31
32 //___________________________________________________________
33 void AliMatrixSq::MultiplyByVec(const Double_t *vecIn,Double_t *vecOut) const
34 {
35   // fill vecOut by matrix*vecIn
36   // vector should be of the same size as the matrix
37   for (int i=GetSize();i--;) {
38     vecOut[i] = 0.0;
39     for (int j=GetSize();j--;) vecOut[i] += vecIn[j]*(*this)(i,j);
40   }
41   //
42 }
43
44 //___________________________________________________________
45 void AliMatrixSq::PrintCOO() const
46 {
47   // print matrix in COO sparse format
48   //
49   // get number of non-zero elements
50   int nnz = 0;
51   int sz = GetSize();
52   for (int ir=0;ir<sz;ir++) for (int ic=0;ic<sz;ic++) if (Query(ir,ic)!=0) nnz++;
53   //
54   printf("%d %d %d\n",sz,sz,nnz);
55   double vl;
56   for (int ir=0;ir<sz;ir++) for (int ic=0;ic<sz;ic++) if ((vl=Query(ir,ic))!=0) printf("%d %d %f\n",ir,ic,vl);
57   //
58 }