Pastix.hxx
1 // Copyright (C) 2001-2010 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 #ifndef SELDON_FILE_PASTIX_HXX
20 
21 // including Pastix headers
22 extern "C"
23 {
24 #define _COMPLEX_H
25 
26 #include "pastix.h"
27 #include "pastix/order.h"
28 
29 #undef FLOAT
30 #undef INT
31 #undef UINT
32 
33 }
34 
35 namespace Seldon
36 {
37 
38  template<class T>
40  {
41  protected :
43  pastix_data_t* pastix_data;
45  pastix_int_t iparm[IPARM_SIZE];
47  double dparm[DPARM_SIZE];
49  pastix_int_t n;
50  pastix_order_t ord;
51  spmatrix_t *spm;
55  bool cholesky;
64  MPI_Comm comm_;
65 
66  void FillSpmMatrix(Vector<pastix_int_t>& Ptr, Vector<pastix_int_t>& IndRow,
67  Vector<T>& Val, bool sym, const Vector<int>&, MPI_Comm comm_facto);
68 
69  public :
70 
71  MatrixPastix();
72  ~MatrixPastix();
73 
74  bool UseInteger8() const;
75  void Clear();
76 
77  void HideMessages();
78  void ShowMessages();
79  void ShowFullHistory();
80 
81  void SelectOrdering(int type);
82  void SetPermutation(const IVect& permut);
83  void SetCholeskyFacto(bool chol);
84 
85  void SetPivotThreshold(double);
86  void RefineSolution();
87  void DoNotRefineSolution();
88  size_t GetMemorySize() const;
89  int GetInfoFactorization() const;
90 
91  template<class T0, class Prop, class Storage, class Allocator, class Tint>
93  Vector<Tint>& numbers, bool keep_matrix = false);
94 
95  template<class T0, class Storage, class Allocator>
97  bool keep_matrix = false);
98 
99  void FactorizeCSC(Vector<pastix_int_t>& Ptr, Vector<pastix_int_t>& IndRow,
100  Vector<T>& Val, bool sym);
101 
102  template<class T0, class Storage, class Allocator>
104  bool keep_matrix = false);
105 
106  template<class Allocator2>
108 
109  template<class Allocator2>
110  void Solve(const SeldonTranspose& TransA,
112 
113  void Solve(const SeldonTranspose&, T* x_ptr, int nrhs);
114 
115  template<class Allocator2>
116  void Solve(const SeldonTranspose& TransA,
118 
119  template<class Allocator2>
120  void Mlt(const SeldonTranspose& TransA,
122 
123  void Mlt(const SeldonTranspose&, T* x_ptr, int nrhs);
124 
125  void SetNumberOfThreadPerNode(int);
126 
127  void FactorizeDistributedMatrix(MPI_Comm& comm_facto, Vector<long>& Ptr,
128  Vector<int>& IndRow, Vector<T>& Val,
129  const Vector<int>& glob_number,
130  bool sym, bool keep_matrix = false);
131 
132  void FactorizeDistributedMatrix(MPI_Comm& comm_facto, Vector<int64_t>& Ptr,
133  Vector<int64_t>& IndRow, Vector<T>& Val,
134  const Vector<int>& glob_number,
135  bool sym, bool keep_matrix = false);
136 
137  template<class Tint>
138  void FactorizeParallel(MPI_Comm& comm_facto,
140  Vector<T>&,
141  const Vector<int>& glob_num,
142  bool sym, bool keep_matrix = false);
143 
144  void FactorizeParallel(MPI_Comm& comm_facto,
147  Vector<T>&, const Vector<int>& glob_num,
148  bool sym, bool keep_matrix = false);
149 
150  template<class Allocator2>
151  void SolveDistributed(MPI_Comm& comm_facto,
152  const SeldonTranspose& TransA,
154  const Vector<int>& glob_num);
155 
156  template<class Allocator2>
157  void SolveDistributed(MPI_Comm& comm_facto,
158  const SeldonTranspose& TransA,
160  const Vector<int>& glob_num);
161 
162  void SolveDistributed(MPI_Comm& comm_facto,
163  const SeldonTranspose& TransA,
164  T* x_ptr, int nrhs,
165  const IVect& glob_num);
166 
167  template<class Allocator2>
168  void MltDistributed(MPI_Comm& comm_facto,
169  const SeldonTranspose& TransA,
171  const Vector<int>& glob_num);
172 
173  template<class Allocator2>
174  void MltDistributed(MPI_Comm& comm_facto,
175  const SeldonTranspose& TransA,
177  const Vector<int>& glob_num);
178 
179  void MltDistributed(MPI_Comm& comm_facto,
180  const SeldonTranspose& TransA,
181  T* x_ptr, int nrhs,
182  const IVect& glob_num);
183 
184 
185  };
186 
187  template<class T0, class Prop, class Storage, class Allocator, class T>
189  bool keep_matrix = false);
190 
191  template<class T, class Allocator>
192  void SolveLU(MatrixPastix<T>& mat_lu, Vector<T, VectFull, Allocator>& x);
193 
194  template<class T, class Allocator>
195  void SolveLU(const SeldonTranspose& TransA,
197 
198  template<class T, class Prop, class Allocator>
199  void SolveLU(MatrixPastix<T>& mat_lu,
201 
202  template<class T, class Prop, class Allocator>
203  void SolveLU(const SeldonTranspose& TransA,
205 
206  template<class Allocator>
207  void SolveLU(MatrixPastix<double>& mat_lu,
208  Vector<complex<double>, VectFull, Allocator>& x);
209 
210  template<class Allocator>
211  void SolveLU(const SeldonTranspose& TransA,
212  MatrixPastix<double>& mat_lu,
213  Vector<complex<double>, VectFull, Allocator>& x);
214 
215  template<class Allocator>
216  void SolveLU(MatrixPastix<complex<double> >& mat_lu,
218 
219  template<class Allocator>
220  void SolveLU(const SeldonTranspose& TransA,
221  MatrixPastix<complex<double> >& mat_lu,
223 
224  template<class T, class Prop, class Storage, class Allocator>
225  void GetCholesky(Matrix<T, Prop, Storage, Allocator>& A,
226  MatrixPastix<T>& mat_chol, bool keep_matrix = false);
227 
228  template<class T, class Allocator>
229  void
230  SolveCholesky(const SeldonTranspose& TransA,
232 
233  template<class T, class Allocator>
234  void
235  MltCholesky(const SeldonTranspose& TransA,
237 
238 }
239 
240 #define SELDON_FILE_PASTIX_HXX
241 #endif
242 
Seldon::MatrixPastix::GetMemorySize
size_t GetMemorySize() const
Returns the size of memory used by the factorisation in bytes.
Definition: Pastix.cxx:174
Seldon::MatrixPastix::n
pastix_int_t n
number of columns
Definition: Pastix.hxx:49
Seldon::MatrixPastix
Definition: Pastix.hxx:39
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::MatrixPastix::adjust_threshold_pivot
bool adjust_threshold_pivot
adjust threshold for static pivoting ?
Definition: Pastix.hxx:63
Seldon::MatrixPastix::MltDistributed
void MltDistributed(MPI_Comm &comm_facto, const SeldonTranspose &TransA, Vector< T, VectFull, Allocator2 > &x, const Vector< int > &glob_num)
computes L x or L^T x
Definition: Pastix.cxx:622
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::MatrixPastix::RefineSolution
void RefineSolution()
You can require that solution is refined after LU resolution.
Definition: Pastix.cxx:158
Seldon::MatrixPastix::SetCholeskyFacto
void SetCholeskyFacto(bool chol)
sets Cholesky factorisation
Definition: Pastix.cxx:141
Seldon::MatrixPastix::dparm
double dparm[DPARM_SIZE]
options (floats)
Definition: Pastix.hxx:47
Seldon::MatrixPastix::print_level
int print_level
level of display
Definition: Pastix.hxx:57
Seldon::MatrixPastix::Mlt
void Mlt(const SeldonTranspose &TransA, Vector< T, VectFull, Allocator2 > &x)
Computes x = L b or x = L^T b (A = L L^T)
Definition: Pastix.cxx:438
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::MatrixPastix::SetNumberOfThreadPerNode
void SetNumberOfThreadPerNode(int)
Modifies the number of threads per node.
Definition: Pastix.cxx:472
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::MatrixPastix::Solve
void Solve(Vector< T, VectFull, Allocator2 > &x)
solving A x = b (A is already factorized)
Definition: Pastix.cxx:360
Seldon::MatrixPastix::MatrixPastix
MatrixPastix()
Default constructor.
Definition: Pastix.cxx:28
Seldon::MatrixPastix::threshold_pivot
double threshold_pivot
threshold for static pivoting
Definition: Pastix.hxx:61
Seldon::MatrixPastix::SetPivotThreshold
void SetPivotThreshold(double)
you can change the threshold used for static pivoting
Definition: Pastix.cxx:149
Seldon::MatrixPastix::SetPermutation
void SetPermutation(const IVect &permut)
provides a permutation array (instead of using Scotch reordering)
Definition: Pastix.cxx:127
Seldon::MatrixPastix::ShowFullHistory
void ShowFullHistory()
Displaying all messages.
Definition: Pastix.cxx:111
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::MatrixPastix::Clear
void Clear()
Clearing factorization.
Definition: Pastix.cxx:80
Seldon::MatrixPastix::FactorizeMatrix
void FactorizeMatrix(Matrix< T0, General, Storage, Allocator > &mat, bool keep_matrix=false)
Factorization of unsymmetric matrix.
Definition: Pastix.cxx:223
Seldon::VirtualSparseDirectSolver
Base class for an interface with a direct solver.
Definition: SparseSolver.hxx:30
Seldon::MatrixPastix::distributed
bool distributed
if true, resolution on several nodes
Definition: Pastix.hxx:53
Seldon::MatrixPastix::FindOrdering
void FindOrdering(Matrix< T0, Prop, Storage, Allocator > &mat, Vector< Tint > &numbers, bool keep_matrix=false)
Returning ordering found by Scotch.
Definition: Pastix.cxx:197
Seldon::MatrixPastix::pastix_data
pastix_data_t * pastix_data
pastix structure
Definition: Pastix.hxx:43
Seldon::MatrixPastix::DoNotRefineSolution
void DoNotRefineSolution()
You can require that solution is not refined (faster).
Definition: Pastix.cxx:166
Seldon::MatrixPastix::SelectOrdering
void SelectOrdering(int type)
selects the algorithm used for reordering
Definition: Pastix.cxx:119
Seldon::MatrixPastix::cholesky
bool cholesky
if true, cholesky factorisation is computed
Definition: Pastix.hxx:55
Seldon::MatrixPastix::~MatrixPastix
~MatrixPastix()
destructor
Definition: Pastix.cxx:61
Seldon::MatrixPastix::ShowMessages
void ShowMessages()
Low level of display.
Definition: Pastix.cxx:103
Seldon::MatrixPastix::SolveDistributed
void SolveDistributed(MPI_Comm &comm_facto, const SeldonTranspose &TransA, Vector< T, VectFull, Allocator2 > &x, const Vector< int > &glob_num)
solves A x = b or A^T x = b in parallel
Definition: Pastix.cxx:561
Seldon::MatrixPastix::HideMessages
void HideMessages()
no message will be displayed
Definition: Pastix.cxx:95
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::MatrixPastix::iparm
pastix_int_t iparm[IPARM_SIZE]
options (integers)
Definition: Pastix.hxx:45
Seldon::MatrixPastix::refine_solution
bool refine_solution
if true, solution is refined
Definition: Pastix.hxx:59
Seldon::Matrix< T, Prop, ColMajor, Allocator >
Column-major full-matrix class.
Definition: Matrix_Pointers.hxx:176