Kronecker¶
- class probnum.linops.Kronecker(A, B)¶
Bases:
probnum.linops.LinearOperator
Kronecker product of two linear operators.
The Kronecker product 1 \(A \otimes B\) of two linear operators \(A\) and \(B\) is given by
\[\begin{split}A \otimes B = \begin{bmatrix} A_{11} B & \dots & A_{1 m_1} B \\ \vdots & \ddots & \vdots \\ A_{n_11} B & \dots & A_{n_1 m_1} B \end{bmatrix}\end{split}\]where \(A_{ij}v=A(v_j e_i)\), where \(e_i\) is the \(i^{\text{th}}\) unit vector. The result is a new linear operator mapping from \(\mathbb{R}^{n_1n_2}\) to \(\mathbb{R}^{m_1m_2}\). By recognizing that \((A \otimes B)\operatorname{vec}(X) = AXB^{\top}\), the Kronecker product can be understood as “translation” between matrix multiplication and (row-wise) vectorization.
- Parameters
A (np.ndarray or LinearOperator) – The first operator.
B (np.ndarray or LinearOperator) – The second operator.
dtype (dtype) – Data type of the operator.
References
- 1
Van Loan, C. F., The ubiquitous Kronecker product, Journal of Computational and Applied Mathematics, 2000, 123, 85-100
See also
SymmetricKronecker
The symmetric Kronecker product of two linear operators.
Attributes Summary
Hermitian adjoint.
Transposed linear operator.
Data type of the linear operator.
Whether input dimension matches output dimension.
Number of linear operator dimensions.
Shape of the linear operator.
- rtype
Methods Summary
__call__
(x[, axis])Call self as a function.
adjoint
()Hermitian adjoint.
astype
(dtype[, order, casting, subok, copy])Cast a linear operator to a different
dtype
.broadcast_matmat
(matmat)Broadcasting for a (implicitly defined) matrix-matrix product.
broadcast_matvec
(matvec)Broadcasting for a (implicitly defined) matrix-vector product.
broadcast_rmatmat
(rmatmat)broadcast_rmatvec
(rmatvec)cond
([p])Compute the condition number of the linear operator.
conj
()Complex conjugate linear operator.
Complex conjugate linear operator.
det
()Determinant of the linear operator.
eigvals
()Eigenvalue spectrum of the linear operator.
inv
()Inverse of the linear operator.
Log absolute determinant of the linear operator.
rank
()Rank of the linear operator.
todense
([cache])Dense matrix representation of the linear operator.
trace
()Trace of the linear operator.
Transpose this linear operator.
Attributes Documentation
- H¶
Hermitian adjoint.
- Return type
- T¶
Transposed linear operator.
- Return type
- ndim¶
Number of linear operator dimensions.
Defined analogously to
numpy.ndarray.ndim
.- Return type
- shape¶
Shape of the linear operator.
Defined as a tuple of the output and input dimension of operator.
Methods Documentation
- adjoint()¶
Hermitian adjoint.
- Return type
- astype(dtype, order='K', casting='unsafe', subok=True, copy=True)¶
Cast a linear operator to a different
dtype
.- Parameters
dtype (
Union
[dtype
,str
]) – Data type to which the linear operator is cast.order (
str
) – Memory layout order of the result.casting (
str
) – Controls what kind of data casting may occur.subok (
bool
) – If True, then sub-classes will be passed-through (default). False is currently not supported for linear operators.copy (
bool
) – Whether to return a new linear operator, even ifdtype
is the same.
- Return type
- classmethod broadcast_matmat(matmat)¶
Broadcasting for a (implicitly defined) matrix-matrix product.
Convenience function / decorator to broadcast the definition of a matrix-matrix product to vectors. This can be used to easily construct a new linear operator only from a matrix-matrix product.
- classmethod broadcast_matvec(matvec)¶
Broadcasting for a (implicitly defined) matrix-vector product.
Convenience function / decorator to broadcast the definition of a matrix-vector product. This can be used to easily construct a new linear operator only from a matrix-vector product.
- cond(p=None)¶
Compute the condition number of the linear operator.
The condition number of the linear operator with respect to the
p
norm. It measures how much the solution \(x\) of the linear system \(Ax=b\) changes with respect to small changes in \(b\).- Parameters
p ({None, 1, , 2, , inf, 'fro'}, optional) –
Order of the norm:
p
norm for matrices
None
2-norm, computed directly via singular value decomposition
’fro’
Frobenius norm
np.inf
max(sum(abs(x), axis=1))
1
max(sum(abs(x), axis=0))
2
2-norm (largest sing. value)
- Returns
The condition number of the linear operator. May be infinite.
- Return type
cond
- conj()¶
Complex conjugate linear operator.
- Return type
- conjugate()¶
Complex conjugate linear operator.
- Return type
- inv()¶
Inverse of the linear operator.
- Return type
- rank()¶
Rank of the linear operator.
- Return type
int64
- todense(cache=True)¶
Dense matrix representation of the linear operator.
This method can be computationally very costly depending on the shape of the linear operator. Use with caution.
- Returns
matrix – Matrix representation of the linear operator.
- Return type
np.ndarray
- trace()¶
Trace of the linear operator.
Computes the trace of a square linear operator \(\text{tr}(A) = \sum_{i-1}^n A_{ii}\).
- transpose()¶
Transpose this linear operator.
Can be abbreviated self.T instead of self.transpose().
- Return type