DGtal  0.9.2
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)
34 
35 #define EigenSupport_RECURSES
36 
37 #if !defined EigenSupport_h
38 
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"
48 
51 // Inclusions
52 #include <iostream>
53 #if defined(__GNUG__)
54 #pragma GCC diagnostic push
55 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
56 #endif
57 #if defined(__clang__)
58 #pragma clang diagnostic push
59 #pragma clang diagnostic ignored "-Wdocumentation"
60 #endif
61 #include <Eigen/Dense>
62 #include <Eigen/Sparse>
63 #include <Eigen/SparseCholesky>
64 #include <Eigen/IterativeLinearSolvers>
65 #include <Eigen/SparseLU>
66 #include <Eigen/SparseQR>
67 #if defined(__clang__)
68 #pragma clang diagnostic pop
69 #endif
70 #if defined(__GNUG__)
71 #endif
72 #pragma GCC diagnostic pop
73 
75 namespace DGtal
76 {
77 
79 // struct EigenLinearAlgebraBackend
94 {
95  typedef Eigen::VectorXd DenseVector;
96  typedef Eigen::MatrixXd DenseMatrix;
97 
98  typedef Eigen::Triplet<double> Triplet;
99  typedef Eigen::SparseMatrix<DenseVector::Scalar, Eigen::ColMajor> SparseMatrix;
100 
101  typedef Eigen::SimplicialLLT<SparseMatrix> SolverSimplicialLLT;
102  typedef Eigen::SimplicialLDLT<SparseMatrix> SolverSimplicialLDLT;
103  typedef Eigen::ConjugateGradient<SparseMatrix> SolverConjugateGradient;
104  typedef Eigen::BiCGSTAB<SparseMatrix> SolverBiCGSTAB;
105  typedef Eigen::SparseLU<SparseMatrix> SolverSparseLU;
106  typedef Eigen::SparseQR<SparseMatrix, Eigen::COLAMDOrdering<SparseMatrix::Index> > SolverSparseQR;
107 };
109 
110 
117 inline
118 std::ostream&
119 operator<<(std::ostream & os, const Eigen::ComputationInfo& info)
120 {
121  switch (info)
122  {
123  case Eigen::Success:
124  os << "success";
125  break;
126  case Eigen::NumericalIssue:
127  os << "numerical_issue";
128  break;
129  case Eigen::NoConvergence:
130  os << "no_convergence";
131  break;
132  case Eigen::InvalidInput:
133  os << "invalid_input";
134  break;
135  }
136 
137  return os;
138 }
139 
140 } // namespace DGtal
141 
142 #else // defined WITH_EIGEN
143 #error "DGtal Eigen support hasn't been enabled"
144 #endif // defined WITH_EIGEN
145 #endif // !defined EigenSupport_h
146 
147 #undef EigenSupport_RECURSES
148 #endif // else defined(EigenSupport_RECURSES)
Aim: Provide linear algebra backend using Eigen dense and sparse matrix as well as dense vector...
Definition: EigenSupport.h:93
Eigen::SparseQR< SparseMatrix, Eigen::COLAMDOrdering< SparseMatrix::Index > > SolverSparseQR
Definition: EigenSupport.h:106
Eigen::ConjugateGradient< SparseMatrix > SolverConjugateGradient
Definition: EigenSupport.h:103
Eigen::SimplicialLLT< SparseMatrix > SolverSimplicialLLT
Definition: EigenSupport.h:101
Eigen::BiCGSTAB< SparseMatrix > SolverBiCGSTAB
Definition: EigenSupport.h:104
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Eigen::SparseMatrix< DenseVector::Scalar, Eigen::ColMajor > SparseMatrix
Definition: EigenSupport.h:99
Eigen::Triplet< double > Triplet
Definition: EigenSupport.h:98
DGtal is the top-level namespace which contains all DGtal functions and types.
Eigen::SimplicialLDLT< SparseMatrix > SolverSimplicialLDLT
Definition: EigenSupport.h:102
Eigen::SparseLU< SparseMatrix > SolverSparseLU
Definition: EigenSupport.h:105