@@ -36,7 +36,8 @@ import InfiniteLinearAlgebra: chop!, chop, choplength, compatible_resize!
36
36
import ContinuumArrays: Basis, Weight, basis, @simplify , Identity, AbstractAffineQuasiVector, ProjectionFactorization,
37
37
inbounds_getindex, grid, plotgrid, transform_ldiv, TransformFactorization, QInfAxes, broadcastbasis, ExpansionLayout, basismap,
38
38
AffineQuasiVector, AffineMap, WeightLayout, AbstractWeightedBasisLayout, WeightedBasisLayout, WeightedBasisLayouts, demap, AbstractBasisLayout, BasisLayout,
39
- checkpoints, weight, unweighted, MappedBasisLayouts, __sum, invmap, plan_ldiv, layout_broadcasted, MappedBasisLayout, SubBasisLayout, _broadcastbasis
39
+ checkpoints, weight, unweighted, MappedBasisLayouts, __sum, invmap, plan_ldiv, layout_broadcasted, MappedBasisLayout, SubBasisLayout, _broadcastbasis,
40
+ plan_transform, plan_grid_transform
40
41
import FastTransforms: Λ, forwardrecurrence, forwardrecurrence!, _forwardrecurrence!, clenshaw, clenshaw!,
41
42
_forwardrecurrence_next, _clenshaw_next, check_clenshaw_recurrences, ChebyshevGrid, chebyshevpoints, Plan
42
43
@@ -52,20 +53,13 @@ export OrthogonalPolynomial, Normalized, orthonormalpolynomial, LanczosPolynomia
52
53
∞, Derivative, .. , Inclusion,
53
54
chebyshevt, chebyshevu, legendre, jacobi, ultraspherical,
54
55
legendrep, jacobip, ultrasphericalc, laguerrel,hermiteh, normalizedjacobip,
55
- jacobimatrix, jacobiweight, legendreweight, chebyshevtweight, chebyshevuweight, Weighted, PiecewiseInterlace
56
+ jacobimatrix, jacobiweight, legendreweight, chebyshevtweight, chebyshevuweight, Weighted, PiecewiseInterlace, plan_transform
56
57
57
58
58
59
import Base: oneto
59
60
60
61
61
62
include (" interlace.jl" )
62
-
63
-
64
- cardinality (:: FullSpace{<:AbstractFloat} ) = ℵ₁
65
- cardinality (:: EuclideanDomain ) = ℵ₁
66
- cardinality (:: Union{DomainSets.RealNumbers,DomainSets.ComplexNumbers} ) = ℵ₁
67
- cardinality (:: Union{DomainSets.Integers,DomainSets.Rationals,DomainSets.NaturalNumbers} ) = ℵ₀
68
-
69
63
include (" standardchop.jl" )
70
64
include (" adaptivetransform.jl" )
71
65
@@ -95,9 +89,9 @@ _equals(::MappedOPLayout, ::MappedOPLayout, P, Q) = demap(P) == demap(Q) && basi
95
89
_equals (:: MappedOPLayout , :: MappedBasisLayouts , P, Q) = demap (P) == demap (Q) && basismap (P) == basismap (Q)
96
90
_equals (:: MappedBasisLayouts , :: MappedOPLayout , P, Q) = demap (P) == demap (Q) && basismap (P) == basismap (Q)
97
91
98
- _broadcastbasis (:: typeof (+ ), :: MappedOPLayout , :: MappedOPLayout , P, Q) where {L,M} = _broadcastbasis (+ , MappedBasisLayout (), MappedBasisLayout (), P, Q)
99
- _broadcastbasis (:: typeof (+ ), :: MappedOPLayout , M:: MappedBasisLayout , P, Q) where L = _broadcastbasis (+ , MappedBasisLayout (), M, P, Q)
100
- _broadcastbasis (:: typeof (+ ), L:: MappedBasisLayout , :: MappedOPLayout , P, Q) where M = _broadcastbasis (+ , L, MappedBasisLayout (), P, Q)
92
+ _broadcastbasis (:: typeof (+ ), :: MappedOPLayout , :: MappedOPLayout , P, Q) = _broadcastbasis (+ , MappedBasisLayout (), MappedBasisLayout (), P, Q)
93
+ _broadcastbasis (:: typeof (+ ), :: MappedOPLayout , M:: MappedBasisLayout , P, Q) = _broadcastbasis (+ , MappedBasisLayout (), M, P, Q)
94
+ _broadcastbasis (:: typeof (+ ), L:: MappedBasisLayout , :: MappedOPLayout , P, Q) = _broadcastbasis (+ , L, MappedBasisLayout (), P, Q)
101
95
__sum (:: MappedOPLayout , A, dims) = __sum (MappedBasisLayout (), A, dims)
102
96
103
97
# demap to avoid Golub-Welsch fallback
@@ -231,11 +225,6 @@ function recurrencecoefficients(C::SubQuasiArray{T,2,<:Any,<:Tuple{AbstractAffin
231
225
A * kr. A, A* kr. b + B, C
232
226
end
233
227
234
-
235
- _vec (a) = vec (a)
236
- _vec (a:: InfiniteArrays.ReshapedArray ) = _vec (parent (a))
237
- _vec (a:: Adjoint{<:Any,<:AbstractVector} ) = a'
238
-
239
228
include (" clenshaw.jl" )
240
229
include (" ratios.jl" )
241
230
include (" normalized.jl" )
@@ -270,24 +259,76 @@ function golubwelsch(V::SubQuasiArray)
270
259
x,w
271
260
end
272
261
273
- function factorize (L:: SubQuasiArray{T,2,<:Normalized,<:Tuple{Inclusion,OneTo}} , dims... ; kws... ) where T
274
- x,w = golubwelsch (L)
275
- TransformFactorization (x, L[x,:]' * Diagonal (w))
262
+ """
263
+ MulPlan(matrix, dims)
264
+
265
+ Takes a matrix and supports it applied to different dimensions.
266
+ """
267
+ struct MulPlan{T, Fact, Dims} # <: Plan{T} We don't depend on AbstractFFTs
268
+ matrix:: Fact
269
+ dims:: Dims
276
270
end
277
271
272
+ MulPlan (fact, dims) = MulPlan {eltype(fact), typeof(fact), typeof(dims)} (fact, dims)
273
+
274
+ function * (P:: MulPlan{<:Any,<:Any,Int} , x:: AbstractVector )
275
+ @assert P. dims == 1
276
+ P. matrix * x
277
+ end
278
278
279
- function factorize (L:: SubQuasiArray{T,2,<:OrthogonalPolynomial,<:Tuple{Inclusion,OneTo}} , dims... ; kws... ) where T
280
- Q = Normalized (parent (L))[parentindices (L)... ]
281
- D = L \ Q
282
- F = factorize (Q, dims... ; kws... )
283
- TransformFactorization (F. grid, D* F. plan)
279
+ function * (P:: MulPlan{<:Any,<:Any,Int} , X:: AbstractMatrix )
280
+ if P. dims == 1
281
+ P. matrix * X
282
+ else
283
+ @assert P. dims == 2
284
+ permutedims (P. matrix * permutedims (X))
285
+ end
284
286
end
285
287
286
- function factorize (L:: SubQuasiArray{T,2,<:OrthogonalPolynomial,<:Tuple{<:Inclusion,<:AbstractUnitRange}} , dims... ; kws... ) where T
287
- _,jr = parentindices (L)
288
- ProjectionFactorization (factorize (parent (L)[:,oneto (maximum (jr))], dims... ; kws... ), jr)
288
+ function * (P:: MulPlan{<:Any,<:Any,Int} , X:: AbstractArray{<:Any,3} )
289
+ Y = similar (X)
290
+ if P. dims == 1
291
+ for j in axes (X,3 )
292
+ Y[:,:,j] = P. matrix * X[:,:,j]
293
+ end
294
+ elseif P. dims == 2
295
+ for k in axes (X,1 )
296
+ Y[k,:,:] = P. matrix * X[k,:,:]
297
+ end
298
+ else
299
+ @assert P. dims == 3
300
+ for k in axes (X,1 ), j in axes (X,2 )
301
+ Y[k,j,:] = P. matrix * X[k,j,:]
302
+ end
303
+ end
304
+ Y
289
305
end
290
306
307
+ function * (P:: MulPlan , X:: AbstractArray )
308
+ for d in P. dims
309
+ X = MulPlan (P. matrix, d) * X
310
+ end
311
+ X
312
+ end
313
+
314
+ * (A:: AbstractMatrix , P:: MulPlan ) = MulPlan (A* P. matrix, P. dims)
315
+
316
+
317
+ function plan_grid_transform (Q:: Normalized , arr, dims= 1 : ndims (arr))
318
+ L = Q[:,OneTo (size (arr,1 ))]
319
+ x,w = golubwelsch (L)
320
+ x, MulPlan (L[x,:]' * Diagonal (w), dims)
321
+ end
322
+
323
+ function plan_grid_transform (P:: OrthogonalPolynomial , arr, dims... )
324
+ Q = Normalized (P)
325
+ x, A = plan_grid_transform (Q, arr, dims... )
326
+ n = size (arr,1 )
327
+ D = (P \ Q)[1 : n, 1 : n]
328
+ x, D * A
329
+ end
330
+
331
+
291
332
function \ (A:: SubQuasiArray{<:Any,2,<:OrthogonalPolynomial} , B:: SubQuasiArray{<:Any,2,<:OrthogonalPolynomial} )
292
333
axes (A,1 ) == axes (B,1 ) || throw (DimensionMismatch ())
293
334
_,jA = parentindices (A)
0 commit comments