89 klu_defaults(&Control);
91 if (dPivot != -1. && (dPivot >= 0. && dPivot <= 1.)) {
101 Control.ordering = 0;
108 Control.scale = scale;
112 KLUSolver::~KLUSolver(
void)
115 klu_free_symbolic(&Symbolic, &Control);
120 klu_free_numeric(&Numeric, &Control);
133 klu_free_symbolic(&Symbolic, &Control);
138 klu_free_numeric(&Numeric, &Control);
142 bHasBeenReset =
true;
146 KLUSolver::Solve(
void)
const
149 const_cast<KLUSolver *
>(
this)->
Factor();
150 bHasBeenReset =
false;
160 if (!ok || Control.status != KLU_OK) {
161 silent_cerr(
"KLUWRAP_solve failed" << std::endl);
165 klu_free_numeric(&Numeric, &Control);
175 KLUSolver::Factor(
void)
182 if (Symbolic == 0 && !bPrepareSymbolic()) {
188 ok = klu_refactor(App, Aip, Axp, Symbolic,
192 klu_free_numeric(&Numeric, &Control);
193 klu_free_symbolic(&Symbolic, &Control);
194 if (!bPrepareSymbolic()) {
201 Numeric = klu_factor(App, Aip, Axp, Symbolic,
205 if (Control.status != KLU_OK) {
206 silent_cerr(
"KLUWRAP_numeric failed" << std::endl);
210 klu_free_symbolic(&Symbolic, &Control);
213 klu_free_numeric(&Numeric, &Control);
224 std::vector<doublereal>& Ax,
225 std::vector<integer>& Ai,
226 std::vector<integer>& Ac,
227 std::vector<integer>& Ap)
const
229 if (!bHasBeenReset) {
241 KLUSolver::bPrepareSymbolic(
void)
243 Symbolic = klu_analyze(iSize, App, Aip, &Control);
244 if (Control.status != KLU_OK) {
245 silent_cerr(
"KLUWRAP_symbolic failed" << std::endl);
249 klu_free_symbolic(&Symbolic, &Control);
259 bool KLUSolver::bGetConditionNumber(
doublereal& dCond)
261 if (Symbolic == 0 || Numeric == 0) {
265 const bool bOK = klu_condest(App, Axp, Symbolic, Numeric, &Control);
267 dCond = Control.condest;
276 KLUSparseSolutionManager::KLUSparseSolutionManager(
integer Dim,
285 KLUSolver::Scale kscale = KLUSolver::SCALE_UNDEF;
287 switch (scale.algorithm) {
289 scale.when = SCALEW_NEVER;
293 kscale = KLUSolver::SCALE_NONE;
294 scale.when = SCALEW_NEVER;
298 kscale = KLUSolver::SCALE_MAX;
299 scale.when = SCALEW_NEVER;
303 kscale = KLUSolver::SCALE_SUM;
304 scale.when = SCALEW_NEVER;
309 kscale = KLUSolver::SCALE_NONE;
313 KLUSolver(Dim, dPivot, kscale));
315 (void)pLS->pdSetResVec(&b[0]);
316 (void)pLS->pdSetSolVec(&b[0]);
317 pLS->SetSolutionManager(
this);
321 KLUSparseSolutionManager::~KLUSparseSolutionManager(
void)
327 KLUSparseSolutionManager::MatrReset(
void)
333 KLUSparseSolutionManager::MakeCompressedColumnForm(
void)
335 ScaleMatrixAndRightHandSide(A);
337 pLS->MakeCompactForm(A, Ax, Ai, Adummy, Ap);
340 template <
typename MH>
341 void KLUSparseSolutionManager::ScaleMatrixAndRightHandSide(MH& mh)
343 if (scale.when != SCALEW_NEVER) {
356 rMatScale.
Report(std::cerr);
364 template <
typename MH>
367 if (pMatScale == 0) {
375 void KLUSparseSolutionManager::ScaleSolution(
void)
377 if (scale.when != SCALEW_NEVER) {
380 pMatScale->ScaleSolution(bVH);
386 KLUSparseSolutionManager::Solve(
void)
388 MakeCompressedColumnForm();
397 KLUSparseSolutionManager::pMatHdl(
void)
const
404 KLUSparseSolutionManager::pResHdl(
void)
const
411 KLUSparseSolutionManager::pSolHdl(
void)
const
419 KLUSparseCCSolutionManager<CC>::KLUSparseCCSolutionManager(
integer Dim,
421 const ScaleOpt& scale)
422 : KLUSparseSolutionManager(Dim, dPivot, scale),
430 KLUSparseCCSolutionManager<CC>::~KLUSparseCCSolutionManager(
void)
439 KLUSparseCCSolutionManager<CC>::MatrReset(
void)
446 KLUSparseCCSolutionManager<CC>::MakeCompressedColumnForm(
void)
449 pLS->MakeCompactForm(A, Ax, Ai, Adummy, Ap);
458 ScaleMatrixAndRightHandSide(*Ac);
465 KLUSparseCCSolutionManager<CC>::MatrInitialize()
484 KLUSparseCCSolutionManager<CC>::pMatHdl(
void)
const
494 template class KLUSparseCCSolutionManager<CColMatrixHandler<0> >;
495 template class KLUSparseCCSolutionManager<DirCColMatrixHandler<0> >;
virtual integer MakeCompressedColumnForm(doublereal *const Ax, integer *const Ai, integer *const Ap, int offset=0) const =0
#define MBDYN_EXCEPT_ARGS
bool bGetInitialized() const
bool ComputeScaleFactors(const T &mh)
std::ostream & Report(std::ostream &os) const
void Reset(scalar_func_type &d)
VectorHandler & ScaleRightHandSide(VectorHandler &bVH) const
#define ASSERT(expression)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
static MatrixScale< T > * Allocate(const SolutionManager::ScaleOpt &scale)
T & ScaleMatrix(T &mh) const