Skip to content

Multiplication of kronecker products is reversed #230

Closed
@apmypb

Description

@apmypb

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

Applying reverse() on the tuples before the product should do the trick

_unsafe_mul!(y, kron(prod(As), prod(Bs)), x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions