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>
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(); }
49 Scalar coeff(Index row, Index col)
const 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());
55 Scalar coeff(Index i)
const 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>
106 typename Lhs::Nested m_A;
107 typename Rhs::Nested m_B;
110 template<
typename Lhs,
typename Rhs>
111 template<
typename Dest>
114 const int BlockRows = Rhs::RowsAtCompileTime,
115 BlockCols = Rhs::ColsAtCompileTime;
116 const Index Br = m_B.rows(),
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>
127 const Index Br = m_B.rows(),
129 dst.resize(rows(),cols());
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,
189 EvalToRowMajor = (LhsFlags & RhsFlags &
RowMajorBit),
192 Flags = ((LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
219 template<
typename A,
typename B>
236 template<
typename A,
typename B>
244 #endif // KRONECKER_TENSOR_PRODUCT_H A versatible sparse matrix representation.
Definition: SparseMatrix.h:85
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
Derived & derived()
Definition: EigenBase.h:34
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
Definition: KroneckerTensorProduct.h:112
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:26
The type used to identify a matrix expression.
Definition: Constants.h:431
Definition: ReturnByValue.h:50
KroneckerProductSparse(const Lhs &A, const Rhs &B)
Constructor.
Definition: KroneckerTensorProduct.h:87
const unsigned int EvalBeforeAssigningBit
means the expression should be evaluated before any assignment
Definition: Constants.h:63
Definition: BandTriangularSolver.h:13
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
KroneckerProduct(const Lhs &A, const Rhs &B)
Constructor.
Definition: KroneckerTensorProduct.h:39
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
KroneckerProduct< A, B > kroneckerProduct(const MatrixBase< A > &a, const MatrixBase< B > &b)
Definition: KroneckerTensorProduct.h:220
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:58
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
void evalTo(Dest &dst) const
Evaluate the Kronecker tensor product.
Definition: KroneckerTensorProduct.h:125
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
Kronecker tensor product helper class for dense matrices.
Definition: KroneckerTensorProduct.h:30
Definition: XprHelper.h:161
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
Kronecker tensor product helper class for sparse matrices.
Definition: KroneckerTensorProduct.h:80