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.645257 0.567612 0.932454 0.990796 … 0.0 0.0 0.0 0.139645 0.273465 0.556325 0.276149 1.0 0.0 0.0 0.69141 0.833255 0.787619 0.216127 0.0 1.0 0.0 0.800348 0.520627 0.975748 0.554424 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 … 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 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 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 1.0 0.0 0.0 0.0 0.567612 0.932454 0.990796 0.0 1.0 0.0 0.0 0.273465 0.556325 0.276149 0.0 0.0 1.0 0.0 0.833255 0.787619 0.216127 0.0 0.0 0.0 1.0 0.520627 0.975748 0.554424julia> exp(K)20×20 Kronecker.KroneckerProduct{Float64, Matrix{Float64}, Matrix{Float64}}: 8.08398 5.91398 8.60405 5.96569 0.0 … 8.27286 12.0359 8.3452 2.09225 4.32718 3.6085 1.94785 0.0 6.05314 5.04781 2.72479 4.78748 5.18581 8.43964 3.42519 0.0 7.25425 11.8059 4.79138 5.9525 5.42328 8.03003 6.72282 0.0 7.58644 11.2329 9.40432 6.34 4.63814 6.74788 4.6787 4.19039 5.69685 8.28816 5.74666 1.64088 3.39367 2.83003 1.52764 1.08453 … 4.16831 3.47602 1.87634 3.75467 4.06706 6.61893 2.68627 2.48163 4.99542 8.12978 3.29944 4.66835 4.2533 6.2977 5.27249 3.08552 5.22417 7.73522 6.47599 3.89359 2.84843 4.14408 2.87333 0.0 8.27286 12.0359 8.3452 1.00772 2.08415 1.73801 0.93817 0.0 6.05314 5.04781 2.72479 2.30586 2.49771 4.06489 1.64972 0.0 … 7.25425 11.8059 4.79138 2.86698 2.61208 3.86761 3.238 0.0 7.58644 11.2329 9.40432 3.89359 2.84843 4.14408 2.87333 0.0 8.27286 12.0359 8.3452 1.00772 2.08415 1.73801 0.93817 0.0 6.05314 5.04781 2.72479 2.30586 2.49771 4.06489 1.64972 0.0 7.25425 11.8059 4.79138 2.86698 2.61208 3.86761 3.238 0.0 … 7.58644 11.2329 9.40432 7.41481 5.42444 7.89183 5.47187 0.0 11.6108 16.8922 11.7123 1.91906 3.96899 3.3098 1.78662 0.0 8.49549 7.08451 3.82419 4.39119 4.75654 7.74103 3.14166 0.0 10.1812 16.5694 6.72463 5.45977 4.97436 7.36533 6.16632 0.0 10.6474 15.7652 13.1988julia> collect(K)20×20 SparseArrays.SparseMatrixCSC{Float64, Int64} with 116 stored entries: ⎡⣿⣿⠀⠀⠑⢄⠀⠀⠑⢄⎤ ⎢⠑⢄⣿⣿⠑⢄⠀⠀⠀⠀⎥ ⎢⠀⠀⠀⠀⣿⣿⠀⠀⠑⢄⎥ ⎢⠀⠀⠀⠀⠀⠀⣿⣿⠑⢄⎥ ⎣⠑⢄⠀⠀⠑⢄⠑⢄⣿⣿⎦
Kronecker.kroneckersum — Function
kroneckersum(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 — Method
collect(K::AbstractKroneckerSum)Collects a lazy instance of the AbstractKroneckerSum type into a full, native matrix. Returns the result as a sparse matrix.