5 #include <unsupported/Eigen/IterativeSolvers>
7 class MatrixReplacement;
14 struct traits<MatrixReplacement> :
public Eigen::internal::traits<Eigen::SparseMatrix<double> >
24 typedef double Scalar;
25 typedef double RealScalar;
26 typedef int StorageIndex;
33 Index rows()
const {
return mp_mat->rows(); }
34 Index cols()
const {
return mp_mat->cols(); }
36 template<
typename Rhs>
42 MatrixReplacement() : mp_mat(0) {}
58 template<
typename Rhs>
59 struct generic_product_impl<MatrixReplacement, Rhs, SparseShape, DenseShape,
GemvProduct>
60 : generic_product_impl_base<MatrixReplacement,Rhs,generic_product_impl<MatrixReplacement,Rhs> >
62 typedef typename Product<MatrixReplacement,Rhs>::Scalar Scalar;
64 template<
typename Dest>
65 static void scaleAndAddTo(Dest& dst,
const MatrixReplacement& lhs,
const Rhs& rhs,
const Scalar& alpha)
69 eigen_assert(alpha==Scalar(1) &&
"scaling is not implemented");
75 dst += rhs(
i) * lhs.my_matrix().col(
i);
99 std::cout <<
"CG: #iterations: " << cg.
iterations() <<
", estimated error: " << cg.
error() << std::endl;
106 std::cout <<
"BiCGSTAB: #iterations: " << bicg.
iterations() <<
", estimated error: " << bicg.
error() << std::endl;
110 Eigen::GMRES<MatrixReplacement, Eigen::IdentityPreconditioner> gmres;
113 std::cout <<
"GMRES: #iterations: " << gmres.iterations() <<
", estimated error: " << gmres.error() << std::endl;
117 Eigen::DGMRES<MatrixReplacement, Eigen::IdentityPreconditioner> gmres;
120 std::cout <<
"DGMRES: #iterations: " << gmres.iterations() <<
", estimated error: " << gmres.error() << std::endl;
124 Eigen::MINRES<MatrixReplacement, Eigen::Lower|Eigen::Upper, Eigen::IdentityPreconditioner> minres;
127 std::cout <<
"MINRES: #iterations: " << minres.iterations() <<
", estimated error: " << minres.error() << std::endl;
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
A bi conjugate gradient stabilized solver for sparse square problems.
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
static const RandomReturnType Random()
Derived & compute(const EigenBase< MatrixDerived > &A)
Base class for all dense matrices, vectors, and expressions.
The matrix class, also used for vectors and row-vectors.
Expression of the product of two arbitrary matrices or vectors.
TransposeReturnType transpose()
A versatible sparse matrix representation.
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT