Loading...
Searching...
No Matches
solver_eigen.h
Go to the documentation of this file.
#ifndef _RHEOLEF_SOLVER_EIGEN_H
#define _RHEOLEF_SOLVER_EIGEN_H
// solver implementation: interface
//
#include "rheolef/config.h"
#ifdef _RHEOLEF_HAVE_EIGEN
#include "rheolef/solver.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <Eigen/Sparse>
#pragma GCC diagnostic pop
namespace rheolef {
// =======================================================================
// rep
// =======================================================================
template<class T, class M>
class solver_eigen_rep : public solver_abstract_rep<T,M> {
public:
// typedef:
typedef solver_abstract_rep<T,M> base;
typedef typename base::size_type size_type;
typedef typename base::determinant_type determinant_type;
// allocator:
explicit solver_eigen_rep (const csr<T,M>& a, const solver_option& opt = solver_option());
solver_eigen_rep (const solver_eigen_rep<T,M>&);
solver_abstract_rep<T,M>* clone() const;
void update_values (const csr<T,M>& a);
bool initialized() const { return true; }
// accessors:
vec<T,M> trans_solve (const vec<T,M>& rhs) const;
vec<T,M> solve (const vec<T,M>& rhs) const;
determinant_type det() const { return _det; }
protected:
// data:
csr<T,M> _a;
Eigen::SparseLU<Eigen::SparseMatrix<T,Eigen::ColMajor>, Eigen::COLAMDOrdering<int> >
_superlu_a;
Eigen::SimplicialLDLT<Eigen::SparseMatrix<T,Eigen::ColMajor>, Eigen::Lower, Eigen::AMDOrdering<int> >
_ldlt_a;
determinant_type _det;
};
// -----------------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------------
template<class T, class M>
inline
solver_eigen_rep<T,M>::solver_eigen_rep (const csr<T,M>& a, const solver_option& opt)
: solver_abstract_rep<T,M>(opt),
_a(a),
_superlu_a(),
_ldlt_a(),
_det()
{
update_values (a);
}
template<class T, class M>
inline
solver_eigen_rep<T,M>::solver_eigen_rep (const solver_eigen_rep<T,M>& x)
: solver_abstract_rep<T,M>(x.option()),
_a(x._a),
_superlu_a(),
_ldlt_a(),
_det()
{
// Eigen::SuperLU copy cstor is non-copyable, so re-initialize for a copy
update_values (_a);
}
template <class T, class M>
inline
solver_abstract_rep<T,M>*
solver_eigen_rep<T,M>::clone() const
{
typedef solver_eigen_rep<T,M> rep;
return new_macro (rep(*this));
}
} // namespace rheolef
#endif // _RHEOLEF_HAVE_EIGEN
#endif // _RHEOLEF_SOLVER_EIGEN_H
rheolef::csr
see the csr page for the full documentation
Definition csr.h:317
rheolef::solver_abstract_rep
Definition solver.h:191
rheolef::solver_abstract_rep::solver_abstract_rep
solver_abstract_rep(const solver_option &opt)
Definition solver.h:195
rheolef::solver_abstract_rep::option
const solver_option & option() const
Definition solver.h:197
rheolef::solver_abstract_rep::size_type
csr< T, M >::size_type size_type
Definition solver.h:193
rheolef::solver_eigen_rep::_a
csr< T, M > _a
Definition solver_eigen.h:66
rheolef::solver_eigen_rep::det
determinant_type det() const
Definition solver_eigen.h:62
rheolef::solver_eigen_rep::solver_eigen_rep
solver_eigen_rep(const csr< T, M > &a, const solver_option &opt=solver_option())
Definition solver_eigen.h:78
rheolef::solver_eigen_rep::update_values
void update_values(const csr< T, M > &a)
Definition solver_eigen.cc:42
rheolef::solver_eigen_rep::size_type
base::size_type size_type
Definition solver_eigen.h:47
rheolef::solver_eigen_rep::base
solver_abstract_rep< T, M > base
Definition solver_eigen.h:46
rheolef::solver_eigen_rep::determinant_type
base::determinant_type determinant_type
Definition solver_eigen.h:48
rheolef::solver_eigen_rep::_superlu_a
Eigen::SparseLU< Eigen::SparseMatrix< T, Eigen::ColMajor >, Eigen::COLAMDOrdering< int > > _superlu_a
Definition solver_eigen.h:68
rheolef::solver_eigen_rep::trans_solve
vec< T, M > trans_solve(const vec< T, M > &rhs) const
Definition solver_eigen.cc:101
rheolef::solver_eigen_rep::_ldlt_a
Eigen::SimplicialLDLT< Eigen::SparseMatrix< T, Eigen::ColMajor >, Eigen::Lower, Eigen::AMDOrdering< int > > _ldlt_a
Definition solver_eigen.h:70
rheolef::solver_eigen_rep::clone
solver_abstract_rep< T, M > * clone() const
Definition solver_eigen.h:102
rheolef::solver_eigen_rep::solve
vec< T, M > solve(const vec< T, M > &rhs) const
Definition solver_eigen.cc:85
rheolef::solver_eigen_rep::initialized
bool initialized() const
Definition solver_eigen.h:56
rheolef::solver_eigen_rep::_det
determinant_type _det
Definition solver_eigen.h:71
rheolef::solver_option
see the solver_option page for the full documentation
Definition solver_option.h:155
rheolef::vec
see the vec page for the full documentation
Definition vec.h:79
T
Expr1::float_type T
Definition field_expr.h:230
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::solver_abstract_rep::determinant_type
Definition solver.h:215
M
Expr1::memory_type M
Definition vec_expr_v2.h:416