3 #ifndef DUNE_ISTL_LDL_HH
4 #define DUNE_ISTL_LDL_HH
6 #if HAVE_SUITESPARSE_LDL || defined DOXYGEN
19 #include <dune/common/exceptions.hh>
20 #include <dune/common/unused.hh>
39 template<
class M,
class T,
class TM,
class TD,
class TA>
40 class SeqOverlappingSchwarz;
42 template<
class T,
bool tag>
43 struct SeqOverlappingSchwarzAssemblerHelper;
51 template<
class Matrix>
68 template<
typename T,
typename A,
int n,
int m>
70 :
public InverseOperator<BlockVector<FieldVector<T,m>, typename A::template rebind<FieldVector<T,m> >::other>,
71 BlockVector<FieldVector<T,n>, typename A::template rebind<FieldVector<T,n> >::other> >
89 return SolverCategory::Category::sequential;
101 LDL(
const Matrix& matrix,
int verbose=0) : matrixIsLoaded_(false), verbose_(verbose)
104 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
117 LDL(
const Matrix& matrix,
int verbose,
bool) : matrixIsLoaded_(false), verbose_(verbose)
120 static_assert(std::is_same<T,double>::value,
"Unsupported Type in LDL (only double supported)");
125 LDL() : matrixIsLoaded_(false), verbose_(0)
131 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
138 const int dimMat(ldlMatrix_.N());
139 ldl_perm(dimMat, Y_,
reinterpret_cast<double*
>(&b[0]), P_);
140 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
141 ldl_dsolve(dimMat, Y_, D_);
142 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
143 ldl_permt(dimMat,
reinterpret_cast<double*
>(&x[0]), Y_, P_);
152 DUNE_UNUSED_PARAMETER(reduction);
163 const int dimMat(ldlMatrix_.N());
164 ldl_perm(dimMat, Y_, b, P_);
165 ldl_lsolve(dimMat, Y_, Lp_, Li_, Lx_);
166 ldl_dsolve(dimMat, Y_, D_);
167 ldl_ltsolve(dimMat, Y_, Lp_, Li_, Lx_);
168 ldl_permt(dimMat, x, Y_, P_);
173 DUNE_UNUSED_PARAMETER(option);
174 DUNE_UNUSED_PARAMETER(value);
180 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
189 if ((ldlMatrix_.N() + ldlMatrix_.M() > 0) || matrixIsLoaded_)
191 ldlMatrix_.setMatrix(matrix,rowIndexSet);
227 matrixIsLoaded_ =
false;
273 template<
class M,
class X,
class TM,
class TD,
class T1>
282 const int dimMat(ldlMatrix_.N());
283 D_ =
new double [dimMat];
284 Y_ =
new double [dimMat];
285 Lp_ =
new int [dimMat + 1];
286 Parent_ =
new int [dimMat];
287 Lnz_ =
new int [dimMat];
288 Flag_ =
new int [dimMat];
289 Pattern_ =
new int [dimMat];
290 P_ =
new int [dimMat];
291 Pinv_ =
new int [dimMat];
293 double Info [AMD_INFO];
294 if(amd_order (dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), P_, (
double *) NULL, Info) < AMD_OK)
295 DUNE_THROW(InvalidStateException,
"Error: AMD failed!");
299 ldl_symbolic(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), Lp_, Parent_, Lnz_, Flag_, P_, Pinv_);
301 Lx_ =
new double [Lp_[dimMat]];
302 Li_ =
new int [Lp_[dimMat]];
304 const int rank(ldl_numeric(dimMat, ldlMatrix_.getColStart(), ldlMatrix_.getRowIndex(), ldlMatrix_.getValues(),
305 Lp_, Parent_, Lnz_, Li_, Lx_, D_, Y_, Pattern_, Flag_, P_, Pinv_));
313 DUNE_THROW(InvalidStateException,
"Error: LDL factorisation failed!");
316 LDLMatrix ldlMatrix_;
317 bool matrixIsLoaded_;
332 template<
typename T,
typename A,
int n,
int m>
338 template<
typename T,
typename A,
int n,
int m>
346 #endif //HAVE_SUITESPARSE_LDL
347 #endif //DUNE_ISTL_LDL_HH