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 ⊕ B
20×20 KroneckerSum{Float64,Array{Bool,2},Array{Float64,2}}: 1.608 0.352075 0.667224 0.664709 … 0.0 0.0 0.0 0.00531984 1.04514 0.511673 0.64536 0.0 0.0 0.0 0.550312 0.510038 1.40783 0.060821 0.0 0.0 0.0 0.203279 0.306009 0.32009 1.2033 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 1.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 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 1.0 0.0 0.0 0.0 0.352075 0.667224 0.664709 0.0 1.0 0.0 0.0 0.0451449 0.511673 0.64536 0.0 0.0 1.0 0.0 0.510038 0.407832 0.060821 0.0 0.0 0.0 1.0 0.306009 0.32009 0.203304
julia> exp(K)
20×20 Kronecker.KroneckerProduct{Float64,Array{Float64,2},Array{Float64,2}}: 6.45653 2.80238 4.43157 3.80859 … 0.0 0.0 0.0 0.96277 3.79902 2.51057 2.44324 0.0 0.0 0.0 2.92945 2.57698 5.75651 1.77922 0.0 0.0 0.0 1.40557 1.60163 2.0296 4.18399 0.0 0.0 0.0 10.9186 4.7391 7.49424 6.44071 1.14915 1.81722 1.56176 1.62814 6.42453 4.24563 4.13176 … 1.55784 1.02949 1.00188 4.95399 4.35793 9.73484 3.00884 1.05672 2.36053 0.72959 2.37696 2.70851 3.43226 7.07554 0.656768 0.832263 1.7157 10.4755 4.54676 7.19008 6.1793 2.24846 3.55564 3.05579 1.56206 6.16379 4.07332 3.96407 3.04811 2.01434 1.96031 4.75293 4.18106 9.33974 2.88672 … 2.06762 4.61869 1.42754 2.28049 2.59859 3.29296 6.78838 1.28505 1.62843 3.35699 8.48109 3.68111 5.82117 5.00284 3.39761 5.37286 4.61755 1.26466 4.99027 3.29781 3.20935 4.60595 3.04383 2.96219 3.84803 3.38504 7.56156 2.33712 3.12434 6.97921 2.15713 1.84631 2.10385 2.66602 5.49595 … 1.94182 2.4607 5.07268 9.64246 4.18519 6.6183 5.68791 2.49064 3.9386 3.38492 1.43784 5.67362 3.7494 3.64883 3.37642 2.23129 2.17145 4.37496 3.84857 8.59702 2.65716 2.29031 5.11615 1.5813 2.09914 2.39194 3.03109 6.24854 1.42346 1.80383 3.71856
julia> collect(K)
20×20 SparseArrays.SparseMatrixCSC{Float64,Int64} with 116 stored entries: [1 , 1] = 1.608 [2 , 1] = 0.00531984 [3 , 1] = 0.550312 [4 , 1] = 0.203279 [5 , 1] = 1.0 [9 , 1] = 1.0 [17, 1] = 1.0 [1 , 2] = 0.352075 [2 , 2] = 1.04514 ⋮ [17, 19] = 0.667224 [18, 19] = 0.511673 [19, 19] = 0.407832 [20, 19] = 0.32009 [12, 20] = 1.0 [16, 20] = 1.0 [17, 20] = 0.664709 [18, 20] = 0.64536 [19, 20] = 0.060821 [20, 20] = 0.203304
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.