NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
tsolver-lapacklu.hxx
Go to the documentation of this file.
1 #ifndef TSOLVER_LAPACK_LU_HXX
7 #define TSOLVER_LAPACK_LU_HXX
8 
9 #include "tmatrix.hxx"
10 
11 namespace numcxx
12 {
17  template<typename T>
18  class TSolverLapackLU: public TLinSolver<T>
19  {
20  const std::shared_ptr< TMatrix<T> > pMatrix;
21  const std::shared_ptr< TMatrix<T> > pLU;
22  const std::shared_ptr< TArray1<int>> pIPiv;
23  public:
26  TSolverLapackLU(const std::shared_ptr<TMatrix<T>> pMatrix);
27 
30  TSolverLapackLU(const TMatrix<T>& Matrix);
31 
33  static std::shared_ptr<TSolverLapackLU<T>> create(const std::shared_ptr<TMatrix<T>> pMatrix);
34 
40  void update();
41 
44  void update(const TMatrix<T>& Matrix);
45 
50  void solve( TArray<T> & Sol, const TArray<T> & Rhs) const;
51 
53  void solve( std::shared_ptr<TArray1<T>> Sol, const std::shared_ptr<TArray1<T>> Rhs) const {solve(*Sol,*Rhs);};
54 
57  std::shared_ptr<TMatrix<T>> calculate_inverse();
58 
61 
62 
63 
64  TMatrix<T> & LU(){ return *pLU;}
65  TArray1<int> & IPiv(){ return *pIPiv;}
66  };
67 
68  template<typename T>
69  inline std::ostream & operator << (std::ostream & s, TSolverLapackLU<T> &LU)
70  {
71  s << "LU:" << std::endl;
72  s << LU.LU() << std::endl;
73  s << "IPiv:" << std::endl;
74  s << LU.IPiv() << std::endl;
75  }
76 
77 }
78 #include "tsolver-lapacklu.ixx"
79 #endif
const std::shared_ptr< TMatrix< T > > pMatrix
std::shared_ptr< TMatrix< T > > calculate_inverse()
Calculate inverse of matrix A from its LU factors.
Header for numcxx::TMatrix.
TArray1< int > & IPiv()
static std::shared_ptr< TSolverLapackLU< T > > create(const std::shared_ptr< TMatrix< T >> pMatrix)
Static wrapper around constructor.
void solve(TArray< T > &Sol, const TArray< T > &Rhs) const
Solve LU factorized system.
TArray is the common template base class for arrays and dense matrices of the numcxx project...
Definition: tarray.hxx:17
Inline methods for numcxx::TSolverLapackLU.
void update()
Perform computation of LU factorization using actual state of matrix.
Base class for linear solvers and preconditioners.
Definition: tarray.hxx:275
TSolverLapackLU()
Default constructor for swig.
One dimensional array class.
Definition: tarray1.hxx:31
Dense matrix class.
Definition: tmatrix.hxx:38
Lapack LU factorization class.
Numcxx template library.
Definition: expression.ixx:41
const std::shared_ptr< TArray1< int > > pIPiv
const std::shared_ptr< TMatrix< T > > pLU
void solve(std::shared_ptr< TArray1< T >> Sol, const std::shared_ptr< TArray1< T >> Rhs) const
Solve LU factorized system.