Eigen-Contrib  5.0.1-dev+master
 
Loading...
Searching...
No Matches
Eigen::KroneckerSparseView< OperatorType, Options > Class Template Reference

#include <contrib/Eigen/src/StructuredMatrices/KroneckerSparseView.h>

Detailed Description

template<typename OperatorType, int Options>
class Eigen::KroneckerSparseView< OperatorType, Options >

A KroneckerOperator or KroneckerSum as a lazy sparse expression.

The view is a SparseMatrixBase expression whose inner vectors are iterated straight from the factors, so the operator takes part in sparse expressions, products and assignments without being materialized first. A product follows Eigen's cost model for its operands like any sparse expression: a sparse-sparse product, or one with a row-major dense right-hand side, revisits every inner vector of the view and evaluates it into a temporary first when an entry costs more to recompute than to read (complex scalars, whose multiply is dearer than a read).

auto L = makeKroneckerSum(Dy, Dx); // 2-D Laplacian
SparseMatrix<double> M = Id - tau * L.sparseView(); // assembled once, no temporary for L
SparseMatrix<double> P = L.sparseView() * S; // sparse-sparse product
KroneckerSum< typename internal::kron_factor_storage< LhsDerived >::type, typename internal::kron_factor_storage< RhsDerived >::type > makeKroneckerSum(const EigenBase< LhsDerived > &a, const EigenBase< RhsDerived > &b)
Definition KroneckerSum.h:496

Inner vector kA*n2' + kB of \( A \otimes B \) (n2' the outer size of B) is the product of inner vectors kA of A and kB of B, so an iterator walks the stored entries of two factor inner vectors; for \( A \oplus B \) it merges the entries of \( A \otimes I \) and \( I \otimes B \). The view stores exactly the entries a sparse materialization would: every stored entry of a factor, explicit zeros included, and nothing is pruned. It is the operand for sparse expressions and assembly; a product with a dense right-hand side is faster through the operator itself, which applies whole factors instead of one entry at a time.

The view owns a copy of the operator, with sparse factors converted to its storage order Options (ColMajor or RowMajor, which must match the other operands of a sparse binary expression). Like a SparseMatrix it is nested by reference in the expressions built from it, so an expression must not outlive a temporary view. Its StorageIndex, the index type of the temporaries Eigen evaluates it into, is the widest of its sparse factors' (int without any) and must hold its dimensions and stored-entry count; 64-bit sparse factors give a 64-bit view. Its InnerIterator is also the interface the coefficient-reading preconditioners take, e.g. DiagonalPreconditioner::compute(view). The view is not a matrix type for the iterative solvers themselves, which bind theirs through Ref; give them the operator (matrix-free, IdentityPreconditioner) or a materialized SparseMatrix.

Template Parameters
OperatorTypethe KroneckerOperator or KroneckerSum type.
OptionsColMajor or RowMajor, the storage order of the view.
Examples
a non-separable potential.
See also
KroneckerOperator::sparseView(), KroneckerSum::sparseView()
+ Inheritance diagram for Eigen::KroneckerSparseView< OperatorType, Options >:

Classes

class  InnerIterator
 

Public Member Functions

const ViewOperator & nestedOperator () const
 

Member Function Documentation

◆ nestedOperator()

template<typename OperatorType, int Options>
const ViewOperator & Eigen::KroneckerSparseView< OperatorType, Options >::nestedOperator ( ) const
inline
Returns
the operator the view iterates, with its sparse factors in the view's storage order.

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