diff options
author | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-10-14 01:38:38 +0800 |
---|---|---|
committer | Chen-Pang He <jdh8@ms63.hinet.net> | 2012-10-14 01:38:38 +0800 |
commit | f34db6578a36438c6d229a9be25378cfe6fab38b (patch) | |
tree | e3652404135d83f561172c09419cfa063bbdfbc1 /unsupported/Eigen/src/KroneckerProduct | |
parent | 20a984cd2ebd826a4243081bf3b25b3a552aceca (diff) |
KroneckerProduct: we have const_cast_derived so why not use it?
Diffstat (limited to 'unsupported/Eigen/src/KroneckerProduct')
-rw-r--r-- | unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h b/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h index 84fd72fc6..14502f03f 100644 --- a/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h +++ b/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h @@ -31,6 +31,8 @@ void kroneckerProduct_full(const Derived_A& A, const Derived_B& B, Derived_AB & Ac = A.cols(), Br = B.rows(), Bc = B.cols(); + AB.resize(Ar*Br,Ac*Bc); + for (unsigned int i=0; i<Ar; ++i) for (unsigned int j=0; j<Ac; ++j) AB.block(i*Br,j*Bc,Br,Bc) = A(i,j)*B; @@ -78,22 +80,6 @@ void kroneckerProduct_sparse(const Derived_A &A, const Derived_B &B, Derived_AB } // end namespace internal - - -/*! - * Computes Kronecker tensor product of two dense matrices - * - * \param a Dense matrix a - * \param b Dense matrix b - * \param c Kronecker tensor product of a and b - */ -template<typename A,typename B,typename CScalar,int CRows,int CCols, int COptions, int CMaxRows, int CMaxCols> -void kroneckerProduct(const MatrixBase<A>& a, const MatrixBase<B>& b, Matrix<CScalar,CRows,CCols,COptions,CMaxRows,CMaxCols>& c) -{ - c.resize(a.rows()*b.rows(),a.cols()*b.cols()); - internal::kroneckerProduct_full(a.derived(), b.derived(), c); -} - /*! * Computes Kronecker tensor product of two dense matrices * @@ -107,10 +93,9 @@ void kroneckerProduct(const MatrixBase<A>& a, const MatrixBase<B>& b, Matrix<CSc * \param c Kronecker tensor product of a and b */ template<typename A,typename B,typename C> -void kroneckerProduct(const MatrixBase<A>& a, const MatrixBase<B>& b, MatrixBase<C> const & c_) +void kroneckerProduct(const MatrixBase<A>& a, const MatrixBase<B>& b, const MatrixBase<C>& c) { - MatrixBase<C>& c = const_cast<MatrixBase<C>& >(c_); - internal::kroneckerProduct_full(a.derived(), b.derived(), c.derived()); + internal::kroneckerProduct_full(a.derived(), b.derived(), c.const_cast_derived()); } /*! |