Eigen::KroneckerProductSparse< Lhs, Rhs > Class Template Reference

Kronecker tensor product helper class for sparse matrices. More...

#include <KroneckerTensorProduct.h>

+ Inheritance diagram for Eigen::KroneckerProductSparse< Lhs, Rhs >:

Public Member Functions

 KroneckerProductSparse (const Lhs &A, const Rhs &B)
 Constructor. More...
 
template<typename Dest >
void evalTo (Dest &dst) const
 Evaluate the Kronecker tensor product. More...
 
- Public Member Functions inherited from Eigen::KroneckerProductBase< KroneckerProductSparse< Lhs, Rhs > >
 KroneckerProductBase (const Lhs &A, const Rhs &B)
 Constructor. More...
 
Index rows () const
 
Index cols () const
 
Scalar coeff (Index row, Index col) const
 
Scalar coeff (Index i) const
 
- Public Member Functions inherited from Eigen::ReturnByValue< Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
const Unusablecoeff (Index) const
 
const Unusablecoeff (Index, Index) const
 
UnusablecoeffRef (Index)
 
UnusablecoeffRef (Index, Index)
 

Private Types

typedef KroneckerProductBase< KroneckerProductSparseBase
 

Additional Inherited Members

- Public Types inherited from Eigen::ReturnByValue< Derived >
typedef internal::traits< Derived >::ReturnType ReturnType
 
typedef internal::dense_xpr_base< ReturnByValue >::type Base
 
- Protected Types inherited from Eigen::KroneckerProductBase< KroneckerProductSparse< Lhs, Rhs > >
typedef Traits::Lhs Lhs
 
typedef Traits::Rhs Rhs
 
- Protected Attributes inherited from Eigen::KroneckerProductBase< KroneckerProductSparse< Lhs, Rhs > >
Lhs::Nested m_A
 
Rhs::Nested m_B
 

Detailed Description

template<typename Lhs, typename Rhs>
class Eigen::KroneckerProductSparse< Lhs, Rhs >

Kronecker tensor product helper class for sparse matrices.

If at least one of the operands is a sparse matrix expression, then this class is returned and evaluates into a sparse matrix.

This class is the return value of kroneckerProduct(EigenBase, EigenBase). Use the function rather than construct this class directly to avoid specifying template prarameters.

Template Parameters
LhsType of the left-hand side, a matrix expression.
RhsType of the rignt-hand side, a matrix expression.

Member Typedef Documentation

◆ Base

template<typename Lhs , typename Rhs >
typedef KroneckerProductBase<KroneckerProductSparse> Eigen::KroneckerProductSparse< Lhs, Rhs >::Base
private

Constructor & Destructor Documentation

◆ KroneckerProductSparse()

template<typename Lhs , typename Rhs >
Eigen::KroneckerProductSparse< Lhs, Rhs >::KroneckerProductSparse ( const Lhs A,
const Rhs B 
)
inline

Constructor.

118 : Base(A, B) {}
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
KroneckerProductBase< KroneckerProductSparse > Base
Definition: KroneckerTensorProduct.h:112
Definition: matrices.h:74

Member Function Documentation

◆ evalTo()

template<typename Lhs , typename Rhs >
template<typename Dest >
void Eigen::KroneckerProductSparse< Lhs, Rhs >::evalTo ( Dest &  dst) const

Evaluate the Kronecker tensor product.

137  {
138  Index Br = m_B.rows(), Bc = m_B.cols();
139  dst.resize(this->rows(), this->cols());
140  dst.resizeNonZeros(0);
141 
142  // 1 - evaluate the operands if needed:
143  typedef typename internal::nested_eval<Lhs, Dynamic>::type Lhs1;
144  typedef internal::remove_all_t<Lhs1> Lhs1Cleaned;
145  const Lhs1 lhs1(m_A);
146  typedef typename internal::nested_eval<Rhs, Dynamic>::type Rhs1;
147  typedef internal::remove_all_t<Rhs1> Rhs1Cleaned;
148  const Rhs1 rhs1(m_B);
149 
150  // 2 - construct respective iterators
151  typedef Eigen::InnerIterator<Lhs1Cleaned> LhsInnerIterator;
152  typedef Eigen::InnerIterator<Rhs1Cleaned> RhsInnerIterator;
153 
154  // compute number of non-zeros per innervectors of dst
155  {
156  // TODO VectorXi is not necessarily big enough!
157  VectorXi nnzA = VectorXi::Zero(Dest::IsRowMajor ? m_A.rows() : m_A.cols());
158  for (Index kA = 0; kA < m_A.outerSize(); ++kA)
159  for (LhsInnerIterator itA(lhs1, kA); itA; ++itA) nnzA(Dest::IsRowMajor ? itA.row() : itA.col())++;
160 
161  VectorXi nnzB = VectorXi::Zero(Dest::IsRowMajor ? m_B.rows() : m_B.cols());
162  for (Index kB = 0; kB < m_B.outerSize(); ++kB)
163  for (RhsInnerIterator itB(rhs1, kB); itB; ++itB) nnzB(Dest::IsRowMajor ? itB.row() : itB.col())++;
164 
165  Matrix<int, Dynamic, Dynamic, ColMajor> nnzAB = nnzB * nnzA.transpose();
166  dst.reserve(VectorXi::Map(nnzAB.data(), nnzAB.size()));
167  }
168 
169  for (Index kA = 0; kA < m_A.outerSize(); ++kA) {
170  for (Index kB = 0; kB < m_B.outerSize(); ++kB) {
171  for (LhsInnerIterator itA(lhs1, kA); itA; ++itA) {
172  for (RhsInnerIterator itB(rhs1, kB); itB; ++itB) {
173  Index i = itA.row() * Br + itB.row(), j = itA.col() * Bc + itB.col();
174  dst.insert(i, j) = itA.value() * itB.value();
175  }
176  }
177  }
178  }
179 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
An InnerIterator allows to loop over the element of any matrix expression.
Definition: CoreIterators.h:37
Rhs::Nested m_B
Definition: KroneckerTensorProduct.h:63
Lhs::Nested m_A
Definition: KroneckerTensorProduct.h:62
Index cols() const
Definition: KroneckerTensorProduct.h:42
Index rows() const
Definition: KroneckerTensorProduct.h:41
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
double Zero
Definition: pseudosolid_node_update_elements.cc:35
std::conditional_t< Evaluate, PlainObject, typename ref_selector< T >::type > type
Definition: XprHelper.h:549
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References cols, Eigen::PlainObjectBase< Derived >::data(), i, j, rows, and oomph::PseudoSolidHelper::Zero.


The documentation for this class was generated from the following file: