]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMatrixSq.cxx
Added AddTrackParams() method for convenience + some comments
[u/mrichter/AliRoot.git] / STEER / AliMatrixSq.cxx
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <iostream>
4 //
5 #include "TClass.h"
6 #include "TMath.h"
7 #include "TVectorD.h"
8 #include "AliMatrixSq.h"
9 //
10
11 using namespace std;
12
13 ClassImp(AliMatrixSq)
14
15
16
17 //___________________________________________________________
18 void AliMatrixSq::MultiplyByVec(Double_t *vecIn,Double_t *vecOut) const
19 {
20   // fill vecOut by matrix*vecIn
21   // vector should be of the same size as the matrix
22   for (int i=GetSize();i--;) {
23     vecOut[i] = 0.0;
24     for (int j=GetSize();j--;) vecOut[i] += vecIn[j]*(*this)(i,j);
25   }
26   //
27 }
28
29 //___________________________________________________________
30 void AliMatrixSq::PrintCOO() const
31 {
32   // print matrix in COO sparse format
33   //
34   // get number of non-zero elements
35   int nnz = 0;
36   int sz = GetSize();
37   for (int ir=0;ir<sz;ir++) for (int ic=0;ic<sz;ic++) if (Querry(ir,ic)!=0) nnz++;
38   //
39   printf("%d %d %d\n",sz,sz,nnz);
40   double vl;
41   for (int ir=0;ir<sz;ir++) for (int ic=0;ic<sz;ic++) if ((vl=Querry(ir,ic))!=0) printf("%d %d %f\n",ir,ic,vl);
42   //
43 }