@@ -9,6 +9,7 @@ abstract type AbstractBasisLayout <: MemoryLayout end
99struct BasisLayout <: AbstractBasisLayout end
1010struct SubBasisLayout <: AbstractBasisLayout end
1111struct MappedBasisLayout <: AbstractBasisLayout end
12+ struct WeightedBasisLayout <: AbstractBasisLayout end
1213
1314abstract type AbstractAdjointBasisLayout <: MemoryLayout end
1415struct AdjointBasisLayout <: AbstractAdjointBasisLayout end
@@ -21,8 +22,8 @@ MemoryLayout(::Type{<:Weight}) = WeightLayout()
2122adjointlayout (:: Type , :: BasisLayout ) = AdjointBasisLayout ()
2223adjointlayout (:: Type , :: SubBasisLayout ) = AdjointSubBasisLayout ()
2324adjointlayout (:: Type , :: MappedBasisLayout ) = AdjointMappedBasisLayout ()
24- broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: BasisLayout ) = BasisLayout ()
25- broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: SubBasisLayout ) = SubBasisLayout ()
25+ broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: BasisLayout ) = WeightedBasisLayout ()
26+ broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: SubBasisLayout ) = WeightedBasisLayout ()
2627
2728combine_mul_styles (:: AbstractBasisLayout ) = LazyQuasiArrayApplyStyle ()
2829combine_mul_styles (:: AbstractAdjointBasisLayout ) = LazyQuasiArrayApplyStyle ()
8889_grid (_, P) = error (" Overload Grid" )
8990_grid (:: MappedBasisLayout , P) = igetindex .(Ref (parentindices (P)[1 ]), grid (demap (P)))
9091_grid (:: SubBasisLayout , P) = grid (parent (P))
92+ _grid (:: WeightedBasisLayout , P) = grid (last (P. args))
9193grid (P) = _grid (MemoryLayout (typeof (P)), P)
9294
93- function transform (L)
95+ struct TransformFactorization{T,Grid,Plan,IPlan} <: Factorization{T}
96+ grid:: Grid
97+ plan:: Plan
98+ iplan:: IPlan
99+ end
100+
101+ TransformFactorization (grid, plan) =
102+ TransformFactorization {promote_type(eltype(grid),eltype(plan)),typeof(grid),typeof(plan),Nothing} (grid, plan, nothing )
103+
104+
105+ TransformFactorization (grid, :: Nothing , iplan) =
106+ TransformFactorization {promote_type(eltype(grid),eltype(iplan)),typeof(grid),Nothing,typeof(iplan)} (grid, nothing , iplan)
107+
108+ grid (T:: TransformFactorization ) = T. grid
109+
110+ \ (a:: TransformFactorization{<:Any,<:Any,Nothing} , b:: AbstractQuasiVector ) = a. iplan \ convert (Array, b[a. grid])
111+ \ (a:: TransformFactorization , b:: AbstractQuasiVector ) = a. plan * convert (Array, b[a. grid])
112+
113+ \ (a:: TransformFactorization{<:Any,<:Any,Nothing} , b:: AbstractVector ) = a. iplan \ b
114+ \ (a:: TransformFactorization , b:: AbstractVector ) = a. plan * b
115+
116+ function _factorize (:: AbstractBasisLayout , L)
94117 p = grid (L)
95- p, L[p,:]
118+ TransformFactorization (p, nothing , factorize ( L[p,:]))
96119end
97120
98- function transform_ldiv (A, B, _)
99- p,T = transform (A)
100- T \ convert (Array, B[p])
121+ struct ProjectionFactorization{T, FAC <: Factorization{T} , INDS} <: Factorization{T}
122+ F :: FAC
123+ inds :: INDS
101124end
102125
126+ \ (a:: ProjectionFactorization , b:: AbstractQuasiVector ) = (a. F \ b)[a. inds]
127+ \ (a:: ProjectionFactorization , b:: AbstractVector ) = (a. F \ b)[a. inds]
128+
129+ _factorize (:: SubBasisLayout , L) = ProjectionFactorization (factorize (parent (L)), parentindices (L)[2 ])
130+
131+ transform_ldiv (A, B, _) = factorize (A) \ B
103132transform_ldiv (A, B) = transform_ldiv (A, B, axes (A))
104133
105134copy (L:: Ldiv{<:AbstractBasisLayout,<:Any,<:Any,<:AbstractQuasiVector} ) =
116145
117146
118147function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix,<:AbstractQuasiVector} )
119- p,T = transform (L. A)
148+ p,T = factorize (L. A)
120149 T \ L. B[p]
121150end
122151
126155# *(arguments(S)...)
127156
128157
158+
159+ # mass matrix
160+ # y = p(x), dy = p'(x) * dx
161+ # \int_a^b f(y) g(y) dy = \int_{-1}^1 f(p(x))*g(p(x)) * p'(x) dx
162+
163+
164+ _sub_getindex (A, kr, jr) = A[kr, jr]
165+ _sub_getindex (A, :: Slice , :: Slice ) = A
166+
167+ function copy (M:: QMul2 {<: QuasiAdjoint{<:Any,<:SubQuasiArray{<:Any,2,<:AbstractQuasiMatrix,<:Tuple{<:AbstractAffineQuasiVector,<:Any}}} ,
168+ <: SubQuasiArray{<:Any,2,<:AbstractQuasiMatrix,<:Tuple{<:AbstractAffineQuasiVector,<:Any}} })
169+ Ac, B = M. args
170+ A = Ac'
171+ PA,PB = parent (A),parent (B)
172+ kr,jr = parentindices (B)
173+ _sub_getindex ((PA' PB)/ kr. A,parentindices (A)[2 ],jr)
174+ end
175+
176+
129177# Differentiation of sub-arrays
130178function copy (M:: QMul2{<:Derivative,<:SubQuasiArray{<:Any,2,<:AbstractQuasiMatrix,<:Tuple{<:Inclusion,<:Any}}} )
131179 A, B = M. args
155203
156204# we represent as a Mul with a banded matrix
157205sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:Inclusion,<:AbstractUnitRange}} ) = SubBasisLayout ()
158- sublayout (:: BasisLayout , :: Type{<:Tuple{<:AbstractAffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
206+ sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:AbstractAffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
159207
160208@inline sub_materialize (:: AbstractBasisLayout , V:: AbstractQuasiArray ) = V
161209@inline sub_materialize (:: AbstractBasisLayout , V:: AbstractArray ) = V
0 commit comments