Skip to content

Enhance Kronecker product to handle arbitrary dimension#3455

Closed
Delaney wants to merge 5 commits intojosdejong:v15from
Delaney:fix-kron-1d-output
Closed

Enhance Kronecker product to handle arbitrary dimension#3455
Delaney wants to merge 5 commits intojosdejong:v15from
Delaney:fix-kron-1d-output

Conversation

@Delaney
Copy link
Copy Markdown
Contributor

@Delaney Delaney commented Apr 18, 2025

Fixes #1753

  • Returns an empty 1D array for Kronecker product of two empty 1D arrays
  • Returns a 1D array for Kronecker product of two 1D arrays
  • In general, returns a Kronecker product of the max dimension of its two arguments

@gwhitney
Copy link
Copy Markdown
Collaborator

Thank you for preparing this PR for issue #1753! Please can you add all additional test cases mentioned anywhere in the discussion for #3133 just so that we can easily be sure none of the problems with that approach are surfacing in your new PR? Much appreciated.

@gwhitney gwhitney mentioned this pull request Apr 21, 2025
7 tasks
@Delaney
Copy link
Copy Markdown
Contributor Author

Delaney commented Apr 22, 2025

@gwhitney I had previously added the empty array and standard 1D cases, and I just added all the ones listed in this comment. I think that should cover it

  * Corrects doc example
  * Factors out 1-dimensional Kronecker product
  * Reimplement Kronecker product recursively to support arbitrary dimension
  * Adds further tests, including up to 3D Kronecker products
@gwhitney gwhitney changed the title Fix Kronecker 1D output Enhance Kronecker product to handle arbitrary dimension Apr 22, 2025
@gwhitney
Copy link
Copy Markdown
Collaborator

Thanks! Yours was the first correct implementation for the 1d Kronecker product, and it showed how the 1D product could be factored out of the 2D product, which in turn made it clear how to support arbitrary dimension of the arguments (recursively). I've now added a commit that implements all that, and corrected the doc test for kron which was failing (you should do npm run build-and-test before issuing a PR, sorry if the contributing docs don't mention that?).

Except for needing a HISTORY line (reviewer's responsibility, not yours), this is good to go -- except unfortunately it is a breaking change (alters kron([1,2], [1,3]) from what was previously documented), so it needs to be scheduled for v15. I will try to update the v15 branch and merge it there; we shall see, I may need Jos's help.

@gwhitney gwhitney changed the base branch from develop to v15 April 22, 2025 23:00
@gwhitney
Copy link
Copy Markdown
Collaborator

OK, I had to rebase on v15 to get the HISTORY straight, and since I didn't know if you would want me to force-push to your fork, I created the replacement copy #3461 of this, which I am closing this in favor of. Thanks for the contribution!

@gwhitney gwhitney closed this Apr 23, 2025
@josdejong
Copy link
Copy Markdown
Owner

Thanks @Delaney!

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 this pull request may close these issues.

Change function kron to output a 1d vector when input is 1d

3 participants