Using the vec-trick with higher order Kronecker products, such as
((τ1 ⊕ τ2) ⊗ (τ3 ⊕ τ4)) * vec(D)
should result in the lower-order products ( (τ1 ⊕ τ2) and (τ3 ⊕ τ4) ) being collected.
In my use case, the size of each (sparse) matrix is around N x N = 128 x 128. These matrices are stored in τ::Array{T<:Complex,4} with size(τ)= (N,N,M,L) . The sparsity pattern along M and L is assumed to be the same.
This would be more efficient if (sparse) workspace matrices are used to store the intermediate results,
reducing the number of allocations,
Last year, some work was started on kron! (JuliaLang/julia#31069) that computed the Kronecker product in-place.
-
Should this implementation by used? If so, should we wait for the PR to go through, or write these methods in Kronecker.jl?
-
Would it be enough to apply this to KroneckerProducts or do we need methods that specialize on other types, such as KroneckerSums and IndexedKroneckerProducts?
-
Currently sparse collects KroneckerSums. Shouldn't it be lazy by default to accommodate these in-place methods? I'm not sure how to generalize over all types, but do something like:
sparse(K::KroneckerSum) = sparse(K.A) ⊕ sparse(K.B)
Using the vec-trick with higher order Kronecker products, such as
should result in the lower-order products (
(τ1 ⊕ τ2)and(τ3 ⊕ τ4)) being collected.In my use case, the size of each (sparse) matrix is around
N x N = 128 x 128. These matrices are stored inτ::Array{T<:Complex,4}withsize(τ)= (N,N,M,L). The sparsity pattern alongMandLis assumed to be the same.This would be more efficient if (sparse) workspace matrices are used to store the intermediate results,
reducing the number of allocations,
Last year, some work was started on
kron!(JuliaLang/julia#31069) that computed the Kronecker product in-place.Should this implementation by used? If so, should we wait for the PR to go through, or write these methods in
Kronecker.jl?Would it be enough to apply this to
KroneckerProducts or do we need methods that specialize on other types, such asKroneckerSums andIndexedKroneckerProducts?Currently
sparsecollectsKroneckerSums. Shouldn't it be lazy by default to accommodate these in-place methods? I'm not sure how to generalize over all types, but do something like: