diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index c755ea3c1..b114b3745 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -282,8 +282,6 @@ struct stem_function }; } -// KroneckerProduct module -template class KroneckerProductSparse; #ifdef EIGEN2_SUPPORT template class Cwise; diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h index 0e431815f..2ef841616 100644 --- a/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/Eigen/src/SparseCore/SparseMatrixBase.h @@ -259,9 +259,6 @@ template class SparseMatrixBase : public EigenBase template inline Derived& operator=(const SparseSparseProduct& product); - template - inline Derived& operator=(const KroneckerProductSparse& product); - friend std::ostream & operator << (std::ostream & s, const SparseMatrixBase& m) { typedef typename Derived::Nested Nested; diff --git a/unsupported/Eigen/KroneckerProduct b/unsupported/Eigen/KroneckerProduct index baddc3837..796e386ad 100644 --- a/unsupported/Eigen/KroneckerProduct +++ b/unsupported/Eigen/KroneckerProduct @@ -2,7 +2,6 @@ #define EIGEN_KRONECKER_PRODUCT_MODULE_H #include "../../Eigen/Core" -#include "../../Eigen/SparseCore" #include "../../Eigen/src/Core/util/DisableStupidWarnings.h" diff --git a/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h b/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h index 5c2841dbd..a313eade3 100644 --- a/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h +++ b/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h @@ -12,12 +12,10 @@ #ifndef KRONECKER_TENSOR_PRODUCT_H #define KRONECKER_TENSOR_PRODUCT_H -#define EIGEN_SIZE_PRODUCT(a,b) (!((int)a && (int)b) ? 0 \ - : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \ - : (int)a * (int)b) - namespace Eigen { +template class SparseMatrix; + /*! * \brief Kronecker tensor product helper class for dense matrices * @@ -79,12 +77,12 @@ class KroneckerProduct : public ReturnByValue > * \tparam Rhs Type of the rignt-hand side, a matrix expression. */ template -class KroneckerProductSparse : public SparseMatrixBase > +class KroneckerProductSparse : public EigenBase > { - public: - typedef SparseMatrixBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(KroneckerProductSparse) + private: + typedef typename internal::traits::Index Index; + public: /*! \brief Constructor. */ KroneckerProductSparse(const Lhs& A, const Rhs& B) : m_A(A), m_B(B) @@ -96,6 +94,14 @@ class KroneckerProductSparse : public SparseMatrixBase + operator SparseMatrix() + { + SparseMatrix result; + evalTo(result.derived()); + return result; + } + private: typename Lhs::Nested m_A; typename Rhs::Nested m_B; @@ -151,10 +157,10 @@ struct traits > typedef typename scalar_product_traits::ReturnType Scalar; enum { - Rows = EIGEN_SIZE_PRODUCT(traits::RowsAtCompileTime, traits::RowsAtCompileTime), - Cols = EIGEN_SIZE_PRODUCT(traits::ColsAtCompileTime, traits::ColsAtCompileTime), - MaxRows = EIGEN_SIZE_PRODUCT(traits::MaxRowsAtCompileTime, traits::MaxRowsAtCompileTime), - MaxCols = EIGEN_SIZE_PRODUCT(traits::MaxColsAtCompileTime, traits::MaxColsAtCompileTime), + Rows = size_at_compile_time::RowsAtCompileTime, traits::RowsAtCompileTime>::ret, + Cols = size_at_compile_time::ColsAtCompileTime, traits::ColsAtCompileTime>::ret, + MaxRows = size_at_compile_time::MaxRowsAtCompileTime, traits::MaxRowsAtCompileTime>::ret, + MaxCols = size_at_compile_time::MaxColsAtCompileTime, traits::MaxColsAtCompileTime>::ret, CoeffReadCost = Lhs::CoeffReadCost + Rhs::CoeffReadCost + NumTraits::MulCost }; @@ -168,17 +174,17 @@ struct traits > typedef typename remove_all<_Lhs>::type Lhs; typedef typename remove_all<_Rhs>::type Rhs; typedef typename scalar_product_traits::ReturnType Scalar; - typedef Sparse StorageKind; + typedef typename promote_storage_type::StorageKind, typename traits::StorageKind>::ret StorageKind; typedef typename promote_index_type::type Index; enum { LhsFlags = Lhs::Flags, RhsFlags = Rhs::Flags, - RowsAtCompileTime = EIGEN_SIZE_PRODUCT(traits::RowsAtCompileTime, traits::RowsAtCompileTime), - ColsAtCompileTime = EIGEN_SIZE_PRODUCT(traits::ColsAtCompileTime, traits::ColsAtCompileTime), - MaxRowsAtCompileTime = EIGEN_SIZE_PRODUCT(traits::MaxRowsAtCompileTime, traits::MaxRowsAtCompileTime), - MaxColsAtCompileTime = EIGEN_SIZE_PRODUCT(traits::MaxColsAtCompileTime, traits::MaxColsAtCompileTime), + RowsAtCompileTime = size_at_compile_time::RowsAtCompileTime, traits::RowsAtCompileTime>::ret, + ColsAtCompileTime = size_at_compile_time::ColsAtCompileTime, traits::ColsAtCompileTime>::ret, + MaxRowsAtCompileTime = size_at_compile_time::MaxRowsAtCompileTime, traits::MaxRowsAtCompileTime>::ret, + MaxColsAtCompileTime = size_at_compile_time::MaxColsAtCompileTime, traits::MaxColsAtCompileTime>::ret, EvalToRowMajor = (LhsFlags & RhsFlags & RowMajorBit), RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit), @@ -233,14 +239,6 @@ KroneckerProductSparse kroneckerProduct(const EigenBase& a, const EigenB return KroneckerProductSparse(a.derived(), b.derived()); } -template -template -Derived& SparseMatrixBase::operator=(const KroneckerProductSparse& product) -{ - product.evalTo(derived()); - return derived(); -} - } // end namespace Eigen #endif // KRONECKER_TENSOR_PRODUCT_H