DGtal  1.4.beta
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 
44 // Eigen API extensions
45 #define EIGEN_DENSEBASE_PLUGIN "DGtal/math/linalg/EigenDenseBaseAddons.h"
46 #define EIGEN_SPARSEMATRIX_PLUGIN "DGtal/math/linalg/EigenSparseMatrixAddons.h"
48 
50 // Inclusions
51 #include <iostream>
52 #if defined(__GNUG__) && !defined(__clang__)
53 #pragma GCC diagnostic push
54 #pragma GCC diagnostic ignored "-Wpragmas"
55 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
56 #pragma GCC diagnostic ignored "-Wignored-attributes"
57 #pragma GCC diagnostic ignored "-Wshadow"
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__) && !defined(__clang__)
74 #pragma GCC diagnostic pop
75 #endif
77 
78 namespace DGtal
79 {
81  // struct EigenLinearAlgebraBackend
96  {
97  typedef Eigen::VectorXd DenseVector;
98  typedef Eigen::MatrixXd DenseMatrix;
99  typedef Eigen::VectorXi IntegerVector;
100 
101  typedef Eigen::SparseMatrix<DenseVector::Scalar, Eigen::ColMajor, DenseVector::Index> SparseMatrix;
102  typedef Eigen::Triplet<double, SparseMatrix::StorageIndex> Triplet;
103 
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 #endif // !defined EigenSupport_h
147 
148 #undef EigenSupport_RECURSES
149 #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 ATu0v1< TKSpace, TLinearAlgebra > &object)
Aim: Provide linear algebra backend using Eigen dense and sparse matrix as well as dense vector....
Definition: EigenSupport.h:96
Eigen::SimplicialLLT< SparseMatrix > SolverSimplicialLLT
Solvers on sparse matrices.
Definition: EigenSupport.h:105
Eigen::SimplicialLDLT< SparseMatrix > SolverSimplicialLDLT
Definition: EigenSupport.h:106
Eigen::Triplet< double, SparseMatrix::StorageIndex > Triplet
Definition: EigenSupport.h:102
Eigen::BiCGSTAB< SparseMatrix > SolverBiCGSTAB
Definition: EigenSupport.h:108
Eigen::SparseQR< SparseMatrix, Eigen::COLAMDOrdering< SparseMatrix::Index > > SolverSparseQR
Definition: EigenSupport.h:110
Eigen::SparseMatrix< DenseVector::Scalar, Eigen::ColMajor, DenseVector::Index > SparseMatrix
Definition: EigenSupport.h:101
Eigen::SparseLU< SparseMatrix > SolverSparseLU
Definition: EigenSupport.h:109
Eigen::ConjugateGradient< SparseMatrix > SolverConjugateGradient
Definition: EigenSupport.h:107