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