KASKADE 7 development version
Loading...
Searching...
No Matches
cgImplementation.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2002-2013 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef CG_IMPLEMENTATION_HH
14#define CG_IMPLEMENTATION_HH
15
16#include <cmath>
17#include <iostream>
18#include <limits>
19#include <memory>
20#include <string>
21#include <vector>
22
23#include "utilities/scalar.hh"
28#include "utilities/timing.hh"
29
30namespace Kaskade
31{
33
43 template <class Domain, class Range>
44 bool requiresInitializedInput(Dune::Preconditioner<Domain,Range> const* p)
45 {
46 if (dynamic_cast<Dune::Richardson<Domain,Range> const*>(p))
47 return false;
48 if (auto sp = dynamic_cast<SymmetricPreconditioner<Domain,Range> const*>(p))
49 return sp->requiresInitializedInput();
50 return true;
51 }
52
53 namespace CG_Detail
54 {
76 template <class Scalar>
77 void stev(char jobz, int n, Scalar* diag, Scalar* subdiag,
78 typename ScalarTraits<Scalar>::Real* w, Scalar* z = nullptr);
79
80 template <class X, class Xstar, class Derived>
82 {
84
85 Regularization(double eps_, int verbose_) : eps(eps_), verbose(verbose_)
86 {}
87
89 {
90 theta = 0;
91 }
92
93 void regularize(double& qAq, double qPq)
94 {
95 qAq += theta*qPq;
96 }
97
98 void updateRegularization(double qAq, double qPq)
99 {
100 double oldTheta = theta > 0 ? theta : eps;
101 theta += (1-qAq)/std::fabs(qPq);
102 if( verbose > 0 ) std::cout << "Regularization: Computed theta: " << theta << '\n';
103 theta = std::min(std::max(2*oldTheta,theta),1e2*oldTheta);
104 if( verbose > 0 )
105 std::cout << "Regularization: Updating theta from " << oldTheta << " to "
106 << theta << '\n';
107 }
108
109 void adjustResidual(Xstar& r, double alpha, Xstar const& Pq)
110 {
111 r.axpy(-alpha*theta,Pq);
112 }
113
114 Real theta = 0, eps = 1e-16;
115 int verbose = 0;
116 };
117
118 // ---------------------------------------------------------------------------------------------
119 // ---------------------------------------------------------------------------------------------
120
121 template <class X, class Xstar, class>
123 {
124 NoRegularization(double,int) {}
125
127 void regularize(double&, double) {}
128 void updateRegularization(double,double) {}
129 void adjustResidual(Xstar&,double,Xstar const&) {}
130
131 };
132
133 // ---------------------------------------------------------------------------------------------
134 // ---------------------------------------------------------------------------------------------
135
136 template <class X, class Xstar, class Derived, CGImplementationType impl>
145 }
146
147
158 {
160
166
167 void stopCGTimer() {}
168 void stopMVTimer() {}
169 void stopDPTimer() {}
170 void stopAPTimer() {}
171 void stopPRTimer() {}
172
173 void printTimers() {}
174 };
175
176 // -----------------------------------------------------------------------------------------------
177 // -----------------------------------------------------------------------------------------------
178
194 {
195 MeasureTime(Timings& timer_ = Timings::instance()) : timer(&timer_) {}
196
197 void resumeCGTimer() { timer->start("CG solver"); }
198 void resumeMVTimer() { timer->start("CG matrix-vector product"); }
199 void resumeDPTimer() { timer->start("CG dual pairings"); }
200 void resumeAPTimer() { timer->start("CG vector ops"); }
201 void resumePRTimer() { timer->start("CG preconditioner"); }
202
203 void stopCGTimer() { timer->stop("CG solver"); }
204 void stopMVTimer() { timer->stop("CG matrix-vector product"); }
205 void stopDPTimer() { timer->stop("CG dual pairings"); }
206 void stopAPTimer() { timer->stop("CG vector ops"); }
207 void stopPRTimer() { timer->stop("CG preconditioner"); }
208
209 void printTimers() { timer->report(std::cout); }
210
211 private:
212 Timings* timer;
213 };
214
216 {
217 template <typename... Args>
218 void init(const Args&...){}
219
220 double operator()() { return 1; }
221 };
222
223 // -----------------------------------------------------------------------------------------------
224 // -----------------------------------------------------------------------------------------------
225
227 {
228 CGFminModel() = default;
229 CGFminModel(CGFminModel const&) = default;
231
232 CGFminModel(double quadraticPart_, double linearPart_, double omegaL_,
233 double dndn_, double dnd_, double dd_)
234 : linearPart(linearPart_), quadraticPart(quadraticPart_), omegaL(omegaL_),
235 dndn(dndn_), dnd(dnd_), dd(dd_)
236 {}
237
238 double operator()(double t)
239 {
240 double normSquared = dndn + t*dnd + t*t*dd;
241 return t*linearPart + 0.5*t*t*quadraticPart + pow(normSquared,1.5);
242 }
243
244 double linearPart = 0, quadraticPart = 0, omegaL = 0, dndn = 0, dnd = 0, dd = 0;
245 };
246
247 // -----------------------------------------------------------------------------------------------
248 // -----------------------------------------------------------------------------------------------
249
278 template<class X, class Xstar, CGImplementationType impl = CGImplementationType::STANDARD,
279 class TimerPolicy = DoNotMeasureTime, class Functor = DoNotAlwaysRegularize>
280 class CGBase
281 : public Dune::InverseOperator<X,Xstar>
282 , public TimerPolicy
283 , public CG_Detail::ChooseRegularization<X,Xstar,CGBase<X,Xstar,impl,TimerPolicy>,impl>::type
284 {
285 enum class Result { Converged, Failed, EncounteredNonConvexity, TruncatedAtNonConvexity };
286
287 public:
289 typedef X domain_type;
291 typedef Xstar range_type;
293 typedef typename X::field_type field_type;
294
299
316 int verbose_ = 0, double eps_ = 1e-15,
317 Timings& timer_ = Timings::instance())
318 : TimerPolicy(timer_),
319 CG_Detail::ChooseRegularization<X,Xstar,CGBase<X,Xstar,impl,TimerPolicy>,impl>::type(
320 eps_,verbose_),
321 proxyOp(op_,zeroDp), op(op_),
322 proxyPrec(prec_,zeroDp), prec(prec_),
323 terminate(terminate_), verbose(verbose_), eps(eps_),
324 requiresInit(requiresInitializedInput(&prec))
325 { }
326
340 CGBase(Dune::LinearOperator<X,Xstar>& op_,
341 Dune::Preconditioner<X,Xstar>& prec_,
342 DualPairing<X,Xstar> const& dp_,
344 int verbose_ = 0, double eps_ = 1e-15,
345 Timings& timer_ = Timings::instance())
346 : TimerPolicy(timer_),
347 CG_Detail::ChooseRegularization<X,Xstar,CGBase<X,Xstar,impl,TimerPolicy>,impl>::type(
348 eps_,verbose_),
349 proxyOp(op_,dp_), op(proxyOp),
350 proxyPrec(prec_,dp_), prec(proxyPrec),
351 terminate(terminate_), verbose(verbose_), eps(eps_),
352 requiresInit(requiresInitializedInput(&prec))
353 { }
354
369 CGBase(Dune::LinearOperator<X,Xstar>& op_,
370 Dune::Preconditioner<X,Xstar>& prec_,
371 DualPairing<X,Xstar> const& dp_,
373 Functor f_,
374 int verbose_ = 0, double eps_ = 1e-15,
375 Timings& timer_ = Timings::instance())
376 : TimerPolicy(timer_),
377 CG_Detail::ChooseRegularization<X,Xstar,CGBase<X,Xstar,impl,TimerPolicy>,impl>::type(
378 eps_,verbose_),
379 proxyOp(op_,dp_), op(proxyOp),
380 proxyPrec(prec_,dp_), prec(proxyPrec),
381 terminate(terminate_), verbose(verbose_), eps(eps_),
382 requiresInit(requiresInitializedInput(&prec)), f(f_)
383 { }
384
385 void apply (X& u, Xstar& b)
386 {
387 Dune::InverseOperatorResult res;
388 apply(u,b,res);
389 }
390
397 virtual void apply(X& u, Xstar&b, Real tolerance, Dune::InverseOperatorResult& res)
398 {
399 terminate.tolerance(tolerance);
400 apply(u,b,res);
401 }
402
403 virtual void apply(X& u, Xstar& b, Dune::InverseOperatorResult& res)
404 {
405 int step = 0;
407 step = cgLoop(u,b,res);
408 else
409 {
410 X u0(u);
411 Xstar b0(b);
412 result = Result::Failed;
413 while( result != Result::Converged && result != Result::TruncatedAtNonConvexity )
414 {
415 u = u0;
416 b = b0;
417 step = cgLoop(u,b,res);
418 }
419 }
420
421 if (verbose>0) // final print
422 {
423 std::cout << "=== rate=" << res.conv_rate
424 << ", T=" << res.elapsed
425 << ", TIT=" << res.elapsed/step
426 << ", IT=" << step << '\n';
427
428 this->printTimers();
429 }
430 }
431
432 int cgLoop (X& u, Xstar& b, Dune::InverseOperatorResult& res)
433 {
434 Dune::Timer watch;
435 this->resumeCGTimer();
436 terminate.clear(); // clear termination criterion
437 alphas.clear();
438 betas.clear();
439
440 result = Result::Failed;
441 res.converged = false;
442 prec.pre(u,b);
443
444 int step = 0;
445 const int maxNoiterations=terminate.getMaxIterationSteps();
446
447 Xstar r(b);
448 this->resumeMVTimer();
449 op.applyscaleadd(-1,u,r); // r = b-Au
450 this->stopMVTimer();
451 std::unique_ptr<X> rq(new X(u)); *rq = 0;
452
453 this->resumePRTimer();
454 if (requiresInit)
455 *rq = 0;
456 prec.apply(*rq,r); // rq = B^{-1} r
457 this->stopPRTimer();
458 std::unique_ptr<X> q(new X(*rq));
459 Xstar Aq(b);
460
461 Xstar Pq(r);
462
463 // some local variables
464 Real alpha = 0, beta = 0;
465 energyNorm2 = 0;
466 this->resumeDPTimer();
467 Real sigma = std::abs(op.dp(*rq,r)); // preconditioned residual norm squared
468 this->stopDPTimer();
469 terminate.residual(Real(sigma));
470 double const sigma0 = sigma;
471
472 if (verbose>0) { // printing
473 std::cout << "=== Kaskade7 IterateType::CG" << '\n';
474 if (verbose>0) {
475 this->printHeader(std::cout);
476 this->printOutput(std::cout,(double)0,sigma0);
477 }
478 }
479
480 // monitor proposal for initial theta
481 if(!std::is_same<Functor,DoNotAlwaysRegularize>::value)
482 {
483 f.init(op,b,*q,op);
484 double tau = f();
485 Xstar Hd(b);
486 op.apply(*q,Hd);
487 double dHd = op.dp(*q,Hd);
488
489 double initialThetaGuess = 1./tau - dHd/sigma;
490 std::cout << "CG: TAU = " << tau << '\n';
491 std::cout << "CG: INITIAL GUESS FOR THETA = " << initialThetaGuess << '\n';
492 }
493
494 // the loop
495 for ( step = 1; step<=maxNoiterations; step++ )
496 {
497 // minimize in given search direction p
498 this->resumeMVTimer();
499 field_type qAq = op.applyDp(*q,Aq); // compute Aq = A*q and qAq = <q,A*q>
500 this->stopMVTimer();
501
502 if (std::isnan(qAq)) std::cerr << "qAq is nan\n";
503
504 this->resumeDPTimer();
505 field_type qPq = op.dp(*q,Pq);
506 this->stopDPTimer();
507 this->regularize(qAq,qPq);
508
509 alpha = sigma/qAq;
510 energyNorm2 += alpha*qAq;
511 alphas.push_back(alpha);
512
513 // don't trust small numbers
514 if( std::fabs(qAq) < eps*eps )
515 {
516 if( verbose > 0 )
517 std::cout << pre << "Terminating due to numerically almost vanishing step."
518 << '\n';
519 result = Result::Converged;
520 res.converged = true;
521 break;
522 }
523
524 if( qAq <= 0 )
525 {
527 {
528 std::cout << pre << "Direction of negative curvature encountered in standard "
529 << "IterateType::CG implementation!" << '\n';
530 std::cout << pre << "Either something is wrong with your operator or you should use "
531 << "TCG, RCG or HCG. Terminating IterateType::CG!" << '\n';
532// result = Result::EncounteredNonConvexity;
533// break;
534 }
535
537 ( impl == CGImplementationType::HYBRID && terminate.minimalDecreaseAchieved() ) )
538 {
539 // At least do something to retain a little chance to get out of the nonconvexity.
540 // In fact if a nonconvexity is encountered in the first step something probably
541 // went wrong elsewhere. Chances that a way out of the nonconvexity can be found
542 // are small in this case.
543 if( step == 1 ) u.axpy(1.0,*q);
544 if( verbose > 0 )
545 std::cout << pre << "Truncating at nonconvexity in iteration "
546 << step << ": " << qAq << '\n';
547 result = Result::TruncatedAtNonConvexity;
548 break;
549 }
550
552 {
553 this->updateRegularization(qAq,qPq);
554 if( verbose > 0 )
555 std::cout << pre << "Regularizing at nonconvexity in iteration "
556 << step << "." << '\n';
557 result = Result::EncounteredNonConvexity;
558 break;
559 }
560 }
561
562 this->resumeAPTimer();
563 u.axpy(alpha,*q);
564 this->stopAPTimer();
565
566 terminate.step(Real(sigma*alpha));
567 terminate.stepDetail(Real(alpha), Real(qAq), Real(qPq), Real(sigma));
568
569 // convergence test
570 if (terminate)
571 {
572 result = Result::Converged;
573 res.converged = true;
574 break;
575 }
576
577 this->resumeAPTimer();
578 r.axpy(-alpha,Aq); // r = r - alpha*A*q
579 this->adjustResidual(r,alpha,Pq);
580 this->stopAPTimer();
581
582 this->resumePRTimer();
583 if (requiresInit)
584 *rq = 0;
585 field_type sigmaNew = prec.applyDp(*rq,r); // rq = B^{-1}r and sigma(new) = <rq,r>
586 // = <r,B^{-1}r>
587 this->stopPRTimer();
588 terminate.residual(Real(sigmaNew));
589
590 if (verbose>1) this->printOutput(std::cout,(double)step,std::abs(sigmaNew),std::abs(sigma));
591
592 // determine new search direction
593 if (std::abs(sigmaNew) < 1e-28*sigma0)
594 {
595 if( verbose > 0 )
596 std::cout << pre << "Convergence due to vanishing residual." << '\n';
597 result = Result::Converged;
598 res.converged = true;
599 break;
600 }
601
602 beta = sigmaNew/sigma;
603 betas.push_back(beta);
604 sigma = sigmaNew;
605 this->resumeAPTimer();
606 rq->axpy(beta,*q); // compute q = rq + beta*q
607 std::swap(rq,q);
608 this->stopAPTimer();
609 Pq *= beta;
610 Pq += r;
611 }
612
613 prec.post(u);
614
615 if (verbose>0) this->printOutput(std::cout,(double)step,std::abs(sigma));
616 res.iterations = step; // fill statistics
617 res.reduction = std::sqrt(std::abs(sigma)/sigma0);
618 res.conv_rate = pow(res.reduction,1.0/step);
619 res.elapsed = watch.elapsed();
620
621 this->stopCGTimer();
622 return step;
623 }
624
626 {
627 return result==Result::EncounteredNonConvexity || result==Result::TruncatedAtNonConvexity;
628 }
629
630 double getSolutionEnergyNormEstimate() { return sqrt(energyNorm2); }
631
638 virtual Dune::SolverCategory::Category category() const override
639 {
640 return Dune::SolverCategory::sequential;
641 }
642
676 Real cond(Real* kappaUpper = nullptr) const
677 {
679 throw LinearAlgebraException("cond() is only defined for the STANDARD CG implementation.",
680 __FILE__, __LINE__);
681
682 // The condition estimate needs at least two steps to yield a meaningful interval.
683 // With a single step there is only one Ritz value, and the quotient would be trivially 1.
684 if (alphas.size() < 2)
685 throw LinearAlgebraException("cond() needs at least two CG iterations.", __FILE__, __LINE__);
686
687 int const k = alphas.size();
688
689 // Build the tridiagonal matrix T_k from the CG coefficients (see the class doc above).
690 std::vector<Real> diag(k);
691 std::vector<Real> subdiag(k-1);
692 for (int i=0; i<k; ++i)
693 {
694 Real d = 1/alphas[i];
695 if (i>0)
696 {
697 d += betas[i-1]/alphas[i-1];
698 subdiag[i-1] = std::sqrt(betas[i-1])/alphas[i-1];
699 }
700 diag[i] = d;
701 }
702
703 // Compute the eigenvalues (ascending) of the symmetric tridiagonal matrix via LAPACK.
704 // If the upper bound is requested we need the eigenvectors of T_k as well (for the last
705 // components of the extremal Ritz vectors), so a single stev run with jobz='V' serves
706 // both purposes; otherwise eigenvalues only suffice.
707 std::vector<Real> w(k);
708 std::vector<Real> z;
709 if (kappaUpper)
710 {
711 z.resize(k*k);
712 CG_Detail::stev('V', k, diag.data(), subdiag.data(), w.data(), z.data());
713 }
714 else
715 CG_Detail::stev('N', k, diag.data(), subdiag.data(), w.data());
716
717 Real lambdaMax = w.back();
718 Real lambdaMin = w.front();
719 if (lambdaMin <= 0)
720 throw LinearAlgebraException("cond(): nonpositive minimal Ritz value.", __FILE__, __LINE__);
721
722 Real kappa = lambdaMax/lambdaMin;
723
724 // Residual-based upper bound on the extremal eigenvalues (Saad, "Iterative Methods for
725 // Sparse Linear Systems", Thm 6.6): the distance of an approximate eigenvalue theta_j with
726 // Ritz vector y_j = V_k u_j (u_j a unit eigenvector of T_k) to the exact spectrum is
727 // bounded by the last Lanczos element beta_k times the last component of u_j,
728 // dist(theta_j, spec(B^{-1}A)) <= beta_k * |u_j^{(k)}|,
729 // where beta_k is the last subdiagonal entry of T_k. We apply this to the extremal Ritz
730 // values (j = 1 and j = k).
731 if (kappaUpper)
732 {
733 // The eigenvector of the largest eigenvalue is the k-th column of z, of the smallest
734 // the first column. With column-major storage, column j occupies z[j*k ... j*k+k-1],
735 // so the last component of column j is z[j*k + k-1].
736 Real sMax = std::abs(z[(k-1)*k + (k-1)]);
737 Real sMin = std::abs(z[0*k + (k-1)]);
738 // The last Lanczos element beta_k = sqrt(betas[k-1])/alphas[k-2] is the last subdiagonal
739 // entry of T_k (the subdiagonal is destroyed by stev, so use the precomputed value).
740 Real betaK = std::sqrt(betas[k-2])/alphas[k-2];
741 // The Ritz values are computed with finite precision: the CG coefficients and the
742 // LAPACK dstev eigenvalues carry roundoff that can push an extremal Ritz value a tiny
743 // amount outside the exact spectrum (which the Saad bound does not account for). Add a
744 // small relative slack to the error terms so that the returned value is an upper bound
745 // in floating-point arithmetic as well. 1e-8 reflects double-precision roundoff scaled
746 // by the condition of the tridiagonal eigenproblem.
747 Real slack = 1 + 1e-8;
748 Real errMax = betaK * sMax * slack;
749 Real errMin = betaK * sMin * slack;
750 Real lambdaMaxUp = lambdaMax + errMax;
751 Real lambdaMinLo = lambdaMin - errMin;
752 if (lambdaMinLo <= 0)
753 *kappaUpper = std::numeric_limits<Real>::infinity();
754 else
755 *kappaUpper = lambdaMaxUp/lambdaMinLo;
756 }
757
758 return kappa;
759 }
760
761 private:
762 // The solver may be constructed with either symmetric operator/preconditioner interface
763 // provided, or with Dune interfaces provided. The implementation relies on the symmetric
764 // interface in order to exploit performance gains with simultaneous evaluation of
765 // matrix-vector products and dual pairings.
766 // Therefore we hold "working" references to symmetric operator/preconditioners. Those
767 // reference either the provided ones, or wrapper objects relaying the evaluation to
768 // provided Dune interfaces.
769 // For the second case, we hold the (small) wrapper objects ourselves. In the first case,
770 // those wrapper objects have to be initialized correctly (even though they are never
771 // accessed). For this we need a dual pairing, hence the dummy zeroDp.
772 ZeroDualPairing<X,Xstar> zeroDp; // just a dummy
773
774 SymmetricLinearOperatorWrapper<X,Xstar> proxyOp; // proxy in case a Dune::LinearOperator
775 // is provided
776 SymmetricLinearOperator<X,Xstar>& op; // working reference to operator
777
778 SymmetricPreconditionerWrapper<X,Xstar> proxyPrec; // proxy in case a Dune::Preconditioner
779 // is provided
780 SymmetricPreconditioner<X,Xstar>& prec; // working reference to preconditioner
781
783 int verbose;
784 double eps;
785 Result result;
786 bool requiresInit;
787 // CG coefficients gathered during the iteration, from which the Lanczos tridiagonal
788 // matrix of the preconditioned operator B^{-1}A is built for the condition estimate.
789 // alphas[i] = sigma_i/<q_i,A q_i>, betas[i] = sigma_{i+1}/sigma_i (i-th iteration step).
790 std::vector<Real> alphas;
791 std::vector<Real> betas;
792
793 double energyNorm2;
794 std::string pre = std::string("KASKADE IterateType::PCG: ");
795 Functor f;
796 };
797} // namespace Kaskade
798#endif
CGBase(Dune::LinearOperator< X, Xstar > &op_, Dune::Preconditioner< X, Xstar > &prec_, DualPairing< X, Xstar > const &dp_, PCGTerminationCriterion< Real > &terminate_, Functor f_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance())
Set up conjugate gradient solver with a functor for an initial regularization guess.
virtual void apply(X &u, Xstar &b, Real tolerance, Dune::InverseOperatorResult &res)
virtual Dune::SolverCategory::Category category() const override
returns the category of the operator
bool encounteredNonConvexity() const
virtual void apply(X &u, Xstar &b, Dune::InverseOperatorResult &res)
CGBase(SymmetricLinearOperator< X, Xstar > &op_, SymmetricPreconditioner< X, Xstar > &prec_, PCGTerminationCriterion< Real > &terminate_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance())
Set up conjugate gradient solver.
void apply(X &u, Xstar &b)
CGBase(Dune::LinearOperator< X, Xstar > &op_, Dune::Preconditioner< X, Xstar > &prec_, DualPairing< X, Xstar > const &dp_, PCGTerminationCriterion< Real > &terminate_, int verbose_=0, double eps_=1e-15, Timings &timer_=Timings::instance())
Set up conjugate gradient solver.
int cgLoop(X &u, Xstar &b, Dune::InverseOperatorResult &res)
Real cond(Real *kappaUpper=nullptr) const
Condition number estimate of the preconditioned system.
double getSolutionEnergyNormEstimate()
Abstract base class for dual pairing of and its dual space .
A base class for linear algebra exceptions.
Interface for IterateType::PCG termination criterion policy classes.
Helper class for working with (real or complex) scalar field types.
Definition scalar.hh:36
Scalar Real
The real type on which the scalar field is based.
Definition scalar.hh:49
Interface for symmetric linear operators.
Wrapper class to present (hopefully) symmetric linear operators in the SymmetricLinearOperator interf...
Interface for symmetric preconditioners.
Wrapper class presenting a symmetric preconditioner interface for any preconditioner.
Supports gathering and reporting execution times information for nested program parts.
Definition timing.hh:64
static Timings & instance()
Returns a reference to a single default instance.
Zero dual pairing implementation (mainly useful whenever a dual pairing is needed for formal language...
bool requiresInitializedInput(Dune::Preconditioner< Domain, Range > const *p)
Whether a preconditioner needs zero initialized result vector or not.
Dune::FieldMatrix< Entry, n, n > diag(Dune::FieldVector< Entry, n > const &d)
Creates a fixed-size diagonal matrix from the given diagonal vector.
void stev(char jobz, int n, Scalar *diag, Scalar *subdiag, typename ScalarTraits< Scalar >::Real *w, Scalar *z=nullptr)
Computes all eigenvalues (and optionally eigenvectors) of a symmetric tridiagonal matrix via LAPACK *...
std::conditional< impl==CGImplementationType::STANDARD||impl==CGImplementationType::TRUNCATED, NoRegularization< X, Xstar, Derived >, Regularization< X, Xstar, Derived > >::type type
void adjustResidual(Xstar &, double, Xstar const &)
ScalarTraits< typenameGetScalar< X >::type >::Real Real
void regularize(double &qAq, double qPq)
void updateRegularization(double qAq, double qPq)
void adjustResidual(Xstar &r, double alpha, Xstar const &Pq)
Regularization(double eps_, int verbose_)
CGFminModel & operator=(CGFminModel const &)=default
CGFminModel(double quadraticPart_, double linearPart_, double omegaL_, double dndn_, double dnd_, double dd_)
CGFminModel(CGFminModel const &)=default
double operator()(double t)
Timer policy that does not measure anything.
DoNotMeasureTime(Timings &=Timings::instance())
MeasureTime(Timings &timer_=Timings::instance())