SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #ifdef HAVE_EIGEN3
16  //#define EIGEN_RUNTIME_NO_MALLOC
17  #include <Eigen/Eigen>
18  #include <Eigen/Dense>
19  #if EIGEN_VERSION_AT_LEAST(3,0,93)
20  #include <Eigen/Sparse>
21  #else
22  #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
23  #include <unsupported/Eigen/SparseExtra>
24 
25  #ifndef DOXYGEN_SHOULD_SKIP_THIS
26  // Triplet definition for Eigen3 backword compatibility
27  namespace Eigen {
28  template <typename T> struct Triplet
29  {
30  Triplet(index_t colIndex, index_t rowIndex, T valueT) :
31  ecol(colIndex), erow(rowIndex), evalue(valueT)
32  {
33  }
34  index_t col() const { return ecol; };
35  index_t row() const { return erow; };
36  T value() const { return evalue; };
37  index_t ecol;
38  index_t erow;
39  T evalue;
40  };
41 
42  // SimplicialLLT definition for Eigen3 backword compatibility
43  template <typename T> class SimplicialLLT
44  : public SimplicialCholesky<T,Lower>
45  {
46  public:
47  SimplicialLLT()
48  {
49  SimplicialCholesky<T>::setMode(SimplicialCholeskyLLt);
50  }
51  inline const T matrixL()
52  {
53  return SimplicialCholesky<T>::m_matrix;
54  }
55  inline const T matrixU()
56  {
57  return SimplicialCholesky<T>::m_matrix.transpose();
58  }
59  };
60  }
61  #endif //DOXYGEN_SHOULD_SKIP_THIS
62 
63  #endif //EIGEN_VERSION_AT_LEAST(3,0,93)
64 
65 namespace shogun
66 {
67 template<class T> class SGSparseMatrix;
68 
73 template<typename T> class EigenSparseUtil
74 {
75  public:
82  static Eigen::SparseMatrix<T> toEigenSparse(SGSparseMatrix<T> sg_matrix);
83 };
84 
85 }
86 
87 #endif //HAVE_EIGEN3
88 
89 #endif

SHOGUN Machine Learning Toolbox - Documentation