-
Notifications
You must be signed in to change notification settings - Fork 184
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 & Sum #699
Comments
Thank you @adenchfi for the proposition. I support such an implementation, as it would have been useful for my work a few weeks ago ;) Re: the resulting array, the default in stdlib is that the resulting array is not allocatable, if the dimensions can be easily derived from the arguments. See for example the integer :: array(5,5)
integer, allocatable :: d(:)
...
d = diag(array)
... |
Glad to hear the support @jvdp1. I took your feedback and made an appropriate implementation, using the outer_product as a template. I am working on making a PR now; I am trying to figure out all I need to add for the testing suite. |
@adenchfi @jvdp1 I think it is better for the user to allocate the resulting array beforehand for performance reasons. This allows the function to use memory more efficiently and reduces the overhead associated with dynamic memory allocation. |
Motivation
Implement the Kronecker product (sometimes known as tensor or direct product) for matrices. The equivalent functionality in numpy is numpy.kron.
Additionally, implement the Kronecker sum, A (kron) I_B + I_A (kron) B, which is one way someone would do it when say creating a N-dimensional Laplacian stencil out of 1D stencils.
The numpy.kron convention for ordering matrix elements would be used.
To discuss:
Prior Art
No response
Additional Information
numpy.kron
The text was updated successfully, but these errors were encountered: