Loading...
Searching...
No Matches
ilut.h
Go to the documentation of this file.
#ifndef _RHEOLEF_ILUT_H
#define _RHEOLEF_ILUT_H
//
// This file is part of Rheolef.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
// AUTHOR: Pierre.Saramito@imag.fr
// DATE: 28 february 2018
namespace rheolef {
} // namespace rheolef
#include "rheolef/solver.h"
#ifdef _RHEOLEF_HAVE_EIGEN
#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_ilut_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_ilut_rep (const csr<T,M>& a, size_type fill_factor, T drop_tol);
solver_ilut_rep (const solver_ilut_rep&);
solver_abstract_rep<T,M>* clone() const;
bool good() const { return true; }
void update_values (const csr<T,M>& a);
// accessors:
vec<T,M> trans_solve (const vec<T,M>& rhs) const;
vec<T,M> solve (const vec<T,M>& rhs) const;
protected:
// data:
csr<T,M> _a;
size_type _fill_factor;
T _drop_tol;
Eigen::IncompleteLUT<T> _ilut_a;
};
// -----------------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------------
template<class T, class M>
inline
solver_ilut_rep<T,M>::solver_ilut_rep (const csr<T,M>& a, size_type fill_factor, T drop_tol)
: solver_abstract_rep<T,M>(solver_option()),
_a(a),
_fill_factor(fill_factor),
_drop_tol(drop_tol),
_ilut_a()
{
update_values (a);
}
template<class T, class M>
inline
solver_ilut_rep<T,M>::solver_ilut_rep (const solver_ilut_rep<T,M>& x)
: solver_abstract_rep<T,M>(x.option()),
_a(x._a),
_fill_factor(x._fill_factor),
_drop_tol(x._drop_tol),
_ilut_a()
{
// Eigen::IncompleteLUT 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_ilut_rep<T,M>::clone() const
{
typedef solver_ilut_rep<T,M> rep;
return new_macro (rep(*this));
}
// =======================================================================
// preconditioner interface
// =======================================================================
//<verbatim:
template <class T, class M>
solver_basic<T,M> ilut (
const csr<T,M>& a,
size_t fill_factor = 10,
T drop_tol = 1e3*std::numeric_limits<T>::epsilon());
//>verbatim:
template <class T, class M>
inline
solver_basic<T,M> ilut (const csr<T,M>& a, size_t fill_factor, T drop_tol)
{
using rep = solver_ilut_rep<T,M>;
solver_basic<T,M> p;
p.solver_basic<T,M>::base::operator= (new_macro(rep(a,fill_factor,drop_tol)));
return p;
}
} // namespace rheolef
#endif // _RHEOLEF_HAVE_EIGEN
#endif // _RHEOLEF_ILUT_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::size_type
csr< T, M >::size_type size_type
Definition solver.h:193
rheolef::solver_basic
Definition solver.h:264
rheolef::solver_ilut_rep
Definition ilut.h:98
rheolef::solver_ilut_rep::_a
csr< T, M > _a
Definition ilut.h:121
rheolef::solver_ilut_rep::solver_ilut_rep
solver_ilut_rep(const csr< T, M > &a, size_type fill_factor, T drop_tol)
Definition ilut.h:131
rheolef::solver_ilut_rep::_ilut_a
Eigen::IncompleteLUT< T > _ilut_a
Definition ilut.h:124
rheolef::solver_ilut_rep::_fill_factor
size_type _fill_factor
Definition ilut.h:122
rheolef::solver_ilut_rep::_drop_tol
T _drop_tol
Definition ilut.h:123
rheolef::solver_ilut_rep::update_values
void update_values(const csr< T, M > &a)
Definition ilut.cc:34
rheolef::solver_ilut_rep::size_type
base::size_type size_type
Definition ilut.h:103
rheolef::solver_ilut_rep::base
solver_abstract_rep< T, M > base
Definition ilut.h:102
rheolef::solver_ilut_rep::determinant_type
base::determinant_type determinant_type
Definition ilut.h:104
rheolef::solver_ilut_rep::solver_ilut_rep
solver_ilut_rep(const solver_ilut_rep &)
rheolef::solver_ilut_rep::trans_solve
vec< T, M > trans_solve(const vec< T, M > &rhs) const
Definition ilut.cc:73
rheolef::solver_ilut_rep::good
bool good() const
Definition ilut.h:111
rheolef::solver_ilut_rep::clone
solver_abstract_rep< T, M > * clone() const
Definition ilut.h:155
rheolef::solver_ilut_rep::solve
vec< T, M > solve(const vec< T, M > &rhs) const
Definition ilut.cc:61
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::ilut
solver_basic< T, M > ilut(const csr< T, M > &a, size_t fill_factor=10, T drop_tol=1e3 *std::numeric_limits< T >::epsilon())
Definition ilut.h:173
p
Definition sphere.icc:25
rheolef::solver_abstract_rep::determinant_type
Definition solver.h:215
M
Expr1::memory_type M
Definition vec_expr_v2.h:416