UmfPack.hxx
1 // Copyright (C) 2003-2009 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_UMFPACK_HXX
21 
22 extern "C"
23 {
24 #include "umfpack.h"
25 #include "colamd.h"
26 #include "camd.h"
27 }
28 
29 #ifdef UMFPACK_INTSIZE64
30 #define umfpack_int_t SuiteSparse_long
31 #else
32 #define umfpack_int_t int
33 #endif
34 
35 
36 namespace Seldon
37 {
39  template<class T>
41  {
42  public :
43  Vector<double> Control, Info;
44  void *Symbolic, *Numeric ;
45  int n;
46  int print_level;
47  bool transpose;
49 
50  public :
52 
53  void HideMessages();
54  void ShowMessages();
55  void ShowFullHistory();
56  bool UseInteger8() const;
57 
58  int GetInfoFactorization() const;
59  size_t GetMemorySize() const;
60 
61  void SelectOrdering(int type);
62  void SetPermutation(const IVect&);
63  };
64 
66  template<class T>
68  {
69  };
70 
72  template<>
73  class MatrixUmfPack<double> : public MatrixUmfPack_Base<double>
74  {
75 
76  protected :
78  umfpack_int_t* ind_, *ptr_;
80  double* data_;
81 
82  public :
83 
84  MatrixUmfPack();
85  ~MatrixUmfPack();
86 
87  void Clear();
88 
89  template<class T0, class Prop, class Storage, class Allocator>
90  void FactorizeMatrix(Matrix<T0, Prop, Storage, Allocator> & mat,
91  bool keep_matrix = false);
92 
93  void FactorizeCSC(Vector<umfpack_int_t>& Ptr, Vector<umfpack_int_t>& IndRow,
94  Vector<double>& Val, bool sym);
95 
96  template<class Prop, class Allocator>
97  void PerformAnalysis(Matrix<double, Prop, RowSparse, Allocator> & mat);
98 
99  template<class Prop, class Allocator>
100  void
101  PerformFactorization(Matrix<double, Prop, RowSparse, Allocator> & mat);
102 
103  template<class Allocator2>
105 
106  template<class Allocator2>
108 
109  template<class Allocator2>
110  void Solve(const SeldonTranspose& TransA,
112 
113  void Solve(const SeldonTranspose& TransA, double* x_ptr, int nrhs);
114 
115  };
116 
117 
119  template<>
120  class MatrixUmfPack<complex<double> >
121  : public MatrixUmfPack_Base<complex<double> >
122  {
123 
124  protected:
126  umfpack_int_t* ptr_, *ind_;
128  double* data_real_, *data_imag_;
129 
130  public :
131 
132  MatrixUmfPack();
133  ~MatrixUmfPack();
134 
135  void Clear();
136 
137  template<class T0, class Prop, class Storage, class Allocator>
138  void
139  FactorizeMatrix(Matrix<T0, Prop, Storage, Allocator> & mat,
140  bool keep_matrix = false);
141 
142  void FactorizeCSC(Vector<umfpack_int_t>& Ptr, Vector<umfpack_int_t>& IndRow,
143  Vector<complex<double> >& Val, bool sym);
144 
145  template<class Allocator2>
146  void Solve(Vector<complex<double>, VectFull, Allocator2>& x);
147 
148  template<class Allocator2>
149  void Solve(const SeldonTranspose&, Vector<complex<double>, VectFull, Allocator2>& x);
150 
151  template<class Allocator2>
152  void Solve(const SeldonTranspose& TransA,
153  Matrix<complex<double>, General, ColMajor, Allocator2>& x);
154 
155  void Solve(const SeldonTranspose& TransA, complex<double>* x_ptr, int nrhs);
156 
157  };
158 
159  template<class T0, class Prop, class Storage, class Allocator, class T>
161  bool keep_matrix = false);
162 
163  template<class T, class Allocator>
164  void SolveLU(MatrixUmfPack<T>& mat_lu, Vector<T, VectFull, Allocator>& x);
165 
166  template<class T, class Allocator>
167  void SolveLU(const SeldonTranspose& TransA,
169 
170  template<class T, class Prop, class Allocator>
171  void SolveLU(MatrixUmfPack<T>& mat_lu,
173 
174  template<class T, class Prop, class Allocator>
175  void SolveLU(const SeldonTranspose& TransA,
177 
178  template<class Allocator>
179  void SolveLU(MatrixUmfPack<double>& mat_lu,
180  Vector<complex<double>, VectFull, Allocator>& x);
181 
182  template<class Allocator>
183  void SolveLU(const SeldonTranspose& TransA,
184  MatrixUmfPack<double>& mat_lu,
185  Vector<complex<double>, VectFull, Allocator>& x);
186 
187  template<class Allocator>
188  void SolveLU(MatrixUmfPack<complex<double> >& mat_lu,
190 
191  template<class Allocator>
192  void SolveLU(const SeldonTranspose& TransA,
193  MatrixUmfPack<complex<double> >& mat_lu,
195 
196 }
197 
198 #define SELDON_FILE_UMFPACK_HXX
199 #endif
Seldon::MatrixUmfPack_Base::status_facto
int status_facto
transpose system to solve ?
Definition: UmfPack.hxx:48
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::MatrixUmfPack< double >::ind_
umfpack_int_t * ind_
arrays containing matrix pattern in csc format
Definition: UmfPack.hxx:78
Seldon::Vector< double >
Seldon::MatrixUmfPack< double >::data_
double * data_
non-zero values
Definition: UmfPack.hxx:80
Seldon::MatrixUmfPack_Base
< base class to solve linear system by using UmfPack
Definition: UmfPack.hxx:40
Seldon::MatrixUmfPack< double >
class to solve linear system in double precision with UmfPack
Definition: UmfPack.hxx:73
Seldon::MatrixUmfPack
empty class
Definition: UmfPack.hxx:67
Seldon::MatrixUmfPack_Base::SelectOrdering
void SelectOrdering(int type)
selects ordering to use in the interfaced solver
Definition: UmfPack.cxx:106
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::VectFull
Definition: StorageInline.cxx:74
Seldon::MatrixUmfPack_Base::MatrixUmfPack_Base
MatrixUmfPack_Base()
constructor
Definition: UmfPack.cxx:29
Seldon::MatrixUmfPack_Base::Numeric
void * Numeric
pointers of UmfPack objects
Definition: UmfPack.hxx:44
Seldon::MatrixUmfPack< complex< double > >::data_real_
double * data_real_
non-zero values
Definition: UmfPack.hxx:128
Seldon::General
Definition: Properties.hxx:26
Seldon::MatrixUmfPack_Base::Info
Vector< double > Info
parameters for UmfPack
Definition: UmfPack.hxx:43
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::MatrixUmfPack_Base::n
int n
number of rows in the matrix
Definition: UmfPack.hxx:45
Seldon::VirtualSparseDirectSolver
Base class for an interface with a direct solver.
Definition: SparseSolver.hxx:30
Seldon::MatrixUmfPack< complex< double > >::ptr_
umfpack_int_t * ptr_
arrays containing matrix pattern in csc format
Definition: UmfPack.hxx:126
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::MatrixUmfPack_Base::HideMessages
void HideMessages()
no message will be displayed by UmfPack
Definition: UmfPack.cxx:49
Seldon::MatrixUmfPack_Base::ShowMessages
void ShowMessages()
normal amount of message displayed by UmfPack
Definition: UmfPack.cxx:58
Seldon::Matrix< T, Prop, ColMajor, Allocator >
Column-major full-matrix class.
Definition: Matrix_Pointers.hxx:176
Seldon::ColMajor
Definition: Storage.hxx:33