DGtal  0.9.4beta
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__) && !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
77 
79 namespace DGtal
80 {
81 
83 // struct EigenLinearAlgebraBackend
98 {
99  typedef Eigen::VectorXd DenseVector;
100  typedef Eigen::MatrixXd DenseMatrix;
101 
102  typedef Eigen::Triplet<double> Triplet;
103  typedef Eigen::SparseMatrix<DenseVector::Scalar, Eigen::ColMajor, long int> SparseMatrix;
104 
105  typedef Eigen::SimplicialLLT<SparseMatrix> SolverSimplicialLLT;
106  typedef Eigen::SimplicialLDLT<SparseMatrix> SolverSimplicialLDLT;
107  typedef Eigen::ConjugateGradient<SparseMatrix> SolverConjugateGradient;
108  typedef Eigen::BiCGSTAB<SparseMatrix> SolverBiCGSTAB;
109  typedef Eigen::SparseLU<SparseMatrix> SolverSparseLU;
110  typedef Eigen::SparseQR<SparseMatrix, Eigen::COLAMDOrdering<SparseMatrix::Index> > SolverSparseQR;
111 };
113 
114 
121 inline
122 std::ostream&
123 operator<<(std::ostream & os, const Eigen::ComputationInfo& info)
124 {
125  switch (info)
126  {
127  case Eigen::Success:
128  os << "success";
129  break;
130  case Eigen::NumericalIssue:
131  os << "numerical_issue";
132  break;
133  case Eigen::NoConvergence:
134  os << "no_convergence";
135  break;
136  case Eigen::InvalidInput:
137  os << "invalid_input";
138  break;
139  }
140 
141  return os;
142 }
143 
144 } // namespace DGtal
145 
146 #else // defined WITH_EIGEN
147 #error "DGtal Eigen support hasn't been enabled"
148 #endif // defined WITH_EIGEN
149 #endif // !defined EigenSupport_h
150 
151 #undef EigenSupport_RECURSES
152 #endif // else defined(EigenSupport_RECURSES)
Aim: Provide linear algebra backend using Eigen dense and sparse matrix as well as dense vector...
Definition: EigenSupport.h:97
Eigen::SparseQR< SparseMatrix, Eigen::COLAMDOrdering< SparseMatrix::Index > > SolverSparseQR
Definition: EigenSupport.h:110
Eigen::ConjugateGradient< SparseMatrix > SolverConjugateGradient
Definition: EigenSupport.h:107
Eigen::SparseMatrix< DenseVector::Scalar, Eigen::ColMajor, long int > SparseMatrix
Definition: EigenSupport.h:103
Eigen::SimplicialLLT< SparseMatrix > SolverSimplicialLLT
Definition: EigenSupport.h:105
Eigen::BiCGSTAB< SparseMatrix > SolverBiCGSTAB
Definition: EigenSupport.h:108
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Eigen::Triplet< double > Triplet
Definition: EigenSupport.h:102
DGtal is the top-level namespace which contains all DGtal functions and types.
Eigen::SimplicialLDLT< SparseMatrix > SolverSimplicialLDLT
Definition: EigenSupport.h:106
Eigen::SparseLU< SparseMatrix > SolverSparseLU
Definition: EigenSupport.h:109