13#ifndef DISCRETE_SOLVER_HH
14#define DISCRETE_SOLVER_HH
24#include <boost/timer/timer.hpp>
43 template <
class Scalar,
class SparseInt=
int>
58 boost::timer::cpu_timer timer;
70 if(
report && (
double)(timer.elapsed().user)/1e9 > 2.0) {
71 std::cout <<
"Factorization: " << (double)(timer.elapsed().user)/1e9 <<
" sec." << std::endl;
79 boost::timer::cpu_timer timer;
80 if(
report >= 2) std::cout <<
"Starting Substitution...";
81 std::vector<double> rhs;
83 factorization->solve(rhs,sol);
84 if(
report >=2) std::cout <<
"Finished: " << (double)(timer.elapsed().user)/1e9 <<
" sec." << std::endl;
106 if(factorization.get()!=
nullptr) factorization.reset();
112 std::string
const& solverName;
114 std::unique_ptr<Factorization<Scalar,SparseInt> > factorization;
Direct solver.Implements Direct Solver Interface of Algorithms.
bool improvementPossible()
void onChangedLinearization()
Do sth if linearization changed.
static const bool needMatrix
needs a matrix
void resolve(std::vector< double > &sol, SparseLinearSystem const &lin) const
solve a system again
void flushFactorization()
flush factorization
void setRelativeAccuracy(double)
Solves always exactly.
double getAbsoluteAccuracy()
Always exact solution.
void solve(std::vector< double > &sol, SparseLinearSystem &lin)
solve a system, keep factorization
double getRelativeAccuracy()
Always exact solution.
DirectLinearSolver(std::string const &solverName_, bool verbose=false)
default constructor
int report
Report of progress (0=no report, 1=brief, 2=verbose)
SparseIndexInt nrows() const
Returns number of rows (computes them, if not known)
std::vector< SparseIndexInt > ridx
row indices
std::vector< SparseIndexInt > cidx
column indices
std::vector< Scalar > data
data
Abstract base class for a sparse linear system.
virtual void getMatrix(MatrixAsTriplet< double > &mat) const
Return the matrix of the linear system in triplet format.
virtual void getRHS(std::vector< double > &rhs) const
Return the right hand side of the linear system.
Factorization of sparse linear systems with UMFPack.