-
Notifications
You must be signed in to change notification settings - Fork 308
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
Kronecker product #652
Comments
I myself have run into the need for an outer product of two vectors, which is of course a special case of the kronecker product. Looks like this used to exist in older versions of ndarray_linalg, but was removed at some point. On a related note, numpy also has support for some other outer operations, i.e. if fn outer_operation<T>(op: impl Fn(T, T) -> T, a: &Array1<T>, b: &Array1<T>) -> Array2<T> |
@termoshtt can you provide the rationale behind the removal of Kronecker product looks like a good addition - I have added the |
After some failed attempts I was able to come up with a working generic implementation of
I'm not even a week in to learning Rust, so take the above with a grain of salt. And any critique is welcome. |
Note that a Kronecker between non-square matrices will be a little different, but yes that looks correct for square matrices, which is what I think we both care about since we are using it for quantum computing purposes. For the more general kronecker it is kron(A, B) = C where A = x*y, B=m*n C= xm*yn of course. The more general implementation can be made in a very similar fashion, you just need to get the second dimension of b. Do you want to make a PR? If not I am happy to. |
Sometimes I forget non-square matrices exist :) Sure, I'll give it a try. |
Superseded by #1105 |
Myself (and another user on the rust discord) have run into the need for the kronecker product of two matrices.
I currently have code like:
(note: in my code I only work on unitary matrices, so this is not general in a few ways)
It would be nice to have a general implementation of this in ndarray (numpy as
np.kron
).The text was updated successfully, but these errors were encountered: