DGtal 1.3.0
Loading...
Searching...
No Matches
EigenSupport.h
1
17#pragma once
18
31#if defined(EigenSupport_RECURSES)
32#error Recursive header files inclusion detected in EigenSupport.h
33#else // defined(EigenSupport_RECURSES)
35#define EigenSupport_RECURSES
36
37#if !defined EigenSupport_h
39#define EigenSupport_h
40
42#if defined(WITH_EIGEN)
43
45// Eigen API extensions
46#define EIGEN_DENSEBASE_PLUGIN "DGtal/math/linalg/EigenDenseBaseAddons.h"
47#define EIGEN_SPARSEMATRIX_PLUGIN "DGtal/math/linalg/EigenSparseMatrixAddons.h"
49
51// Inclusions
52#include <iostream>
53#if defined(__GNUG__) && !defined(__clang__)
54#pragma GCC diagnostic push
55#pragma GCC diagnostic ignored "-Wpragmas"
56#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
57#pragma GCC diagnostic ignored "-Wignored-attributes"
58#pragma GCC diagnostic ignored "-Wshadow"
59#endif
60#if defined(__clang__)
61#pragma clang diagnostic push
62#pragma clang diagnostic ignored "-Wdocumentation"
63#pragma clang diagnostic ignored "-Wignored-attributes"
64#endif
65#include <Eigen/Dense>
66#include <Eigen/Sparse>
67#include <Eigen/SparseCholesky>
68#include <Eigen/IterativeLinearSolvers>
69#include <Eigen/SparseLU>
70#include <Eigen/SparseQR>
71#if defined(__clang__)
72#pragma clang diagnostic pop
73#endif
74#if defined(__GNUG__) && !defined(__clang__)
75#pragma GCC diagnostic pop
76#endif
78
79namespace DGtal
80{
82 // struct EigenLinearAlgebraBackend
97 {
98 typedef Eigen::VectorXd DenseVector;
99 typedef Eigen::MatrixXd DenseMatrix;
100 typedef Eigen::VectorXi IntegerVector;
101
102 typedef Eigen::SparseMatrix<DenseVector::Scalar, Eigen::ColMajor, DenseVector::Index> SparseMatrix;
103 typedef Eigen::Triplet<double, SparseMatrix::StorageIndex> Triplet;
104
106 typedef Eigen::SimplicialLLT<SparseMatrix> SolverSimplicialLLT;
107 typedef Eigen::SimplicialLDLT<SparseMatrix> SolverSimplicialLDLT;
108 typedef Eigen::ConjugateGradient<SparseMatrix> SolverConjugateGradient;
109 typedef Eigen::BiCGSTAB<SparseMatrix> SolverBiCGSTAB;
110 typedef Eigen::SparseLU<SparseMatrix> SolverSparseLU;
111 typedef Eigen::SparseQR<SparseMatrix, Eigen::COLAMDOrdering<SparseMatrix::Index> > SolverSparseQR;
112 };
114
115
122 inline
123 std::ostream&
124 operator<<(std::ostream & os, const Eigen::ComputationInfo& info)
125 {
126 switch (info)
127 {
128 case Eigen::Success:
129 os << "success";
130 break;
131 case Eigen::NumericalIssue:
132 os << "numerical_issue";
133 break;
134 case Eigen::NoConvergence:
135 os << "no_convergence";
136 break;
137 case Eigen::InvalidInput:
138 os << "invalid_input";
139 break;
140 }
141
142 return os;
143 }
144
145} // namespace DGtal
146
147#else // defined WITH_EIGEN
148#error "DGtal Eigen support hasn't been enabled"
149#endif // defined WITH_EIGEN
150#endif // !defined EigenSupport_h
151
152#undef EigenSupport_RECURSES
153#endif // else defined(EigenSupport_RECURSES)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Provide linear algebra backend using Eigen dense and sparse matrix as well as dense vector....
Definition: EigenSupport.h:97
Eigen::SimplicialLLT< SparseMatrix > SolverSimplicialLLT
Solvers on sparse matrices.
Definition: EigenSupport.h:106
Eigen::SimplicialLDLT< SparseMatrix > SolverSimplicialLDLT
Definition: EigenSupport.h:107
Eigen::Triplet< double, SparseMatrix::StorageIndex > Triplet
Definition: EigenSupport.h:103
Eigen::BiCGSTAB< SparseMatrix > SolverBiCGSTAB
Definition: EigenSupport.h:109
Eigen::SparseQR< SparseMatrix, Eigen::COLAMDOrdering< SparseMatrix::Index > > SolverSparseQR
Definition: EigenSupport.h:111
Eigen::SparseMatrix< DenseVector::Scalar, Eigen::ColMajor, DenseVector::Index > SparseMatrix
Definition: EigenSupport.h:102
Eigen::SparseLU< SparseMatrix > SolverSparseLU
Definition: EigenSupport.h:110
Eigen::ConjugateGradient< SparseMatrix > SolverConjugateGradient
Definition: EigenSupport.h:108