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}}: 0.313838 0.75306 0.0112007 0.540038 … 0.0 0.0 0.0 0.691031 0.641369 0.64634 0.209703 0.0 0.0 0.0 0.321617 0.216254 0.870073 0.304266 0.0 0.0 0.0 0.323434 0.104137 0.366677 0.78911 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 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.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.75306 0.0112007 0.540038 0.0 1.0 0.0 0.0 0.641369 0.64634 0.209703 0.0 0.0 1.0 0.0 0.216254 0.870073 0.304266 0.0 0.0 0.0 1.0 0.104137 0.366677 0.78911
julia> exp(K)
20×20 Kronecker.KroneckerProduct{Float64,Array{Float64,2},Array{Float64,2}}: 2.05929 1.50266 0.755388 1.30741 … 0.0 0.0 0.0 1.61831 2.65953 1.7201 1.13753 0.0 0.0 0.0 0.961594 0.839322 2.79314 1.03977 0.0 0.0 0.0 0.879089 0.611547 1.05038 2.61121 0.0 0.0 0.0 4.2274 3.08473 1.55069 2.68391 3.6496 1.83465 3.17538 3.32213 5.45959 3.53109 2.33517 … 6.45933 4.17769 2.76277 1.974 1.723 5.73388 2.13449 2.0385 6.78385 2.52535 1.80463 1.25541 2.15627 5.3604 1.4853 2.55112 6.34197 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 5.00151 3.6496 1.83465 3.17538 1.77809 0.893844 1.54705 3.93046 6.45933 4.17769 2.76277 3.14699 2.03538 1.34603 2.33547 2.0385 6.78385 2.52535 0.993162 3.3051 1.23035 2.13509 1.4853 2.55112 6.34197 … 0.723638 1.24291 3.08982 3.21084 2.34295 1.1778 2.03851 2.80931 1.41224 2.44427 2.52326 4.14673 2.68197 1.77363 4.97213 3.21581 2.12667 1.49932 1.30867 4.35506 1.62121 1.56916 5.22193 1.94391 1.37067 0.953524 1.63776 4.07139 1.14332 1.96375 4.88179
julia> collect(K)
20×20 SparseArrays.SparseMatrixCSC{Float64,Int64} with 116 stored entries: [1 , 1] = 0.313838 [2 , 1] = 0.691031 [3 , 1] = 0.321617 [4 , 1] = 0.323434 [13, 1] = 1.0 [17, 1] = 1.0 [1 , 2] = 0.75306 [2 , 2] = 0.641369 [3 , 2] = 0.216254 ⋮ [7 , 19] = 1.0 [17, 19] = 0.0112007 [18, 19] = 0.64634 [19, 19] = 0.870073 [20, 19] = 0.366677 [8 , 20] = 1.0 [17, 20] = 0.540038 [18, 20] = 0.209703 [19, 20] = 0.304266 [20, 20] = 0.78911
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.