3 #ifndef DUNE_SUPERLUMATRIX_HH
4 #define DUNE_SUPERLUMATRIX_HH
7 #ifdef SUPERLU_POST_2005_VERSION
10 #define SUPERLU_NTYPE 1
14 #include "slu_sdefs.h"
18 #include "slu_ddefs.h"
22 #include "slu_cdefs.h"
26 #include "slu_zdefs.h"
50 #include <dune/common/fmatrix.hh>
51 #include <dune/common/fvector.hh>
52 #include <dune/common/typetraits.hh>
72 static void create(SuperMatrix *
mat,
int n,
int m,
int offset,
73 float *values,
int *rowindex,
int* colindex,
74 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
76 sCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
84 static void print(
char* name, SuperMatrix*
mat)
86 sPrint_CompCol_Matrix(name, mat);
93 struct SuperMatrixCreateSparseChooser<double>
95 static void create(SuperMatrix *
mat,
int n,
int m,
int offset,
96 double *values,
int *rowindex,
int* colindex,
97 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
99 dCreate_CompCol_Matrix(mat, n, m, offset, values, rowindex, colindex,
100 stype, dtype, mtype);
105 struct SuperMatrixPrinter<double>
107 static void print(
char* name, SuperMatrix*
mat)
109 dPrint_CompCol_Matrix(name, mat);
116 struct SuperMatrixCreateSparseChooser<std::complex<float> >
118 static void create(SuperMatrix *
mat,
int n,
int m,
int offset,
119 std::complex<float> *values,
int *rowindex,
int* colindex,
120 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
122 cCreate_CompCol_Matrix(mat, n, m, offset, reinterpret_cast< ::complex*>(values),
123 rowindex, colindex, stype, dtype, mtype);
128 struct SuperMatrixPrinter<std::complex<float> >
130 static void print(
char* name, SuperMatrix*
mat)
132 cPrint_CompCol_Matrix(name, mat);
139 struct SuperMatrixCreateSparseChooser<std::complex<double> >
141 static void create(SuperMatrix *
mat,
int n,
int m,
int offset,
142 std::complex<double> *values,
int *rowindex,
int* colindex,
143 Stype_t stype, Dtype_t dtype, Mtype_t mtype)
145 zCreate_CompCol_Matrix(mat, n, m, offset, reinterpret_cast<doublecomplex*>(values),
146 rowindex, colindex, stype, dtype, mtype);
151 struct SuperMatrixPrinter<std::complex<double> >
153 static void print(
char* name, SuperMatrix*
mat)
155 zPrint_CompCol_Matrix(name, mat);
172 Dune::is_same<T,float>::value ? SLU_S :
173 ( Dune::is_same<T,std::complex<double> >::value ? SLU_Z :
174 ( Dune::is_same<T,std::complex<float> >::value ? SLU_C : SLU_D ));
223 template<
class B,
class TA,
int n,
int m>
227 template<
class M,
class X,
class TM,
class TD,
class T1>
251 if (this->N_+this->M_*this->Nnz_ != 0)
256 operator SuperMatrix&()
262 operator const SuperMatrix&()
const
271 ::create(&
A, this->N_, this->M_, this->colstart[this->N_],
272 this->values,this->rowindex, this->colstart, SLU_NC,
281 ::create(&
A, this->N_, this->M_, this->colstart[this->N_],
282 this->values,this->rowindex, this->colstart, SLU_NC,
293 virtual void setMatrix(
const Matrix&
mat,
const std::set<std::size_t>& mrs)
295 if(this->N_+this->M_+this->Nnz_!=0)
297 this->N_=mrs.size()*n;
298 this->M_=mrs.size()*m;
318 SUPERLU_FREE(
A.Store);
324 template<
class T,
class A,
int n,
int m>
328 template<
class I,
class S,
class D>
341 virtual void createMatrix()
const
345 ::create(&slumat->A, slumat->N_, slumat->M_, slumat->colstart[this->cols],
346 slumat->values,slumat->rowindex, slumat->colstart, SLU_NC,