Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
Eigen::KroneckerSum< LhsMatrix, RhsMatrix > Class Template Reference

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

Detailed Description

template<typename LhsMatrix, typename RhsMatrix>
class Eigen::KroneckerSum< LhsMatrix, RhsMatrix >

The Kronecker sum \( A \oplus B = A \otimes I + I \otimes B \) of two square matrices as an implicit operator that is never materialized.

For A of size n1 and B of size n2 the Kronecker sum is the n1*n2 x n1*n2 matrix whose block (i,j) is A(i,j)*I plus B on the diagonal blocks. It is the matrix of the separable operators that finite-difference and spectral discretizations produce on tensor-product grids: with Dx and Dy the 1-D second-difference matrices tridiag(1, -2, 1)/h^2, the 2-D Laplacian is \( D_y \oplus D_x \), the 3-D one \( D_z \oplus D_y \oplus D_x \), and an implicit Euler step of the heat equation, \( (I - \tau L) u = b \) with \( L = D_y \oplus D_x \), is \( \big((I - \tau D_y) \oplus (-\tau D_x)\big) u = b \), since \( I \otimes I = I \) lets a shift go into either factor.

With \( \mathrm{vec} \) stacking columns as for KroneckerOperator, the product is \( (A \oplus B)\,\mathrm{vec}(X) = \mathrm{vec}(B X + X A^T) \) for X of size n2 x n1: one product with each factor, O(n1 n2 (n1 + n2)) for dense factors and O(n1 nnz(B) + n2 nnz(A)) for sparse ones, with no identity ever formed. The factors may be of any kind KroneckerOperator accepts – dense, diagonal, sparse, Identity() or a KroneckerOperator – or a KroneckerSum itself, which is how sums of three or more factors are built (makeKroneckerSum(a, b, c, ...) nests to the right). A Kronecker sum may in turn be a factor of a KroneckerOperator.

The operator is closed under transpose, conjugate and adjoint ( \( (A \oplus B)^T = A^T \oplus B^T \)), materializes into a dense or a sparse matrix on assignment, and plugs into the matrix-free iterative solvers (with IdentityPreconditioner). solve and the reusable BartelsStewart solver use the Schur forms of the factors; eigenvalues are the pairwise sums \( \lambda_i(A) + \mu_j(B) \), with eigenvectors \( V_A \otimes V_B \), also as a KroneckerOperator factor.

SparseMatrix<double> Dx = ..., Dy = ...; // tridiag(1, -2, 1) / h^2
SparseMatrix<double> Iy(ny, ny); Iy.setIdentity();
auto M = makeKroneckerSum(Iy - tau * Dy, -tau * Dx); // I - tau (Dy (+) Dx)
BartelsStewart<decltype(M)> step(M); // Schur forms, once
for (int k = 0; k < steps; ++k) u = step.solve(u); // implicit Euler
Direct solver for Kronecker-sum systems .
Definition KroneckerSum.h:554
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:479
Template Parameters
LhsMatrixthe type of the left factor A, see KroneckerOperator.
RhsMatrixthe type of the right factor B, under the same convention; its scalar type must match that of LhsMatrix.
See also
makeKroneckerSum(), class BartelsStewart, class KroneckerOperator
+ Inheritance diagram for Eigen::KroneckerSum< LhsMatrix, RhsMatrix >:

Public Member Functions

KroneckerSum< typename LhsOps::TransposedFactor, typename RhsOps::TransposedFactor > adjoint () const
 
Scalar coeff (Index row, Index col) const
 
KroneckerSum conjugate () const
 
ComplexVector eigenvalues () const
 
KroneckerOperator< typename LhsSpectrum::Eigenvectors, typename RhsSpectrum::Eigenvectors > eigenvectors () const
 
template<typename LhsDerived, typename RhsDerived>
 KroneckerSum (const EigenBase< LhsDerived > &a, const EigenBase< RhsDerived > &b)
 
const LhsMatrix & lhs () const
 
template<typename Rhs>
Product< KroneckerSum, Rhs > operator* (const MatrixBase< Rhs > &x) const
 
const RhsMatrix & rhs () const
 
template<typename Rhs>
Matrix< Scalar, ColsAtCompileTime, Rhs::ColsAtCompileTime > solve (const MatrixBase< Rhs > &b) const
 
KroneckerSum< typename LhsOps::TransposedFactor, typename RhsOps::TransposedFactor > transpose () const
 

Constructor & Destructor Documentation

◆ KroneckerSum()

