Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplication of kronecker products is reversed #230

Closed
apmypb opened this issue Jun 24, 2024 · 1 comment · Fixed by #231
Closed

Multiplication of kronecker products is reversed #230

apmypb opened this issue Jun 24, 2024 · 1 comment · Fixed by #231

Comments

@apmypb
Copy link

apmypb commented Jun 24, 2024

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)

@dkarrasch
Copy link
Member

Thanks for catching this! It had a test, which used the same linear maps, so didn't see the missing reverse. 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants