MyraMath
ILUSolver.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_ITERATIVE_ILUSOLVER_H
7 #define MYRAMATH_ITERATIVE_ILUSOLVER_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
16 
18 
19 namespace myra {
20 
21 template<class Number> class Matrix;
22 template<class Number> class MatrixRange;
23 template<class Number> class CMatrixRange;
24 template<class Number> class Vector;
25 template<class Number> class CVectorRange;
26 
28 template<class Number> class MYRAMATH_EXPORT ILUSolver
29  {
30  public:
31 
32  // Useful typedefs.
33  typedef typename ReflectPrecision<Number>::type Precision;
34 
36  // Can optionally apply a shift to A to make it more positive and reduce the chance of breakdown.
37  // Can optionally modify the factorization, by compensating the diagonal as entries are dropped.
38  ILUSolver(const CSparseMatrixRange<Number>& A, Precision shift = 0, bool modify = false);
39 
41  // side = Solve by A from the 'L'eft or from the 'R'ight?
42  // op = Apply an operation to A? ('T'ranspose, 'H'ermitian, 'C'onjugate or 'N'othing)
43  void solve(const MatrixRange<Number>& B, char side = 'L', char op = 'N') const;
44 
45  // Implementation details of solve().
46  void solveL(const MatrixRange<Number>& B, char side, char op) const;
47  void solveU(const MatrixRange<Number>& B, char side, char op) const;
48 
50  int size() const;
51 
52  private:
53 
54  // Holds triangles L and U.
57 
58  };
59 
60 // ReflectNumber for ILUSolver
61 template<class Number> class ReflectNumber <ILUSolver<Number> >
62  { public: typedef Number type; };
63 
64 // Overloads ILUSolver*x, delegates to .solve() under the hood.
65 MYRAMATH_EXPORT Vector<NumberS> operator * (const ILUSolver<NumberS>& solver, const CVectorRange<NumberS>& x);
66 MYRAMATH_EXPORT Vector<NumberD> operator * (const ILUSolver<NumberD>& solver, const CVectorRange<NumberD>& x);
67 MYRAMATH_EXPORT Vector<NumberC> operator * (const ILUSolver<NumberC>& solver, const CVectorRange<NumberC>& x);
68 MYRAMATH_EXPORT Vector<NumberZ> operator * (const ILUSolver<NumberZ>& solver, const CVectorRange<NumberZ>& x);
69 
70 // Overloads ILUSolver*X, delegates to .solve() under the hood.
71 MYRAMATH_EXPORT Matrix<NumberS> operator * (const ILUSolver<NumberS>& solver, const CMatrixRange<NumberS>& X);
72 MYRAMATH_EXPORT Matrix<NumberD> operator * (const ILUSolver<NumberD>& solver, const CMatrixRange<NumberD>& X);
73 MYRAMATH_EXPORT Matrix<NumberC> operator * (const ILUSolver<NumberC>& solver, const CMatrixRange<NumberC>& X);
74 MYRAMATH_EXPORT Matrix<NumberZ> operator * (const ILUSolver<NumberZ>& solver, const CMatrixRange<NumberZ>& X);
75 
76 } // namespace myra
77 
78 #endif
Reflects Number trait for a Container, containers of Numbers (Matrix&#39;s, Vector&#39;s, etc) should special...
Definition: Number.h:55
Incompletely factors A ~= L*U, presents approximate solve() method.
Definition: ILUSolver.h:28
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
General purpose compressed-sparse-column (CSC) container.
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Various utility functions/classes related to scalar Number types.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
Represents a const SparseMatrixRange.
Definition: bothcat.h:24
Tabulates a vector of length N, allows random access.
Definition: conjugate.h:21
Reflects Precision trait for a Number, scalar Number types should specialize it.
Definition: Number.h:33
Represents a const VectorRange.
Definition: axpy.h:20
Stores an IxJ matrix A in compressed sparse column format.
Definition: bothcat.h:23