SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
eigen3.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Copyright (C) 2012 Sergey Lisitsyn
8  */
9 
10 #ifndef EIGEN3_H_
11 #define EIGEN3_H_
12 
13 #include <shogun/lib/config.h>
14 
15  //#define EIGEN_RUNTIME_NO_MALLOC
16  #include <Eigen/Eigen>
17  #include <Eigen/Dense>
18  #if EIGEN_VERSION_AT_LEAST(3,0,93)
19  #include <Eigen/Sparse>
20  #else
21  #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
22  #include <unsupported/Eigen/SparseExtra>
23 
24  #ifndef DOXYGEN_SHOULD_SKIP_THIS
25  // Triplet definition for Eigen3 backword compatibility
26  namespace Eigen {
27  template <typename T> struct Triplet
28  {
29  Triplet(index_t colIndex, index_t rowIndex, T valueT) :
30  ecol(colIndex), erow(rowIndex), evalue(valueT)
31  {
32  }
33  index_t col() const { return ecol; };
34  index_t row() const { return erow; };
35  T value() const { return evalue; };
36  index_t ecol;
37  index_t erow;
38  T evalue;
39  };
40 
41  // SimplicialLLT definition for Eigen3 backword compatibility
42  template <typename T> class SimplicialLLT
43  : public SimplicialCholesky<T,Lower>
44  {
45  public:
46  SimplicialLLT()
47  {
48  SimplicialCholesky<T>::setMode(SimplicialCholeskyLLt);
49  }
50  inline const T matrixL()
51  {
52  return SimplicialCholesky<T>::m_matrix;
53  }
54  inline const T matrixU()
55  {
56  return SimplicialCholesky<T>::m_matrix.transpose();
57  }
58  };
59  }
60  #endif //DOXYGEN_SHOULD_SKIP_THIS
61 
62  #endif //EIGEN_VERSION_AT_LEAST(3,0,93)
63 
64 #if ((EIGEN_WORLD_VERSION == 3) && (EIGEN_MAJOR_VERSION == 2) && \
65  ((EIGEN_MINOR_VERSION == 91) || (EIGEN_MINOR_VERSION == 92)))
66  // Regression has been introduced to eigen develop (3.3alpha1+):
67  // http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1229
68  // until this is not fixed we need to copy the matrix and calculate the log
69  #define EIGEN_WITH_LOG_BUG_1229 1
70 #endif
71 
72 #if ((EIGEN_WORLD_VERSION == 3) && (EIGEN_MAJOR_VERSION == 2) && \
73  ((EIGEN_MINOR_VERSION >= 91)))
74  // Eigen operator bug that was introduced somewhere in 3.3+
75  // TODO put reference and version when it got fixed
76  // c.f. github isse #3486
77  #define EIGEN_WITH_OPERATOR_BUG 1
78 #endif
79 namespace shogun
80 {
81 template<class T> class SGSparseMatrix;
82 
87 template<typename T> class EigenSparseUtil
88 {
89  public:
96  static Eigen::SparseMatrix<T> toEigenSparse(SGSparseMatrix<T> sg_matrix);
97 };
98 
99 }
100 
101 
102 #endif
template class SGSparseMatrix
int32_t index_t
Definition: common.h:62
Definition: SGMatrix.h:20
static Eigen::SparseMatrix< T > toEigenSparse(SGSparseMatrix< T > sg_matrix)
Definition: eigen3.cpp:22
This class contains some utilities for Eigen3 Sparse Matrix integration with shogun. Currently it provides a method for converting SGSparseMatrix to Eigen3 SparseMatrix.
Definition: eigen3.h:87
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18

SHOGUN Machine Learning Toolbox - Documentation