@@ -153,50 +153,68 @@ copy(L::Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(*)}}) = _broadcast_mul
153153copy (L:: Ldiv{<:MappedBasisLayouts,BroadcastLayout{typeof(*)}} ) = _broadcast_mul_ldiv (map (MemoryLayout,arguments (L. B)), L. A, L. B)
154154
155155
156- # expansion
157- grid_layout (_, P, n... ) = error (" Overload Grid" )
158156
159- grid_layout (:: MappedBasisLayout , P, n... ) = invmap (parentindices (P)[1 ])[grid (demap (P), n... )]
160- grid_layout (:: SubBasisLayout , P:: AbstractQuasiMatrix , n) = grid (parent (P), maximum (parentindices (P)[2 ][n]))
161- grid_layout (:: SubBasisLayout , P:: AbstractQuasiMatrix ) = grid (parent (P), maximum (parentindices (P)[2 ]))
162- grid_layout (:: WeightedBasisLayouts , P, n... ) = grid (unweighted (P), n... )
163157
164158
165159"""
166160 grid(P, n...)
167161
168162Creates a grid of points. if `n` is unspecified it will
169163be sufficient number of points to determine `size(P,2)`
170- coefficients. Otherwise its enough points to determine `n`
171- coefficients.
164+ coefficients. If `n` is an integer or `Block` its enough points to determine `n`
165+ coefficients. If `n` is a tuple then it returns a tuple of grids corresponding to a
166+ tensor-product. That is, a 5⨱6 2D transform would be
167+ ```julia
168+ (x,y) = grid(P, (5,6))
169+ plan_transform(P, (5,6)) * f.(x, y')
170+ ```
171+ and a 5×6×7 3D transform would be
172+ ```julia
173+ (x,y,z) = grid(P, (5,6,7))
174+ plan_transform(P, (5,6,7)) * f.(x, y', reshape(z,1,1,:))
175+ ```
172176"""
173- grid (P, n... ) = grid_layout (MemoryLayout (P), P, n... )
177+ grid (P, n:: Block{1} ) = grid_layout (MemoryLayout (P), P, n... )
178+ grid (P, n:: Integer ) = grid_layout (MemoryLayout (P), P, n... )
179+ grid (L, B:: Block ) = grid (L, Block .(B. n)) # grid(L, Block(2,3)) == grid(L, (Block(2), Block(3))
180+ grid (L, ns:: Tuple ) = grid .(Ref (L), ns)
181+ grid (L) = grid (L, size (L,2 ))
174182
183+ grid_layout (_, P, n) = grid_axis (axes (P,2 ), P, n)
175184
176- # values(f ) =
185+ grid_axis ( :: OneTo , P, n :: Block ) = grid (P, size (P, 2 ))
177186
187+ grid_layout (:: MappedBasisLayout , P, n) = invmap (parentindices (P)[1 ])[grid (demap (P), n)]
188+ grid_layout (:: SubBasisLayout , P:: AbstractQuasiMatrix , n) = grid (parent (P), parentindices (P)[2 ][n])
189+ grid_layout (:: WeightedBasisLayouts , P, n) = grid (unweighted (P), n)
178190
179191
180- function plan_grid_transform_layout (lay, L, szs :: NTuple{N,Int} , dims = 1 : N) where N
181- p = grid (L)
182- p, InvPlan ( factorize (L[p,:]), dims )
183- end
192+ # Default transform is just solve least squares on a grid
193+ # note this computes the grid an extra time.
194+ mapfactorize (L, n :: Integer ) = factorize (L[grid (L,n), OneTo (n)] )
195+ mapfactorize (L, n :: Block{1} ) = factorize (L[ grid (L,n), Block .( OneTo ( Int (n)))])
184196
185- function plan_grid_transform_layout (:: MappedBasisLayout , L, szs:: NTuple{N,Int} , dims= 1 : N) where N
186- x,F = plan_grid_transform (demap (L), szs, dims)
187- invmap (parentindices (L)[1 ])[x], F
197+ mapfactorize (L, ns) = map (n -> mapfactorize (L,n), ns)
198+ function plan_transform_layout (lay, L, szs:: NTuple{N,Union{Int,Block{1}}} , dims= ntuple (identity,Val (N))) where N
199+ dimsz = getindex .(Ref (szs), dims) # get the sizes of transformed dimensions
200+ InvPlan (mapfactorize (L, dimsz), dims)
188201end
202+ plan_transform_layout (:: MappedBasisLayout , L, szs:: NTuple{N,Union{Int,Block{1}}} , dims= ntuple (identity,Val (N))) where N = plan_transform (demap (L), szs, dims)
203+ plan_transform (L, szs:: NTuple{N,Union{Int,Block{1}}} , dims= ntuple (identity,Val (N))) where N = plan_transform_layout (MemoryLayout (L), L, szs, dims)
189204
190- plan_grid_transform (L, szs:: NTuple{N,Int} , dims= 1 : N) where N = plan_grid_transform_layout (MemoryLayout (L), L, szs, dims)
205+ plan_transform (L, arr:: AbstractArray , dims... ) = plan_transform (L, size (arr), dims... )
206+ plan_transform (L, lng:: Union{Integer,Block{1}} , dims... ) = plan_transform (L, (lng,), dims... )
207+ plan_transform (L) = plan_transform (L, size (L,2 ))
191208
192- plan_grid_transform (L, arr :: AbstractArray , dims... ) = plan_grid_transform (L, size (arr ), dims... )
193- plan_grid_transform (L, lng :: Union{Integer,Block{1}} , dims ... ) = plan_grid_transform (L, (lng,), dims ... )
209+ plan_transform (L, B :: Block , dims... ) = plan_transform (L, Block .(B . n ), dims... ) # grid(L, Block(2,3)) == grid(L, (Block(2), Block(3) )
210+
194211
195- plan_transform (P, szs, dims... ) = plan_grid_transform (P, szs, dims... )[2 ]
196212
197- _factorize (:: AbstractBasisLayout , L, dims... ; kws... ) =
198- TransformFactorization (plan_grid_transform (L, (size (L,2 ), dims... ), 1 )... )
213+ plan_grid_transform (P, szs:: NTuple{N,Union{Integer,Block{1}}} , dims= ntuple (identity,Val (N))) where N = grid (P, getindex .(Ref (szs), dims)), plan_transform (P, szs, dims)
214+ plan_grid_transform (P, lng:: Union{Integer,Block{1}} , dims= 1 ) = plan_grid_transform (P, (lng,), dims)
215+ plan_grid_transform (P, B:: Block{N} , dims= ntuple (identity,Val (N))) where N = plan_grid_transform (P, Block .(B. n), dims)
199216
217+ _factorize (:: AbstractBasisLayout , L, dims... ; kws... ) = TransformFactorization (plan_grid_transform (L, (size (L,2 ), dims... ), 1 )... )
200218
201219
202220"""
0 commit comments