template<typename LhsMatrix, typename RhsMatrix>
template<typename LhsDerived, typename RhsDerived>
Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::KroneckerSum ( const EigenBase< LhsDerived > & a,
const EigenBase< RhsDerived > & b )
inline

Builds the operator A (+) B from the two square factors, evaluated into the operator's factor types as for KroneckerOperator.

Member Function Documentation

◆ adjoint()

template<typename LhsMatrix, typename RhsMatrix>
KroneckerSum< typename LhsOps::TransposedFactor, typename RhsOps::TransposedFactor > Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::adjoint ( ) const
inline
Returns
the adjoint \( A^H \oplus B^H \), itself a Kronecker sum.

◆ coeff()

template<typename LhsMatrix, typename RhsMatrix>
Scalar Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::coeff ( Index row,
Index col ) const
inline
Returns
the coefficient at row row and column col: \( A(i_1, j_1)\,\delta_{i_2 j_2} + \delta_{i_1 j_1} B(i_2, j_2) \) with row = i1*n2 + i2 and col = j1*n2 + j2.

◆ conjugate()

template<typename LhsMatrix, typename RhsMatrix>
KroneckerSum Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::conjugate ( ) const
inline
Returns
the conjugate \( \bar A \oplus \bar B \), itself a Kronecker sum.

◆ eigenvalues()

template<typename LhsMatrix, typename RhsMatrix>
ComplexVector Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::eigenvalues ( ) const
inline
Returns
the eigenvalues in Kronecker order: entry i*n2 + j is \( \lambda_i(A) + \mu_j(B) \), from one eigenvalue solve per factor (recursively for a Kronecker-sum factor, and for a Kronecker factor, whose own factors must then be square), matching column i*n2 + j of eigenvectors. The set is not sorted.

Each sum carries the errors of the factor eigenvalues, of order \( \epsilon\,(\kappa(\lambda_i) \|A\| + \kappa(\mu_j) \|B\|) \) for simple eigenvalues with condition numbers \( \kappa \), where a dense eigensolver of \( A \oplus B \) errs by \( \epsilon\,\kappa(\lambda_i)\,\kappa(\mu_j)\,\|A \oplus B\| \). The sums are thus the more accurate for ill-conditioned or defective factors, whose Jordan blocks lengthen in the sum, and the less accurate when a shift splits across the factors, as in \( (A + cI) \oplus (B - cI) \).

◆ eigenvectors()

template<typename LhsMatrix, typename RhsMatrix>
KroneckerOperator< typename LhsSpectrum::Eigenvectors, typename RhsSpectrum::Eigenvectors > Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::eigenvectors ( ) const
inline
Returns
the matrix of eigenvectors \( V_A \otimes V_B \) – a KroneckerOperator, never materialized – since \( (A \oplus B)(v_i \otimes w_j) = (\lambda_i + \mu_j)(v_i \otimes w_j) \): column i*n2 + j matches eigenvalues()[i*n2 + j]. Assign it to a dense matrix to materialize.

◆ lhs()

template<typename LhsMatrix, typename RhsMatrix>
const LhsMatrix & Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::lhs ( ) const
inline
Returns
the left factor A.

◆ operator*()

template<typename LhsMatrix, typename RhsMatrix>
template<typename Rhs>
Product< KroneckerSum, Rhs > Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::operator* ( const MatrixBase< Rhs > & x) const
inline
Returns
the product expression (*this) * x, evaluated through \( \mathrm{mat}(y) = B\,\mathrm{mat}(x) + \mathrm{mat}(x)\,A^T \).

◆ rhs()

template<typename LhsMatrix, typename RhsMatrix>
const RhsMatrix & Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::rhs ( ) const
inline
Returns
the right factor B.

◆ solve()

template<typename LhsMatrix, typename RhsMatrix>
template<typename Rhs>
Matrix< Scalar, ColsAtCompileTime, Rhs::ColsAtCompileTime > Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::solve ( const MatrixBase< Rhs > & b) const
inline
Returns
the solution of (*this) * x = b through a BartelsStewart solver set up for this call; construct the solver once instead to reuse its Schur forms across calls.

◆ transpose()

template<typename LhsMatrix, typename RhsMatrix>
KroneckerSum< typename LhsOps::TransposedFactor, typename RhsOps::TransposedFactor > Eigen::KroneckerSum< LhsMatrix, RhsMatrix >::transpose ( ) const
inline
Returns
the transpose \( A^T \oplus B^T \), itself a Kronecker sum.

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