Repository navigation
Support dims in 2D and 3D transform plans - #277
Merged
Merged
Conversation
Extend NDimsPlan so that dims may be a tuple of tuples, each listing the dimensions spanned by the slices a transform acts on. Slices are copied into a buffer stored in the plan, transformed in place, and copied back, so transforms only implemented on matrices can act on 3- and 4-arrays. For example dims = ((1,3), (2,4)) applies the transform to A[:,k,:,j] and then to A[k,:,j,:]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #277 +/- ##
==========================================
+ Coverage 77.48% 78.17% +0.68%
==========================================
Files 17 17
Lines 3247 3313 +66
==========================================
+ Hits 2516 2590 +74
+ Misses 731 723 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generate the dims methods from tables so that plan_sph2fourier, plan_sphv2fourier, plan_ann2cxf, plan_rectdisk2cheb, plan_tri2cheb, plan_tet2cheb, plan_spinsph2fourier and the corresponding FFTW synthesis and analysis plans all accept dims, like the disk plans. tet transforms act on 3-dimensional slices, so their dims entries are triples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
dimsargument, similar to FFTW.jl, to every plan for a transform acting on matrices or 3-arrays, so they can be applied to slices of higher-dimensional arrays.dimsis a tuple listing the dimensions of each slice, applied in order:Supported plans:
plan_sph2fourier,plan_sphv2fourier,plan_disk2cxf,plan_ann2cxf,plan_rectdisk2cheb,plan_tri2cheb,plan_spinsph2fourier,plan_tet2chebsph,sphv,disk,annulus,rectdisk,tri,spinsph,tetdimsis positional, as in FFTW. It goes after the transform parameters, which keep their defaults, and is told apart from them by being aTuple. For example,plan_disk2cxf(A, dims),plan_disk2cxf(A, α, β, dims),plan_annulus_analysis(A, ρ, dims; flags)andplan_spinsph2fourier(A, s, dims)all work. The existing convenience functions forward their arguments, sodisk2cxf/cxf2disk,tri2cheb/cheb2triand the rest acceptdimswith no further changes. The methods are generated from two tables insrc/arrays.jl, which also produce the docstrings.Implementation
This extends
NDimsPlanrather than adding a new plan type:dims: the existing vector-transform path throughArrayPlanis unchanged.dims: each entry lists the dimensions a slice spans. An entry(i, j)means rows run along dimensioniand columns along dimensionj, so((3,1),)transforms the transposed slices. Each slice is copied into a buffer stored in the plan, transformed in place withlmul!/ldiv!, and copied back. This works for any plan that supports in-place application to anArrayof the slice size, including vector plans, for example((2,), (3,)).\,inv,adjointandtransposeapply the factors in reverse order, which matters when dims overlap, e.g.((1,3), (2,3)).inv(plan_disk_analysis(A, dims)) isa typeof(plan_disk_synthesis(A, dims)), matching Inv of synthesis #274.FTPlan. The spin-weighted plans use a complex buffer.Throughput matches a hand-written loop over slices. For n = 50 and 40 slices,
plan_disk_analysistakes 51.6 ms with the plan versus 51.7 ms with the loop, and in-placelmul!allocates 160 bytes.Tests
For every plan listed above, the tests compare
*,'andtransposeagainst applying the plan slice by slice, and do the same for\where the underlying plan supports it. They also cover 4-arrays, transposed and overlapping dims, complex input, and errors for malformed dims, differing slice sizes and size mismatches.Limitations
dimsentry.invor\beyond the disk: among the FFTW plans, only the disk plans defineinv(Inv of synthesis #274), and none define\. The otherdimsplans therefore inherit the same limitation.NDimsPlangains a fifth type parameter,Buf. It isn't exported, and no package in my local depot uses it.Version bumped to 0.17.6.
🤖 Generated with Claude Code