SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Copyright (C) 2012 Sergey Lisitsyn 00008 */ 00009 00010 #ifndef EIGEN3_H_ 00011 #define EIGEN3_H_ 00012 00013 #include <shogun/lib/config.h> 00014 00015 #ifdef HAVE_EIGEN3 00016 //#define EIGEN_RUNTIME_NO_MALLOC 00017 #include <Eigen/Eigen> 00018 #include <Eigen/Dense> 00019 #if EIGEN_VERSION_AT_LEAST(3,0,93) 00020 #include <Eigen/Sparse> 00021 #else 00022 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET 00023 #include <unsupported/Eigen/SparseExtra> 00024 00025 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00026 // Triplet definition for Eigen3 backword compatibility 00027 namespace Eigen { 00028 template <typename T> struct Triplet 00029 { 00030 Triplet(index_t colIndex, index_t rowIndex, T valueT) : 00031 ecol(colIndex), erow(rowIndex), evalue(valueT) 00032 { 00033 } 00034 index_t col() const { return ecol; }; 00035 index_t row() const { return erow; }; 00036 T value() const { return evalue; }; 00037 index_t ecol; 00038 index_t erow; 00039 T evalue; 00040 }; 00041 00042 // SimplicialLLT definition for Eigen3 backword compatibility 00043 template <typename T> class SimplicialLLT 00044 : public SimplicialCholesky<T,Lower> 00045 { 00046 public: 00047 SimplicialLLT() 00048 { 00049 SimplicialCholesky<T>::setMode(SimplicialCholeskyLLt); 00050 } 00051 inline const T matrixL() 00052 { 00053 return SimplicialCholesky<T>::m_matrix; 00054 } 00055 inline const T matrixU() 00056 { 00057 return SimplicialCholesky<T>::m_matrix.transpose(); 00058 } 00059 }; 00060 } 00061 #endif //DOXYGEN_SHOULD_SKIP_THIS 00062 00063 #endif //EIGEN_VERSION_AT_LEAST(3,0,93) 00064 00065 namespace shogun 00066 { 00067 template<class T> class SGSparseMatrix; 00068 00073 template<typename T> class EigenSparseUtil 00074 { 00075 public: 00082 static Eigen::SparseMatrix<T> toEigenSparse(SGSparseMatrix<T> sg_matrix); 00083 }; 00084 00085 } 00086 00087 #endif //HAVE_EIGEN3 00088 00089 #endif