@@ -30,56 +30,53 @@ combine_mul_styles(::AbstractAdjointBasisLayout) = LazyQuasiArrayApplyStyle()
30
30
ApplyStyle (:: typeof (pinv), :: Type{<:Basis} ) = LazyQuasiArrayApplyStyle ()
31
31
pinv (J:: Basis ) = apply (pinv,J)
32
32
33
- _multup (a:: Tuple ) = Mul (a... )
34
- _multup (a) = a
35
-
36
33
37
34
function == (A:: Basis , B:: Basis )
38
35
axes (A) == axes (B) && throw (ArgumentError (" Override == to compare bases of type $(typeof (A)) and $(typeof (B)) " ))
39
36
false
40
37
end
41
38
39
+ @inline quasildivapplystyle (:: AbstractBasisLayout , :: AbstractBasisLayout ) = LdivApplyStyle ()
40
+ @inline quasildivapplystyle (:: AbstractBasisLayout , _) = LdivApplyStyle ()
41
+ @inline quasildivapplystyle (_, :: AbstractBasisLayout ) = LdivApplyStyle ()
42
42
43
- ApplyStyle (:: typeof (\ ), :: Type{<:Basis} , :: Type{<:AbstractQuasiMatrix} ) = LdivApplyStyle ()
44
- ApplyStyle (:: typeof (\ ), :: Type{<:Basis} , :: Type{<:AbstractQuasiVector} ) = LdivApplyStyle ()
45
- ApplyStyle (:: typeof (\ ), :: Type{<:SubQuasiArray{<:Any,2,<:Basis}} , :: Type{<:AbstractQuasiMatrix} ) = LdivApplyStyle ()
46
- ApplyStyle (:: typeof (\ ), :: Type{<:SubQuasiArray{<:Any,2,<:Basis}} , :: Type{<:AbstractQuasiVector} ) = LdivApplyStyle ()
47
43
48
- copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)}} ) = + (broadcast (\ ,Ref (L. A),arguments (L. B))... )
49
- copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)},<:Any,<:AbstractQuasiVector} ) =
50
- + ( broadcast ( \ , Ref ( L. A), arguments ( L. B)) ... )
44
+ @inline copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)}} ) = + (broadcast (\ ,Ref (L. A),arguments (L. B))... )
45
+ @inline copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(+)},<:Any,<:AbstractQuasiVector} ) =
46
+ transform_ldiv ( L. A, L. B)
51
47
52
- function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)}} )
48
+ @inline function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)}} )
53
49
a,b = arguments (L. B)
54
50
(L. A\ a)- (L. A\ b)
55
51
end
56
52
57
- function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)},<:Any,<:AbstractQuasiVector} )
58
- a,b = arguments (L. B)
59
- (L. A\ a)- (L. A\ b)
60
- end
53
+ @inline copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)},<:Any,<:AbstractQuasiVector} ) =
54
+ transform_ldiv (L. A, L. B)
61
55
62
56
function copy (P:: Ldiv{BasisLayout,BasisLayout} )
63
57
A, B = P. A, P. B
64
- A == B || throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
65
- Eye (size (A,2 ))
58
+ A == B || throw (ArgumentError (" Override copy for $(typeof (A)) \\ $(typeof (B)) " ))
59
+ SquareEye {eltype(P)} (size (A,2 ))
66
60
end
67
61
function copy (P:: Ldiv{SubBasisLayout,SubBasisLayout} )
68
62
A, B = P. A, P. B
69
63
(parent (A) == parent (B) && parentindices (A) == parentindices (B)) ||
70
- throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
71
- Eye (size (A,2 ))
64
+ throw (ArgumentError (" Override copy for $(typeof (A)) \\ $(typeof (B)) " ))
65
+ SquareEye {eltype(P)} (size (A,2 ))
72
66
end
73
67
74
- function copy (P:: Ldiv{MappedBasisLayout,MappedBasisLayout} )
68
+ @inline function copy (P:: Ldiv{MappedBasisLayout,MappedBasisLayout} )
75
69
A, B = P. A, P. B
76
70
demap (A)\ demap (B)
77
71
end
78
- # function copy(P::Ldiv{MappedBasisLayout,SubBasisLayout})
79
- # A, B = P.A, P.B
80
- # # use lazy_getindex to avoid sparse arrays
81
- # lazy_getindex(parent(A)\parent(B),:,parentindices(B)[2])
82
- # end
72
+
73
+ @inline copy (L:: Ldiv{BasisLayout,SubBasisLayout} ) = apply (\ , L. A, ApplyQuasiArray (L. B))
74
+ @inline function copy (L:: Ldiv{SubBasisLayout,BasisLayout} )
75
+ P = parent (L. A)
76
+ kr, jr = parentindices (L. A)
77
+ lazy_getindex (apply (\ , P, L. B), jr, :) # avoid sparse arrays
78
+ end
79
+
83
80
84
81
for Bas1 in (:Basis , :WeightedBasis ), Bas2 in (:Basis , :WeightedBasis )
85
82
@eval == (A:: SubQuasiArray{<:Any,2,<:$Bas1} , B:: SubQuasiArray{<:Any,2,<:$Bas2} ) =
88
85
89
86
90
87
# expansion
91
- grid (P) = error (" Overload Grid" )
88
+ _grid (_, P) = error (" Overload Grid" )
89
+ _grid (:: MappedBasisLayout , P) = igetindex .(Ref (parentindices (P)[1 ]), grid (demap (P)))
90
+ _grid (:: SubBasisLayout , P) = grid (parent (P))
91
+ grid (P) = _grid (MemoryLayout (typeof (P)), P)
92
+
92
93
function transform (L)
93
94
p = grid (L)
94
95
p,L[p,:]
95
96
end
96
97
97
- function copy (L :: Ldiv{<:AbstractBasisLayout,<:Any,<:Any,<:AbstractQuasiVector} )
98
- p,T = transform (L . A)
99
- T \ L . B[p]
98
+ function transform_ldiv (A, B, _ )
99
+ p,T = transform (A)
100
+ T \ convert (Array, B[p])
100
101
end
101
102
103
+ transform_ldiv (A, B) = transform_ldiv (A, B, axes (A))
104
+
105
+ copy (L:: Ldiv{<:AbstractBasisLayout,<:Any,<:Any,<:AbstractQuasiVector} ) =
106
+ transform_ldiv (L. A, L. B)
107
+
102
108
copy (L:: Ldiv{<:AbstractBasisLayout,ApplyLayout{typeof(*)},<:Any,<:AbstractQuasiVector} ) =
103
- copy (Ldiv {LazyLayout,ApplyLayout{typeof(*)}} (L. A, L. B))
109
+ transform_ldiv (L. A, L. B)
110
+
111
+ function copy (L:: Ldiv{ApplyLayout{typeof(*)},<:AbstractBasisLayout} )
112
+ args = arguments (L. A)
113
+ @assert length (args) == 2 # temporary
114
+ apply (\ , last (args), apply (\ , first (args), L. B))
115
+ end
116
+
104
117
105
118
function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix,<:AbstractQuasiVector} )
106
119
p,T = transform (L. A)
107
- T \ L. B[p]
120
+ T \ L. B[p]
108
121
end
109
122
110
123
# # materialize views
144
157
sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:Inclusion,<:AbstractUnitRange}} ) = SubBasisLayout ()
145
158
sublayout (:: BasisLayout , :: Type{<:Tuple{<:AffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
146
159
160
+ @inline sub_materialize (:: AbstractBasisLayout , V:: AbstractQuasiArray ) = V
161
+ @inline sub_materialize (:: AbstractBasisLayout , V:: AbstractArray ) = V
162
+
147
163
demap (x) = x
148
164
demap (V:: SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:Any,<:Slice}} ) = parent (V)
149
165
function demap (V:: SubQuasiArray{<:Any,2} )
@@ -172,8 +188,28 @@ function arguments(V::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:Inclusion,<:Abstract
172
188
A,P
173
189
end
174
190
175
- copy (L:: Ldiv{BasisLayout,SubBasisLayout} ) = apply (\ , L. A, ApplyQuasiArray (L. B))
191
+ # ###
192
+ # sum
193
+ # ###
176
194
195
+ _sum (V:: AbstractQuasiArray , dims) = __sum (MemoryLayout (typeof (V)), V, dims)
196
+ _sum (V:: AbstractQuasiArray , :: Colon ) = __sum (MemoryLayout (typeof (V)), V, :)
197
+ sum (V:: AbstractQuasiArray ; dims= :) = _sum (V, dims)
177
198
199
+ __sum (L, Vm, _) = error (" Override for $L " )
200
+ function __sum (:: SubBasisLayout , Vm, dims)
201
+ @assert dims == 1
202
+ sum (parent (Vm); dims= dims)[:,parentindices (Vm)[2 ]]
203
+ end
204
+ function __sum (:: ApplyLayout{typeof(*)} , V:: AbstractQuasiVector , :: Colon )
205
+ a = arguments (V)
206
+ first (apply (* , sum (a[1 ]; dims= 1 ), tail (a)... ))
207
+ end
208
+
209
+ function __sum (:: MappedBasisLayout , V:: AbstractQuasiArray , dims)
210
+ kr, jr = parentindices (V)
211
+ @assert kr isa AffineQuasiVector
212
+ sum (demap (V); dims= dims)/ kr. A
213
+ end
178
214
179
215
include (" splines.jl" )
0 commit comments