@@ -9,6 +9,7 @@ abstract type AbstractBasisLayout <: MemoryLayout end
9
9
struct BasisLayout <: AbstractBasisLayout end
10
10
struct SubBasisLayout <: AbstractBasisLayout end
11
11
struct MappedBasisLayout <: AbstractBasisLayout end
12
+ struct WeightedBasisLayout <: AbstractBasisLayout end
12
13
13
14
abstract type AbstractAdjointBasisLayout <: MemoryLayout end
14
15
struct AdjointBasisLayout <: AbstractAdjointBasisLayout end
@@ -21,8 +22,8 @@ MemoryLayout(::Type{<:Weight}) = WeightLayout()
21
22
adjointlayout (:: Type , :: BasisLayout ) = AdjointBasisLayout ()
22
23
adjointlayout (:: Type , :: SubBasisLayout ) = AdjointSubBasisLayout ()
23
24
adjointlayout (:: 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 ()
26
27
27
28
combine_mul_styles (:: AbstractBasisLayout ) = LazyQuasiArrayApplyStyle ()
28
29
combine_mul_styles (:: AbstractAdjointBasisLayout ) = LazyQuasiArrayApplyStyle ()
88
89
_grid (_, P) = error (" Overload Grid" )
89
90
_grid (:: MappedBasisLayout , P) = igetindex .(Ref (parentindices (P)[1 ]), grid (demap (P)))
90
91
_grid (:: SubBasisLayout , P) = grid (parent (P))
92
+ _grid (:: WeightedBasisLayout , P) = grid (last (P. args))
91
93
grid (P) = _grid (MemoryLayout (typeof (P)), P)
92
94
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)
94
117
p = grid (L)
95
- p, L[p,:]
118
+ TransformFactorization (p, nothing , factorize ( L[p,:]))
96
119
end
97
120
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
101
124
end
102
125
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
103
132
transform_ldiv (A, B) = transform_ldiv (A, B, axes (A))
104
133
105
134
copy (L:: Ldiv{<:AbstractBasisLayout,<:Any,<:Any,<:AbstractQuasiVector} ) =
116
145
117
146
118
147
function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix,<:AbstractQuasiVector} )
119
- p,T = transform (L. A)
148
+ p,T = factorize (L. A)
120
149
T \ L. B[p]
121
150
end
122
151
126
155
# *(arguments(S)...)
127
156
128
157
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
+
129
177
# Differentiation of sub-arrays
130
178
function copy (M:: QMul2{<:Derivative,<:SubQuasiArray{<:Any,2,<:AbstractQuasiMatrix,<:Tuple{<:Inclusion,<:Any}}} )
131
179
A, B = M. args
155
203
156
204
# we represent as a Mul with a banded matrix
157
205
sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:Inclusion,<:AbstractUnitRange}} ) = SubBasisLayout ()
158
- sublayout (:: BasisLayout , :: Type{<:Tuple{<:AbstractAffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
206
+ sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:AbstractAffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
159
207
160
208
@inline sub_materialize (:: AbstractBasisLayout , V:: AbstractQuasiArray ) = V
161
209
@inline sub_materialize (:: AbstractBasisLayout , V:: AbstractArray ) = V
0 commit comments