solver_cholmod.h
Go to the documentation of this file.
#ifndef _RHEOLEF_SOLVER_CHOLMOD_H
#define _RHEOLEF_SOLVER_CHOLMOD_H
// solver implementation: interface
//
#include "rheolef/solver.h"
#if defined(_RHEOLEF_HAVE_CHOLMOD)
#include <suitesparse/cholmod.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <Eigen/Sparse>
#include <Eigen/src/CholmodSupport/CholmodSupport.h>
#pragma GCC diagnostic pop
namespace rheolef {
// =======================================================================
// rep
// =======================================================================
template<class T, class M>
class solver_cholmod_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_cholmod_rep (const csr<T,M>& a, const solver_option& opt = solver_option());
solver_cholmod_rep (const solver_cholmod_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::CholmodDecomposition<Eigen::SparseMatrix<double> >
_llt_a;
determinant_type _det;
};
// -----------------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------------
template<class T, class M>
inline
solver_cholmod_rep<T,M>::solver_cholmod_rep (const csr<T,M>& a, const solver_option& opt)
: solver_abstract_rep<T,M>(opt),
_a(a),
_llt_a(),
_det()
{
update_values (a);
}
template<class T, class M>
inline
solver_cholmod_rep<T,M>::solver_cholmod_rep (const solver_cholmod_rep<T,M>& x)
: solver_abstract_rep<T,M>(x.option()),
_a(x._a),
_llt_a(),
_det()
{
// Eigen::CholmodSupernodalLLT 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_cholmod_rep<T,M>::clone() const
{
typedef solver_cholmod_rep<T,M> rep;
return new_macro (rep(*this));
}
} // namespace rheolef
#endif // _RHEOLEF_HAVE_CHOLMOD
#endif // _RHEOLEF_SOLVER_CHOLMOD_H
rheolef::csr< T, M >
rheolef::solver_abstract_rep
Definition: solver.h:191
rheolef::solver_abstract_rep::size_type
csr< T, M >::size_type size_type
Definition: solver.h:193
rheolef::solver_cholmod_rep
Definition: solver_cholmod.h:40
rheolef::solver_cholmod_rep::_a
csr< T, M > _a
Definition: solver_cholmod.h:64
rheolef::solver_cholmod_rep::det
determinant_type det() const
Definition: solver_cholmod.h:60
rheolef::solver_cholmod_rep::solver_cholmod_rep
solver_cholmod_rep(const csr< T, M > &a, const solver_option &opt=solver_option())
Definition: solver_cholmod.h:74
rheolef::solver_cholmod_rep::_llt_a
Eigen::CholmodDecomposition< Eigen::SparseMatrix< double > > _llt_a
Definition: solver_cholmod.h:66
rheolef::solver_cholmod_rep::update_values
void update_values(const csr< T, M > &a)
Definition: solver_cholmod.cc:35
rheolef::solver_cholmod_rep::size_type
base::size_type size_type
Definition: solver_cholmod.h:45
rheolef::solver_cholmod_rep::base
solver_abstract_rep< T, M > base
Definition: solver_cholmod.h:44
rheolef::solver_cholmod_rep::determinant_type
base::determinant_type determinant_type
Definition: solver_cholmod.h:46
rheolef::solver_cholmod_rep::trans_solve
vec< T, M > trans_solve(const vec< T, M > &rhs) const
Definition: solver_cholmod.cc:81
rheolef::solver_cholmod_rep::clone
solver_abstract_rep< T, M > * clone() const
Definition: solver_cholmod.h:96
rheolef::solver_cholmod_rep::solve
vec< T, M > solve(const vec< T, M > &rhs) const
Definition: solver_cholmod.cc:69
rheolef::solver_cholmod_rep::initialized
bool initialized() const
Definition: solver_cholmod.h:54
rheolef::solver_cholmod_rep::_det
determinant_type _det
Definition: solver_cholmod.h:67
rheolef::solver_option
see the solver_option page for the full documentation
Definition: solver_option.h:155
rheolef::vec< T, M >
T
Expr1::float_type T
Definition: field_expr.h:261
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
a
Definition: diffusion_isotropic.h:25
rheolef::solver_abstract_rep::determinant_type
Definition: solver.h:215
M
Expr1::memory_type M
Definition: vec_expr_v2.h:416