ROOT logo
#ifndef ALIMINRESSOLVE_H
#define ALIMINRESSOLVE_H

/**********************************************************************************************/
/* General class for solving large system of linear equations                                 */
/* Includes MINRES, FGMRES methods as well as a few precondiotiong methods                    */
/*                                                                                            */ 
/* Author: ruben.shahoyan@cern.ch                                                             */
/*                                                                                            */ 
/**********************************************************************************************/

#include <TObject.h>
#include <TVectorD.h>
class AliMatrixSq;
class AliMatrixSparse;
class AliSymBDMatrix;


class AliMinResSolve : public TObject {
  //
 public:
  enum {kPreconBD=1,kPreconILU0=100,kPreconILU10=kPreconILU0+10,kPreconsTot};
  enum {kSolMinRes,kSolFGMRes,kNSolvers};
 public:
  AliMinResSolve();
  AliMinResSolve(const AliMatrixSq *mat, const TVectorD* rhs);
  AliMinResSolve(const AliMatrixSq *mat, const double  * rhs);
  AliMinResSolve(const AliMinResSolve& src);
  ~AliMinResSolve();
  AliMinResSolve& operator=(const AliMinResSolve& rhs);
  //
  // ---------  MINRES method (for symmetric matrices)
  Bool_t SolveMinRes(Double_t* VecSol,Int_t precon=0,int itnlim=2000,double rtol=1e-12);
  Bool_t SolveMinRes(TVectorD &VecSol,Int_t precon=0,int itnlim=2000,double rtol=1e-12);
  //
  // ---------  FGMRES method (for general symmetric matrices)
  Bool_t SolveFGMRES(Double_t* VecSol,Int_t precon=0,int itnlim=2000,double rtol=1e-12, int nkrylov=60);
  Bool_t SolveFGMRES(TVectorD &VecSol,Int_t precon=0,int itnlim=2000,double rtol=1e-12, int nkrylov=60);  
  //
  Bool_t InitAuxMinRes();
  Bool_t InitAuxFGMRES(int nkrylov);
  void   ApplyPrecon(const TVectorD& vecRHS, TVectorD& vecOut)     const;
  void   ApplyPrecon(const double*   vecRHS, double*   vecOut)     const;
  //
  Int_t  BuildPrecon(Int_t val=0);
  Int_t  GetPrecon()                                               const    {return fPrecon;} 
  void   ClearAux();
  //
  Int_t  BuildPreconBD(Int_t hwidth);
  Int_t  BuildPreconILUK(Int_t lofM);
  Int_t  BuildPreconILUKDense(Int_t lofM);
  Int_t  PreconILUKsymb(Int_t lofM);
  Int_t  PreconILUKsymbDense(Int_t lofM);
  //
 protected:
  //
  Int_t               fSize;                             // dimension of the input matrix
  Int_t               fPrecon;                           // preconditioner type
  AliMatrixSq*        fMatrix;                           // matrix defining the equations
  Double_t*           fRHS;                              // right hand side
  //
  Double_t            *fPVecY;                           // aux. space
  Double_t            *fPVecR1;                          // aux. space
  Double_t            *fPVecR2;                          // aux. space
  Double_t            *fPVecV;                           // aux. space
  Double_t            *fPVecW;                           // aux. space
  Double_t            *fPVecW1;                          // aux. space
  Double_t            *fPVecW2;                          // aux. space
  Double_t            **fPvv;                            // aux. space
  Double_t            **fPvz;                            // aux. space
  Double_t            **fPhh;                            // aux. space
  Double_t            *fDiagLU;                          // aux space
  AliMatrixSparse     *fMatL;                            // aux. space
  AliMatrixSparse     *fMatU;                            // aux. space
  AliSymBDMatrix      *fMatBD;                           // aux. space
  //
  ClassDef(AliMinResSolve,0)
};

#endif
 AliMinResSolve.h:1
 AliMinResSolve.h:2
 AliMinResSolve.h:3
 AliMinResSolve.h:4
 AliMinResSolve.h:5
 AliMinResSolve.h:6
 AliMinResSolve.h:7
 AliMinResSolve.h:8
 AliMinResSolve.h:9
 AliMinResSolve.h:10
 AliMinResSolve.h:11
 AliMinResSolve.h:12
 AliMinResSolve.h:13
 AliMinResSolve.h:14
 AliMinResSolve.h:15
 AliMinResSolve.h:16
 AliMinResSolve.h:17
 AliMinResSolve.h:18
 AliMinResSolve.h:19
 AliMinResSolve.h:20
 AliMinResSolve.h:21
 AliMinResSolve.h:22
 AliMinResSolve.h:23
 AliMinResSolve.h:24
 AliMinResSolve.h:25
 AliMinResSolve.h:26
 AliMinResSolve.h:27
 AliMinResSolve.h:28
 AliMinResSolve.h:29
 AliMinResSolve.h:30
 AliMinResSolve.h:31
 AliMinResSolve.h:32
 AliMinResSolve.h:33
 AliMinResSolve.h:34
 AliMinResSolve.h:35
 AliMinResSolve.h:36
 AliMinResSolve.h:37
 AliMinResSolve.h:38
 AliMinResSolve.h:39
 AliMinResSolve.h:40
 AliMinResSolve.h:41
 AliMinResSolve.h:42
 AliMinResSolve.h:43
 AliMinResSolve.h:44
 AliMinResSolve.h:45
 AliMinResSolve.h:46
 AliMinResSolve.h:47
 AliMinResSolve.h:48
 AliMinResSolve.h:49
 AliMinResSolve.h:50
 AliMinResSolve.h:51
 AliMinResSolve.h:52
 AliMinResSolve.h:53
 AliMinResSolve.h:54
 AliMinResSolve.h:55
 AliMinResSolve.h:56
 AliMinResSolve.h:57
 AliMinResSolve.h:58
 AliMinResSolve.h:59
 AliMinResSolve.h:60
 AliMinResSolve.h:61
 AliMinResSolve.h:62
 AliMinResSolve.h:63
 AliMinResSolve.h:64
 AliMinResSolve.h:65
 AliMinResSolve.h:66
 AliMinResSolve.h:67
 AliMinResSolve.h:68
 AliMinResSolve.h:69
 AliMinResSolve.h:70
 AliMinResSolve.h:71
 AliMinResSolve.h:72
 AliMinResSolve.h:73
 AliMinResSolve.h:74
 AliMinResSolve.h:75
 AliMinResSolve.h:76
 AliMinResSolve.h:77
 AliMinResSolve.h:78
 AliMinResSolve.h:79
 AliMinResSolve.h:80