LAMA
|
Uses matrix inverse to solve the equation system. More...
#include <InverseSolver.hpp>
Data Structures | |
struct | InverseSolverRuntime |
Public Member Functions | |
InverseSolver (const std::string &id) | |
Creates an InverseSolver with the specified id. | |
InverseSolver (const std::string &id, LoggerPtr logger) | |
Creates an InverseSolver with the specified id and logger. | |
InverseSolver (const InverseSolver &other) | |
Copy constructor that copies the status independent solver information. | |
virtual | ~InverseSolver () |
virtual void | initialize (const Matrix &coefficients) |
Initializes the solver by inverting and storing the given matrix. | |
virtual void | solveImpl () |
Solves the equation system with the given rhs and stores the result in the given vector. | |
virtual void | setContext (ContextPtr context) |
Sets the context where this solver should be executed. | |
void | computeInverse (Matrix &matrix) const |
virtual SolverPtr | copy () |
Copies the status independent solver informations to create a new instance of the same type. | |
virtual InverseSolverRuntime & | getRuntime () |
Returns the complete configuration of the derived class. | |
virtual const InverseSolverRuntime & | getConstRuntime () const |
Returns the complete const configuration of the derived class. | |
virtual void | solve (Vector &solution, const Vector &rhs) |
Solves the equation system based on the given rhs. | |
virtual void | solveInit (Vector &solution, const Vector &rhs) |
Initializes the solver with rhs and solution. | |
virtual void | solveFinalize () |
Finalizes the solving process. | |
const std::string & | getId () const |
Returns the ID of this solver. | |
const Vector & | getResidual () const |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this. | |
const Matrix & | getCoefficients () const |
Gets the matrix A from A*u=f. | |
void | setLogger (LoggerPtr logger) |
Redefines mLogger. | |
void | setLogLevel (LogLevel::LogLevel level) |
Switches the loglevel of mLogger. | |
Protected Member Functions | |
virtual void | writeAt (std::ostream &stream) const |
Overrides Printable::writeAt with more useful stuff. | |
Protected Attributes | |
InverseSolverRuntime | mInverseSolverRuntime |
std::string | mId |
The ID of this solver. | |
LoggerPtr | mLogger |
The solver logger. | |
ContextPtr | mContext |
For forcing the context solver dependent. | |
Private Member Functions | |
template<typename T > | |
void | invert (DenseMatrix< T > &matrix, IndexType *const permutation) const |
template<typename T > | |
void | decompose (DenseMatrix< T > &matrix, IndexType *const permutation) const |
void | logStartSolve () |
void | logEndSolve () |
LAMA_LOG_DECL_STATIC_LOGGER (logger) |
Uses matrix inverse to solve the equation system.
lama::InverseSolver::InverseSolver | ( | const std::string & | id | ) |
Creates an InverseSolver with the specified id.
[in] | id | The id of this solver |
Referenced by copy().
lama::InverseSolver::InverseSolver | ( | const std::string & | id, |
LoggerPtr | logger | ||
) |
Creates an InverseSolver with the specified id and logger.
[in] | id | The id of this solver |
[in] | logger | The logger used by this solver. |
lama::InverseSolver::InverseSolver | ( | const InverseSolver & | other | ) |
Copy constructor that copies the status independent solver information.
References lama::Solver::mId.
lama::InverseSolver::~InverseSolver | ( | ) | [virtual] |
void lama::InverseSolver::computeInverse | ( | Matrix & | matrix | ) | const |
References lama::Matrix::getNumRows(), invert(), and LAMA_THROWEXCEPTION.
SolverPtr lama::InverseSolver::copy | ( | ) | [virtual] |
Copies the status independent solver informations to create a new instance of the same type.
Implements lama::Solver.
References InverseSolver().
void lama::InverseSolver::decompose | ( | DenseMatrix< T > & | matrix, |
IndexType *const | permutation | ||
) | const [private] |
References lama::CblasRowMajor, lama::Matrix::getColDistribution(), lama::DenseStorageView< T >::getData(), lama::Distributed::getDistribution(), lama::DenseMatrix< T >::getLocalStorage(), lama::_MatrixStorage::getNumColumns(), lama::Matrix::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Matrix::getNumRows(), and LAMA_THROWEXCEPTION.
const Matrix & lama::Solver::getCoefficients | ( | ) | const [inherited] |
Gets the matrix A from A*u=f.
References lama::Solver::getConstRuntime(), LAMA_ASSERT_DEBUG, and lama::Solver::SolverRuntime::mCoefficients.
Referenced by invert(), and lama::LUSolver::piamax_own().
const InverseSolver::InverseSolverRuntime & lama::InverseSolver::getConstRuntime | ( | ) | const [virtual] |
Returns the complete const configuration of the derived class.
Implements lama::Solver.
References mInverseSolverRuntime.
const std::string & lama::Solver::getId | ( | ) | const [inherited] |
Returns the ID of this solver.
References lama::Solver::mId.
Referenced by lama::IterativeSolver::criteriaAreSatisfied(), lama::IterativeSolver::solveImpl(), and lama::SolverConfigGrammar::SolverConfigGrammar().
const Vector & lama::Solver::getResidual | ( | ) | const [inherited] |
Contingently calculates the current residual based on the coefficients, rhs and solution currently associated with this.
Should be used internally only, because the three vectors mentioned above have to be initialized.
References lama::LogLevel::completeInformation, lama::Vector::create(), lama::SolutionProxy::getConstReference(), lama::Solver::getConstRuntime(), lama::SolutionProxy::isDirty(), LAMA_ASSERT_DEBUG, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::mLogger, lama::Solver::SolverRuntime::mResidual, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, and lama::SolutionProxy::setDirty().
Referenced by lama::ResidualStagnation::isSatisfied(), lama::ResidualThreshold::isSatisfied(), lama::CG::iterate(), lama::GMRES::iterate(), and lama::Logger::logResidual().
InverseSolver::InverseSolverRuntime & lama::InverseSolver::getRuntime | ( | ) | [virtual] |
Returns the complete configuration of the derived class.
Implements lama::Solver.
References mInverseSolverRuntime.
Referenced by initialize(), setContext(), and solveImpl().
void lama::InverseSolver::initialize | ( | const Matrix & | coefficients | ) | [virtual] |
Initializes the solver by inverting and storing the given matrix.
[in] | The | matrix A from A*u=f. |
Reimplemented from lama::Solver.
References lama::Matrix::create(), lama::Matrix::getContextPtr(), getRuntime(), LAMA_REGION, and lama::InverseSolver::InverseSolverRuntime::mInverse.
void lama::InverseSolver::invert | ( | DenseMatrix< T > & | matrix, |
IndexType *const | permutation | ||
) | const [private] |
References lama::CblasRowMajor, lama::Solver::getCoefficients(), lama::Matrix::getColDistribution(), lama::Matrix::getContextPtr(), lama::DenseStorageView< T >::getData(), lama::Distributed::getDistribution(), lama::LAMAInterfaceRegistry::getInterface(), lama::LAMAInterface::getLAPACKInterface(), lama::DenseMatrix< T >::getLocalStorage(), lama::_MatrixStorage::getNumColumns(), lama::Matrix::getNumColumns(), lama::_MatrixStorage::getNumRows(), lama::Matrix::getNumRows(), lama::LAMAInterfaceRegistry::getRegistry(), LAMA_REGION, and LAMA_THROWEXCEPTION.
Referenced by computeInverse().
lama::InverseSolver::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
Reimplemented from lama::Solver.
void lama::InverseSolver::logEndSolve | ( | ) | [private] |
References lama::LogLevel::convergenceHistory, lama::l2Norm(), lama::Solver::mLogger, and lama::LogLevel::solverInformation.
Referenced by solveImpl().
void lama::InverseSolver::logStartSolve | ( | ) | [private] |
References lama::Solver::mLogger.
Referenced by solveImpl().
void lama::InverseSolver::setContext | ( | ContextPtr | context | ) | [virtual] |
Sets the context where this solver should be executed.
Sets the context where this solver should be executed. Caution: This overrides the context of the coefficients matrix A from A * u = f used to inializ this solver.
[in] | context | the context where this solver should be executed. |
Reimplemented from lama::Solver.
References getRuntime(), lama::Solver::mContext, and lama::InverseSolver::InverseSolverRuntime::mInverse.
void lama::Solver::setLogger | ( | LoggerPtr | logger | ) | [inherited] |
Redefines mLogger.
References lama::Solver::mLogger.
void lama::Solver::setLogLevel | ( | LogLevel::LogLevel | level | ) | [inherited] |
void lama::Solver::solve | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual, inherited] |
Solves the equation system based on the given rhs.
The solver needs to be initialized first with the matrix from the equation to solve, e.g. A from A*u=f (call solver::initialize(A) for example) This method is abstract. It has to be implemented by a class which inherits from this class.
rhs | The right hand side of A*u=f. |
solution | The solution from A*u=f. Mostly used as starting solution for an IterativeSolver. |
Reimplemented in lama::LUSolver, lama::DefaultJacobi, and lama::SpecializedJacobi.
References lama::Solver::getConstRuntime(), LAMA_REGION, lama::Solver::solveFinalize(), lama::Solver::solveImpl(), and lama::Solver::solveInit().
Referenced by lama::SimpleAMG::cycle().
void lama::Solver::solveFinalize | ( | ) | [virtual, inherited] |
Finalizes the solving process.
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
Referenced by lama::Solver::solve().
void lama::InverseSolver::solveImpl | ( | ) | [virtual] |
Solves the equation system with the given rhs and stores the result in the given vector.
Solves the equation system with the given rhs. Must be initialized first.
Implements lama::Solver.
References getRuntime(), LAMA_ASSERT_ERROR, LAMA_REGION, logEndSolve(), logStartSolve(), and lama::InverseSolver::InverseSolverRuntime::mInverse.
void lama::Solver::solveInit | ( | Vector & | solution, |
const Vector & | rhs | ||
) | [virtual, inherited] |
Initializes the solver with rhs and solution.
[in] | rhs | The right hand side of the system of equations |
[out] | solution | The allocated memory and starting solution for the system |
Reimplemented in lama::DefaultJacobi, and lama::SpecializedJacobi.
References lama::Matrix::getColDistribution(), lama::Distributed::getDistribution(), lama::Matrix::getNumColumns(), lama::Matrix::getNumRows(), lama::Solver::getRuntime(), LAMA_THROWEXCEPTION, lama::Solver::SolverRuntime::mCoefficients, lama::Solver::SolverRuntime::mRhs, lama::Solver::SolverRuntime::mSolution, lama::Solver::SolverRuntime::mSolveInit, and lama::Vector::size().
Referenced by lama::Solver::solve().
void lama::Solver::writeAt | ( | std::ostream & | stream | ) | const [protected, virtual, inherited] |
Overrides Printable::writeAt with more useful stuff.
Reimplemented from Printable.
References lama::Solver::mId.
ContextPtr lama::Solver::mContext [protected, inherited] |
For forcing the context solver dependent.
If the context for a solver is set, the context of the input matrix will be ignored
Referenced by lama::SpecializedJacobi::iterateTyped(), setContext(), and lama::Solver::setContext().
std::string lama::Solver::mId [protected, inherited] |
The ID of this solver.
Referenced by lama::Solver::getId(), InverseSolver(), lama::Solver::Solver(), lama::Solver::writeAt(), and lama::Solver::~Solver().
Referenced by getConstRuntime(), and getRuntime().
LoggerPtr lama::Solver::mLogger [protected, inherited] |
The solver logger.
May be the NullLogger if no logger has been specified.
Referenced by lama::Solver::getResidual(), lama::IterativeSolver::initialize(), lama::Solver::initialize(), logEndSolve(), lama::IterativeSolver::logEndSolve(), lama::IterativeSolver::logIterationEndAndResidual(), lama::IterativeSolver::logIterationStart(), lama::SimpleAMG::logSetupDetails(), lama::SimpleAMG::logSetupInfo(), lama::SimpleAMG::logSetupSettings(), lama::SimpleAMG::logSolverInfo(), logStartSolve(), lama::IterativeSolver::logStartSolve(), lama::MetaSolver::parseConfiguration(), lama::Solver::setLogger(), and lama::Solver::setLogLevel().