Kronecker sums
A Kronecker sum between two square matrices of the same size is defined as
\[A \oplus B = A ⊗ I + I \oplus B\,.\]
To construct objects of the KroneckerSum type, one can either use kroneckersum or the binary operator ⊕. Lazy Kronecker sums work like lazy Kronecker products, though there are far fewer methods to process these constructs efficiently. The most important property for Kronecker sums relates to matrix exponentiation:
\[\exp(A \oplus B) = \exp(A) \otimes \exp(B)\,.\]
The function collect can be used to transform a KroneckerSum struct into a sparse array. It is recommended to make it 'dense' this way before doing operations such as multiplication with a vector.
julia> A, B = rand(Bool, 5, 5), rand(4, 4);julia> K = A ⊕ B20×20 KroneckerSum{Float64, Matrix{Bool}, Matrix{Float64}}: 0.689978 0.537508 0.382429 0.189431 … 0.0 0.0 0.0 0.594117 0.761856 0.295176 0.56654 1.0 0.0 0.0 0.639958 0.809272 0.36733 0.492077 0.0 1.0 0.0 0.82299 0.668781 0.630435 0.947146 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 … 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.537508 0.382429 0.189431 0.0 1.0 0.0 0.0 0.761856 0.295176 0.56654 0.0 0.0 1.0 0.0 0.809272 0.36733 0.492077 0.0 0.0 0.0 1.0 0.668781 0.630435 0.947146julia> exp(K)20×20 Kronecker.KroneckerProduct{Float64, Matrix{Float64}, Matrix{Float64}}: 11.2187 7.17498 4.42187 4.47579 … 7.96999 4.91183 4.97173 8.97294 13.1051 5.18867 7.42468 14.5572 5.76359 8.24736 9.30673 9.94582 9.06223 7.22779 11.0479 10.0664 8.02866 12.6375 11.9833 8.17501 14.5808 13.3111 9.08083 16.1964 9.19205 5.87885 3.62308 3.66726 7.31876 4.51048 4.56548 7.35202 10.7377 4.25136 6.08344 … 13.3677 5.29264 7.57346 7.6255 8.14915 7.42518 5.92212 10.1451 9.24382 7.37263 10.3546 9.81855 6.69823 11.9469 12.2234 8.33883 14.873 6.35435 4.06398 2.50459 2.53513 5.99716 3.69599 3.74106 5.08236 7.42284 2.93891 4.20541 10.9538 4.33691 6.20587 5.27142 5.63341 5.13293 4.09389 … 8.31315 7.5746 6.0413 7.15799 6.78744 4.63041 8.25872 10.0161 6.83303 12.1873 4.10294 2.62407 1.61719 1.63691 3.157 1.94563 1.96935 3.28163 4.79285 1.89763 2.71539 5.76624 2.28302 3.26687 3.4037 3.63744 3.31429 2.64339 4.37617 3.98739 3.18024 4.62185 4.38259 2.98981 5.33258 … 5.27265 3.59701 6.41558 6.29235 4.02432 2.48015 2.5104 5.32045 3.27894 3.31893 5.03277 7.35041 2.91023 4.16438 9.71779 3.84755 5.50561 5.21998 5.57844 5.08285 4.05395 7.37511 6.7199 5.35962 7.08815 6.72122 4.58522 8.17814 8.88595 6.06201 10.8121julia> collect(K)20×20 SparseArrays.SparseMatrixCSC{Float64, Int64} with 132 stored entries: ⎡⣿⣿⠑⢄⠑⢄⠑⢄⠑⢄⎤ ⎢⠑⢄⣿⣿⠑⢄⠀⠀⠑⢄⎥ ⎢⠀⠀⠑⢄⣿⣿⠑⢄⠑⢄⎥ ⎢⠀⠀⠑⢄⠀⠀⣿⣿⠀⠀⎥ ⎣⠑⢄⠀⠀⠀⠀⠑⢄⣿⣿⎦
Kronecker.kroneckersum — Functionkroneckersum(A::AbstractMatrix, B::AbstractMatrix)Construct a sum of Kronecker products between two square matrices and their respective identity matrices. Does not evaluate the Kronecker products explicitly.
kroneckersum(A::AbstractMatrix, B::AbstractMatrix...)Higher-order lazy kronecker sum, e.g.
kroneckersum(A,B,C,D)kroneckersum(A::AbstractMatrix, pow::Int)Kronecker-sum power, computes A ⊕ A ⊕ ... ⊕ A = (A ⊗ I ⊗ ... ⊗ I) + (I ⊗ A ⊗ ... ⊗ I) + ... (I ⊗ I ⊗ ... A).
Kronecker.:⊕ — Function⊕(A::AbstractMatrix, B::AbstractMatrix)Binary operator for kroneckersum, computes as Lazy Kronecker sum. See kroneckersum for documentation.
Base.collect — Methodcollect(K::AbstractKroneckerSum)Collects a lazy instance of the AbstractKroneckerSum type into a full, native matrix. Returns the result as a sparse matrix.
Base.exp — Functionexp(K::AbstractKroneckerSum)Computes the matrix exponential of an AbstractKroneckerSum K. Returns an instance of KroneckerProduct.
Missing docstring for mul!(x::AbstractVector, K::AbstractKroneckerSum, v::AbstractVector). Check Documenter's build log for details.