12 #ifndef KRONECKER_TENSOR_PRODUCT_H 13 #define KRONECKER_TENSOR_PRODUCT_H 17 template<
typename Scalar,
int Options,
typename Index>
class SparseMatrix;
29 template<
typename Lhs,
typename Rhs>
34 typedef typename Base::Scalar
Scalar;
35 typedef typename Base::Index
Index;
44 template<
typename Dest>
void evalTo(Dest& dst)
const;
46 inline Index
rows()
const {
return m_A.rows() *
m_B.rows(); }
47 inline Index
cols()
const {
return m_A.cols() *
m_B.cols(); }
51 return m_A.coeff(row /
m_B.rows(), col /
m_B.cols()) *
52 m_B.coeff(row %
m_B.rows(), col %
m_B.cols());
58 return m_A.coeff(i /
m_A.size()) *
m_B.coeff(i %
m_A.size());
62 typename Lhs::Nested
m_A;
63 typename Rhs::Nested
m_B;
79 template<
typename Lhs,
typename Rhs>
92 template<
typename Dest>
void evalTo(Dest& dst)
const;
94 inline Index
rows()
const {
return m_A.rows() *
m_B.rows(); }
95 inline Index
cols()
const {
return m_A.cols() *
m_B.cols(); }
97 template<
typename Scalar,
int Options,
typename Index>
110 template<
typename Lhs,
typename Rhs>
111 template<
typename Dest>
114 const int BlockRows = Rhs::RowsAtCompileTime,
115 BlockCols = Rhs::ColsAtCompileTime;
118 for (
Index i=0; i <
m_A.rows(); ++i)
119 for (
Index j=0; j <
m_A.cols(); ++j)
123 template<
typename Lhs,
typename Rhs>
124 template<
typename Dest>
130 dst.resizeNonZeros(0);
131 dst.reserve(
m_A.nonZeros() *
m_B.nonZeros());
133 for (
Index kA=0; kA <
m_A.outerSize(); ++kA)
135 for (
Index kB=0; kB <
m_B.outerSize(); ++kB)
137 for (
typename Lhs::InnerIterator itA(
m_A,kA); itA; ++itA)
139 for (
typename Rhs::InnerIterator itB(
m_B,kB); itB; ++itB)
141 const Index i = itA.row() * Br + itB.row(),
142 j = itA.col() * Bc + itB.col();
143 dst.insert(i,j) = itA.value() * itB.value();
152 template<
typename _Lhs,
typename _Rhs>
170 template<
typename _Lhs,
typename _Rhs>
181 LhsFlags = Lhs::Flags,
182 RhsFlags = Rhs::Flags,
219 template<
typename A,
typename B>
236 template<
typename A,
typename B>
244 #endif // KRONECKER_TENSOR_PRODUCT_H
scalar_product_traits< typename Lhs::Scalar, typename Rhs::Scalar >::ReturnType Scalar
promote_index_type< typename Lhs::Index, typename Rhs::Index >::type Index
A versatible sparse matrix representation.
remove_all< _Rhs >::type Rhs
iterative scaling algorithm to equilibrate rows and column norms in matrices
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
Scalar coeff(Index row, Index col) const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
const unsigned int RowMajorBit
remove_all< _Lhs >::type Lhs
remove_all< _Rhs >::type Rhs
ReturnByValue< KroneckerProduct > Base
const unsigned int HereditaryBits
KroneckerProductSparse(const Lhs &A, const Rhs &B)
Constructor.
Interfaces matrix-vector operations tailored to general sparse matrices.
remove_all< _Lhs >::type Lhs
scalar_product_traits< typename Lhs::Scalar, typename Rhs::Scalar >::ReturnType Scalar
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
const unsigned int EvalBeforeAssigningBit
internal::traits< KroneckerProductSparse >::Index Index
Expression of a fixed-size or dynamic-size block.
const SparseMatrix< _Scalar, _Options, _Index > & derived() const
Matrix< Scalar, Rows, Cols > ReturnType
KroneckerProduct(const Lhs &A, const Rhs &B)
Constructor.
KroneckerProduct< A, B > kroneckerProduct(const MatrixBase< A > &a, const MatrixBase< B > &b)
const unsigned int EvalBeforeNestingBit
The matrix class, also used for vectors and row-vectors.
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Base class for all dense matrices, vectors, and expressions.
Kronecker tensor product helper class for dense matrices.
Kronecker tensor product helper class for sparse matrices.
Scalar coeff(Index i) const
promote_storage_type< typename traits< Lhs >::StorageKind, typename traits< Rhs >::StorageKind >::ret StorageKind