]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMatrixSq.cxx
Adding Sym.Band-Diagonal matrix class + new preconditioners + coding conventions
[u/mrichter/AliRoot.git] / STEER / AliMatrixSq.cxx
1 /**********************************************************************************************/
2 /* Abstract class for matrix used for millepede2 operation.                                   */
3 /* Author: ruben.shahoyan@cern.ch                                                             */
4 /*                                                                                            */ 
5 /**********************************************************************************************/
6
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <iostream>
10 //
11 #include "TClass.h"
12 #include "TMath.h"
13 #include "AliMatrixSq.h"
14 //
15
16 using namespace std;
17
18 ClassImp(AliMatrixSq)
19
20
21
22 //___________________________________________________________
23 void AliMatrixSq::MultiplyByVec(Double_t *vecIn,Double_t *vecOut) const
24 {
25   // fill vecOut by matrix*vecIn
26   // vector should be of the same size as the matrix
27   for (int i=GetSize();i--;) {
28     vecOut[i] = 0.0;
29     for (int j=GetSize();j--;) vecOut[i] += vecIn[j]*(*this)(i,j);
30   }
31   //
32 }
33
34 //___________________________________________________________
35 void AliMatrixSq::PrintCOO() const
36 {
37   // print matrix in COO sparse format
38   //
39   // get number of non-zero elements
40   int nnz = 0;
41   int sz = GetSize();
42   for (int ir=0;ir<sz;ir++) for (int ic=0;ic<sz;ic++) if (Query(ir,ic)!=0) nnz++;
43   //
44   printf("%d %d %d\n",sz,sz,nnz);
45   double vl;
46   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);
47   //
48 }