Go to the documentation of this file.
12 #ifndef KRONECKER_TENSOR_PRODUCT_H
13 #define KRONECKER_TENSOR_PRODUCT_H
24 template<
typename Derived>
65 typename Lhs::Nested
m_A;
66 typename Rhs::Nested
m_B;
81 template<
typename Lhs,
typename Rhs>
96 template<
typename Dest>
void evalTo(Dest& dst)
const;
114 template<
typename Lhs,
typename Rhs>
129 template<
typename Dest>
void evalTo(Dest& dst)
const;
132 template<
typename Lhs,
typename Rhs>
133 template<
typename Dest>
136 const int BlockRows = Rhs::RowsAtCompileTime,
137 BlockCols = Rhs::ColsAtCompileTime;
138 const Index Br = m_B.rows(),
140 for (
Index i=0;
i < m_A.rows(); ++
i)
141 for (
Index j=0;
j < m_A.cols(); ++
j)
145 template<
typename Lhs,
typename Rhs>
146 template<
typename Dest>
149 Index Br = m_B.rows(), Bc = m_B.cols();
150 dst.resize(this->
rows(), this->
cols());
151 dst.resizeNonZeros(0);
156 const Lhs1 lhs1(m_A);
159 const Rhs1 rhs1(m_B);
168 VectorXi nnzA = VectorXi::Zero(Dest::IsRowMajor ? m_A.rows() : m_A.cols());
169 for (
Index kA=0; kA < m_A.outerSize(); ++kA)
170 for (LhsInnerIterator itA(lhs1,kA); itA; ++itA)
171 nnzA(Dest::IsRowMajor ? itA.row() : itA.col())++;
173 VectorXi nnzB = VectorXi::Zero(Dest::IsRowMajor ? m_B.rows() : m_B.cols());
174 for (
Index kB=0; kB < m_B.outerSize(); ++kB)
175 for (RhsInnerIterator itB(rhs1,kB); itB; ++itB)
176 nnzB(Dest::IsRowMajor ? itB.row() : itB.col())++;
179 dst.reserve(VectorXi::Map(nnzAB.
data(), nnzAB.size()));
182 for (
Index kA=0; kA < m_A.outerSize(); ++kA)
184 for (
Index kB=0; kB < m_B.outerSize(); ++kB)
186 for (LhsInnerIterator itA(lhs1,kA); itA; ++itA)
188 for (RhsInnerIterator itB(rhs1,kB); itB; ++itB)
190 Index i = itA.row() * Br + itB.row(),
191 j = itA.col() * Bc + itB.col();
192 dst.insert(
i,
j) = itA.value() * itB.value();
201 template<
typename _Lhs,
typename _Rhs>
219 template<
typename _Lhs,
typename _Rhs>
230 LhsFlags = Lhs::Flags,
231 RhsFlags = Rhs::Flags,
270 template<
typename A,
typename B>
297 template<
typename A,
typename B>
305 #endif // KRONECKER_TENSOR_PRODUCT_H
Namespace containing all symbols from the Eigen library.
Scalar coeff(Index i) const
A versatible sparse matrix representation.
Matrix< Scalar, Rows, Cols > ReturnType
Expression of a fixed-size or dynamic-size block.
Kronecker tensor product helper class for sparse matrices.
The base class of dense and sparse Kronecker product.
Scalar coeff(Index row, Index col) const
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
SparseMatrix< Scalar, 0, StorageIndex > ReturnType
remove_all< _Rhs >::type Rhs
const unsigned int RowMajorBit
ScalarBinaryOpTraits< typename Lhs::Scalar, typename Rhs::Scalar >::ReturnType Scalar
internal::traits< Derived > Traits
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
KroneckerProductSparse(const Lhs &A, const Rhs &B)
Constructor.
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
ScalarBinaryOpTraits< typename Lhs::Scalar, typename Rhs::Scalar >::ReturnType Scalar
promote_index_type< typename Lhs::StorageIndex, typename Rhs::StorageIndex >::type StorageIndex
KroneckerProductBase(const Lhs &A, const Rhs &B)
Constructor.
remove_all< _Lhs >::type Lhs
KroneckerProductBase< KroneckerProduct > Base
KroneckerProductBase< KroneckerProductSparse > Base
An InnerIterator allows to loop over the element of any matrix expression.
promote_index_type< typename Lhs::StorageIndex, typename Rhs::StorageIndex >::type StorageIndex
remove_all< _Rhs >::type Rhs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar * data() const
KroneckerProduct< A, B > kroneckerProduct(const MatrixBase< A > &a, const MatrixBase< B > &b)
The matrix class, also used for vectors and row-vectors.
Base class for all dense matrices, vectors, and expressions.
const unsigned int EvalBeforeNestingBit
const unsigned int HereditaryBits
Kronecker tensor product helper class for dense matrices.
cwise_promote_storage_type< typename traits< Lhs >::StorageKind, typename traits< Rhs >::StorageKind, scalar_product_op< typename Lhs::Scalar, typename Rhs::Scalar > >::ret StorageKind
KroneckerProduct(const Lhs &A, const Rhs &B)
Constructor.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
remove_all< _Lhs >::type Lhs
gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:01:28