Chen-Pang He avatar Chen-Pang He committed 743300a

Make KroneckerProductSparse inherit EigenBase instead of SparseMatrixBase, for it does not provide an InnerIterator.

Comments (0)

Files changed (5)

Eigen/src/Core/util/ForwardDeclarations.h

 };
 }
 
-// KroneckerProduct module
-template<typename Lhs, typename Rhs> class KroneckerProductSparse;
 
 #ifdef EIGEN2_SUPPORT
 template<typename ExpressionType> class Cwise;

Eigen/src/SparseCore/SparseMatrixBase.h

     template<typename Lhs, typename Rhs>
     inline Derived& operator=(const SparseSparseProduct<Lhs,Rhs>& product);
 
-    template<typename Lhs, typename Rhs>
-    inline Derived& operator=(const KroneckerProductSparse<Lhs,Rhs>& product);
-
     friend std::ostream & operator << (std::ostream & s, const SparseMatrixBase& m)
     {
       typedef typename Derived::Nested Nested;

unsupported/Eigen/KroneckerProduct

 #define EIGEN_KRONECKER_PRODUCT_MODULE_H
 
 #include "../../Eigen/Core"
-#include "../../Eigen/SparseCore"
 
 #include "../../Eigen/src/Core/util/DisableStupidWarnings.h"
 

unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h

 #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 { 
 
-namespace Eigen { 
+template<typename Scalar, int Options, typename Index> class SparseMatrix;
 
 /*!
  * \brief Kronecker tensor product helper class for dense matrices
  * \tparam Rhs  Type of the rignt-hand side, a matrix expression.
  */
 template<typename Lhs, typename Rhs>
-class KroneckerProductSparse : public SparseMatrixBase<KroneckerProductSparse<Lhs,Rhs> >
+class KroneckerProductSparse : public EigenBase<KroneckerProductSparse<Lhs,Rhs> >
 {
+  private:
+    typedef typename internal::traits<KroneckerProductSparse>::Index Index;
+
   public:
-    typedef SparseMatrixBase<KroneckerProductSparse> Base;
-    EIGEN_DENSE_PUBLIC_INTERFACE(KroneckerProductSparse)
-
     /*! \brief Constructor. */
     KroneckerProductSparse(const Lhs& A, const Rhs& B)
       : m_A(A), m_B(B)
     inline Index rows() const { return m_A.rows() * m_B.rows(); }
     inline Index cols() const { return m_A.cols() * m_B.cols(); }
 
+    template<typename Scalar, int Options, typename Index>
+    operator SparseMatrix<Scalar, Options, Index>()
+    {
+      SparseMatrix<Scalar, Options, Index> result;
+      evalTo(result.derived());
+      return result;
+    }
+
   private:
     typename Lhs::Nested m_A;
     typename Rhs::Nested m_B;
   typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar;
 
   enum {
-    Rows = EIGEN_SIZE_PRODUCT(traits<Lhs>::RowsAtCompileTime, traits<Rhs>::RowsAtCompileTime),
-    Cols = EIGEN_SIZE_PRODUCT(traits<Lhs>::ColsAtCompileTime, traits<Rhs>::ColsAtCompileTime),
-    MaxRows = EIGEN_SIZE_PRODUCT(traits<Lhs>::MaxRowsAtCompileTime, traits<Rhs>::MaxRowsAtCompileTime),
-    MaxCols = EIGEN_SIZE_PRODUCT(traits<Lhs>::MaxColsAtCompileTime, traits<Rhs>::MaxColsAtCompileTime),
+    Rows = size_at_compile_time<traits<Lhs>::RowsAtCompileTime, traits<Rhs>::RowsAtCompileTime>::ret,
+    Cols = size_at_compile_time<traits<Lhs>::ColsAtCompileTime, traits<Rhs>::ColsAtCompileTime>::ret,
+    MaxRows = size_at_compile_time<traits<Lhs>::MaxRowsAtCompileTime, traits<Rhs>::MaxRowsAtCompileTime>::ret,
+    MaxCols = size_at_compile_time<traits<Lhs>::MaxColsAtCompileTime, traits<Rhs>::MaxColsAtCompileTime>::ret,
     CoeffReadCost = Lhs::CoeffReadCost + Rhs::CoeffReadCost + NumTraits<Scalar>::MulCost
   };
 
   typedef typename remove_all<_Lhs>::type Lhs;
   typedef typename remove_all<_Rhs>::type Rhs;
   typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar;
-  typedef Sparse StorageKind;
+  typedef typename promote_storage_type<typename traits<Lhs>::StorageKind, typename traits<Rhs>::StorageKind>::ret StorageKind;
   typedef typename promote_index_type<typename Lhs::Index, typename Rhs::Index>::type Index;
 
   enum {
     LhsFlags = Lhs::Flags,
     RhsFlags = Rhs::Flags,
 
-    RowsAtCompileTime = EIGEN_SIZE_PRODUCT(traits<Lhs>::RowsAtCompileTime, traits<Rhs>::RowsAtCompileTime),
-    ColsAtCompileTime = EIGEN_SIZE_PRODUCT(traits<Lhs>::ColsAtCompileTime, traits<Rhs>::ColsAtCompileTime),
-    MaxRowsAtCompileTime = EIGEN_SIZE_PRODUCT(traits<Lhs>::MaxRowsAtCompileTime, traits<Rhs>::MaxRowsAtCompileTime),
-    MaxColsAtCompileTime = EIGEN_SIZE_PRODUCT(traits<Lhs>::MaxColsAtCompileTime, traits<Rhs>::MaxColsAtCompileTime),
+    RowsAtCompileTime = size_at_compile_time<traits<Lhs>::RowsAtCompileTime, traits<Rhs>::RowsAtCompileTime>::ret,
+    ColsAtCompileTime = size_at_compile_time<traits<Lhs>::ColsAtCompileTime, traits<Rhs>::ColsAtCompileTime>::ret,
+    MaxRowsAtCompileTime = size_at_compile_time<traits<Lhs>::MaxRowsAtCompileTime, traits<Rhs>::MaxRowsAtCompileTime>::ret,
+    MaxColsAtCompileTime = size_at_compile_time<traits<Lhs>::MaxColsAtCompileTime, traits<Rhs>::MaxColsAtCompileTime>::ret,
 
     EvalToRowMajor = (LhsFlags & RhsFlags & RowMajorBit),
     RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit),
   return KroneckerProductSparse<A,B>(a.derived(), b.derived());
 }
 
-template<typename Derived>
-template<typename Lhs, typename Rhs>
-Derived& SparseMatrixBase<Derived>::operator=(const KroneckerProductSparse<Lhs,Rhs>& product)
-{
-  product.evalTo(derived());
-  return derived();
-}
-
 } // end namespace Eigen
 
 #endif // KRONECKER_TENSOR_PRODUCT_H

unsupported/Eigen/src/MatrixFunctions/MatrixPowerBase.h

     Index rows() const { return m_pow.rows(); }
     Index cols() const { return m_pow.cols(); }
 
-#ifndef EIGEN_PARSED_BY_DOXYGEN
-    struct Unusable {};
-    const Unusable& coeff(Index) const { return *reinterpret_cast<const Unusable*>(this); }
-    const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }
-    Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }
-    Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }
-#endif
-
   private:
     Derived& m_pow;
     const RealScalar m_p;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.