Pardiso.hxx
1 // Copyright (C) 2003-20013 Marc DuruflĂ©
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_PARDISO_HXX
21 
22 // if PARDISO_INTSIZE64 is defined, pardiso_64 is used instead of pardiso
23 #ifdef PARDISO_INTSIZE64
24 #define pardiso_int_t int64_t
25 #define call_pardiso pardiso_64
26 #else
27 #define pardiso_int_t int
28 #define call_pardiso pardiso
29 #endif
30 
31 // including Pardiso headers
32 extern "C"
33 {
34  // MKL version :
35  void pardisoinit(void*, int*, int*);
36  void pardiso(void *, int*, int*, int*,
37  int*, int*,
38  void *, int*, int*, int*,
39  int*, int*, int*,
40  void *, void *, int*);
41 
42  void pardiso_64(void *, pardiso_int_t*, pardiso_int_t*, pardiso_int_t*,
43  pardiso_int_t*, pardiso_int_t*,
44  void *, pardiso_int_t*, pardiso_int_t*, pardiso_int_t*,
45  pardiso_int_t*, pardiso_int_t*, pardiso_int_t*,
46  void *, void *, pardiso_int_t*);
47 
48  // recent version :
49  /* void pardisoinit (void *, int *, int *, int *, double *, int *);
50  void pardiso (void *, int *, int *, int *, int *, int *,
51  void *, int *, int *, int *, int *, int *,
52  int *, void *, void *, int *, double *); */
53 }
54 
55 namespace Seldon
56 {
57  template<class T>
59  {
60  protected :
61  void* pt[64];
62  pardiso_int_t mtype;
63  pardiso_int_t iparm[64];
64  double dparm[64];
65  pardiso_int_t size_matrix;
66  pardiso_int_t maxfct;
68  pardiso_int_t mnum;
69  pardiso_int_t msglvl;
70  int info_facto;
74  pardiso_int_t type_ordering;
75 
76  public :
77  MatrixPardiso();
79 
80  bool UseInteger8() const;
81  void Clear();
82 
83  void SelectOrdering(int type);
84  void SetPermutation(const IVect& permut);
85 
86  void HideMessages();
87  void ShowMessages();
88 
89  int GetInfoFactorization() const;
90  size_t GetMemorySize() const;
91 
92  template<class T0, class Prop, class Storage, class Allocator>
94  bool keep_matrix = false);
95 
97  Vector<pardiso_int_t>& IndCol,
98  Vector<T>& Values, bool sym);
99 
100  void FactorizeCSR(bool sym);
101 
102  template<class Allocator2>
104 
105  template<class Allocator2>
106  void Solve(const SeldonTranspose& TransA,
108 
109  void Solve(const SeldonTranspose& TransA, T* x_ptr, int nrhs_);
110 
111  template<class Allocator2, class Prop>
112  void Solve(const SeldonTranspose& TransA,
114 
115  };
116 
117 
118  template<class T0, class Prop, class Storage, class Allocator, class T>
120  bool keep_matrix = false);
121 
122  template<class T, class Allocator>
123  void SolveLU(MatrixPardiso<T>& mat_lu, Vector<T, VectFull, Allocator>& x);
124 
125  template<class T, class Allocator>
126  void SolveLU(const SeldonTranspose& TransA,
128 
129  template<class T, class Prop, class Allocator>
130  void SolveLU(MatrixPardiso<T>& mat_lu,
132 
133  template<class T, class Allocator, class Prop>
134  void SolveLU(const SeldonTranspose& TransA,
136 
137  template<class Allocator>
138  void SolveLU(MatrixPardiso<double>& mat_lu,
139  Vector<complex<double>, VectFull, Allocator>& x);
140 
141  template<class Allocator>
142  void SolveLU(const SeldonTranspose& TransA,
143  MatrixPardiso<double>& mat_lu,
144  Vector<complex<double>, VectFull, Allocator>& x);
145 
146  template<class Allocator>
147  void SolveLU(MatrixPardiso<complex<double> >& mat_lu,
149 
150  template<class Allocator>
151  void SolveLU(const SeldonTranspose& TransA,
152  MatrixPardiso<complex<double> >& mat_lu,
154 
155 }
156 
157 #define SELDON_FILE_PARDISO_HXX
158 #endif
Seldon::MatrixPardiso::FactorizeCSR
void FactorizeCSR(Vector< pardiso_int_t > &Ptr, Vector< pardiso_int_t > &IndCol, Vector< T > &Values, bool sym)
Performs analysis and factorisation of a matrix given in CSR form.
Definition: Pardiso.cxx:169
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::MatrixPardiso
Definition: Pardiso.hxx:58
Seldon::Vector< pardiso_int_t >
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::MatrixPardiso::Solve
void Solve(Vector< T, VectFull, Allocator2 > &x)
solves A x = b, x contains the source b on input, the solution x on output
Definition: Pardiso.cxx:308
Seldon::MatrixPardiso::Clear
void Clear()
LU factorization is cleared.
Definition: Pardiso.cxx:61
Seldon::MatrixPardiso::pt
void * pt[64]
pointer to Pardiso object
Definition: Pardiso.hxx:61
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::MatrixPardiso::GetMemorySize
size_t GetMemorySize() const
returns the size of memory used by numerical factorization in bytes
Definition: Pardiso.cxx:135
Seldon::MatrixPardiso::MatrixPardiso
MatrixPardiso()
default constructor
Definition: Pardiso.cxx:29
Seldon::MatrixPardiso::~MatrixPardiso
~MatrixPardiso()
destructor
Definition: Pardiso.cxx:43
Seldon::MatrixPardiso::indA
Vector< pardiso_int_t > indA
matrix in CSR form
Definition: Pardiso.hxx:71
Seldon::MatrixPardiso::SetPermutation
void SetPermutation(const IVect &permut)
Sets ordering.
Definition: Pardiso.cxx:101
Seldon::MatrixPardiso::iparm
pardiso_int_t iparm[64]
integer parameters
Definition: Pardiso.hxx:63
Seldon::MatrixPardiso::mtype
pardiso_int_t mtype
matrix type
Definition: Pardiso.hxx:62
Seldon::MatrixPardiso::ShowMessages
void ShowMessages()
Enables output messages.
Definition: Pardiso.cxx:119
Seldon::Vector< T, VectFull, Allocator >
Full vector class.
Definition: Vector.hxx:88
Seldon::GetLU
void GetLU(Matrix< T0, Prop0, Storage0, Allocator0 > &A)
Returns the LU factorization of a matrix.
Definition: Functions_Matrix.cxx:2073
Seldon::MatrixPardiso::perm
Vector< pardiso_int_t > perm
permutation array
Definition: Pardiso.hxx:73
Seldon::VirtualSparseDirectSolver
Base class for an interface with a direct solver.
Definition: SparseSolver.hxx:30
Seldon::MatrixPardiso::SelectOrdering
void SelectOrdering(int type)
sets ordering algorithm to use
Definition: Pardiso.cxx:93
Seldon::MatrixPardiso::GetInfoFactorization
int GetInfoFactorization() const
returns the error code obtained during numerical factorization
Definition: Pardiso.cxx:127
Seldon::MatrixPardiso::mnum
pardiso_int_t mnum
factor number, 1 <= mnum <= maxfct
Definition: Pardiso.hxx:68
Seldon::MatrixPardiso::msglvl
pardiso_int_t msglvl
verbosity level
Definition: Pardiso.hxx:69
Seldon::MatrixPardiso::FactorizeMatrix
void FactorizeMatrix(Matrix< T0, Prop, Storage, Allocator > &mat, bool keep_matrix=false)
performs analysis and factorization of matrix mat
Definition: Pardiso.cxx:151
Seldon::MatrixPardiso::HideMessages
void HideMessages()
Disables output messages.
Definition: Pardiso.cxx:111
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::MatrixPardiso::maxfct
pardiso_int_t maxfct
maximum number of factors with identical sparsity structure
Definition: Pardiso.hxx:66
Seldon::MatrixPardiso::valA
Vector< T > valA
values of non-zero entries
Definition: Pardiso.hxx:72
Seldon::Matrix< T, Prop, ColMajor, Allocator >
Column-major full-matrix class.
Definition: Matrix_Pointers.hxx:176