A Julia package for defining and working with linear maps, also known as linear transformations or linear operators acting on vectors. The only requirement for a LinearMap is that it can act on a vector (by multiplication) efficiently.
Other
303
stars
42
forks
source link
Multiplication of kronecker products is reversed #230
It seems that the product $(A_1 \otimes B_1) \cdot \dots\cdot (A_n \otimes B_n)$ is falsely computed as
$(A_n\cdot\dots\cdot A_1) \otimes (B_n\cdot\dots\cdot B_1)$ and not like $(A_1\cdot\dots\cdot A_n) \otimes (B_1\cdot\dots\cdot B_n)$ (the order of maps reversed)
One can check the following minimal working example:
using LinearAlgebra
using LinearMaps
A = [0 1; 0 0]
B = [0 0; 1 0]
J = LinearMap(I, 1)
Matrix(kron(J, A*B)) == Matrix(kron(J, A) * kron(J, B)) # should be true
It seems that the product $(A_1 \otimes B_1) \cdot \dots\cdot (A_n \otimes B_n)$ is falsely computed as $(A_n\cdot\dots\cdot A_1) \otimes (B_n\cdot\dots\cdot B_1)$ and not like $(A_1\cdot\dots\cdot A_n) \otimes (B_1\cdot\dots\cdot B_n)$ (the order of maps reversed) One can check the following minimal working example:
Applying
reverse()
on the tuples before the product should do the trick https://github.com/JuliaLinearAlgebra/LinearMaps.jl/blob/ee91b4f119e036aa403e3fb0d7c9094e51f46f70/src/kronecker.jl#L275