@@ -5,18 +5,27 @@ abstract type Weight{T} <: LazyQuasiVector{T} end
5
5
const WeightedBasis{T, A<: AbstractQuasiVector , B<: Basis } = BroadcastQuasiMatrix{T,typeof (* ),<: Tuple{A,B} }
6
6
7
7
struct WeightLayout <: MemoryLayout end
8
- struct BasisLayout <: MemoryLayout end
9
- struct AdjointBasisLayout <: MemoryLayout end
8
+ abstract type AbstractBasisLayout <: MemoryLayout end
9
+ struct BasisLayout <: AbstractBasisLayout end
10
+ struct SubBasisLayout <: AbstractBasisLayout end
11
+ struct MappedBasisLayout <: AbstractBasisLayout end
12
+
13
+ abstract type AbstractAdjointBasisLayout <: MemoryLayout end
14
+ struct AdjointBasisLayout <: AbstractAdjointBasisLayout end
15
+ struct AdjointSubBasisLayout <: AbstractAdjointBasisLayout end
16
+ struct AdjointMappedBasisLayout <: AbstractAdjointBasisLayout end
10
17
11
18
MemoryLayout (:: Type{<:Basis} ) = BasisLayout ()
12
19
MemoryLayout (:: Type{<:Weight} ) = WeightLayout ()
13
20
14
21
adjointlayout (:: Type , :: BasisLayout ) = AdjointBasisLayout ()
15
- transposelayout (:: Type{<:Real} , :: BasisLayout ) = AdjointBasisLayout ()
22
+ adjointlayout (:: Type , :: SubBasisLayout ) = AdjointSubBasisLayout ()
23
+ adjointlayout (:: Type , :: MappedBasisLayout ) = AdjointMappedBasisLayout ()
16
24
broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: BasisLayout ) = BasisLayout ()
25
+ broadcastlayout (:: Type{typeof(*)} , :: WeightLayout , :: SubBasisLayout ) = SubBasisLayout ()
17
26
18
- combine_mul_styles (:: BasisLayout ) = LazyQuasiArrayApplyStyle ()
19
- combine_mul_styles (:: AdjointBasisLayout ) = LazyQuasiArrayApplyStyle ()
27
+ combine_mul_styles (:: AbstractBasisLayout ) = LazyQuasiArrayApplyStyle ()
28
+ combine_mul_styles (:: AbstractAdjointBasisLayout ) = LazyQuasiArrayApplyStyle ()
20
29
21
30
ApplyStyle (:: typeof (pinv), :: Type{<:Basis} ) = LazyQuasiArrayApplyStyle ()
22
31
pinv (J:: Basis ) = apply (pinv,J)
@@ -25,7 +34,7 @@ _multup(a::Tuple) = Mul(a...)
25
34
_multup (a) = a
26
35
27
36
28
- function == (A:: Basis , B:: Basis )
37
+ function == (A:: Basis , B:: Basis )
29
38
axes (A) == axes (B) && throw (ArgumentError (" Override == to compare bases of type $(typeof (A)) and $(typeof (B)) " ))
30
39
false
31
40
end
@@ -36,42 +45,45 @@ ApplyStyle(::typeof(\), ::Type{<:Basis}, ::Type{<:AbstractQuasiVector}) = LdivAp
36
45
ApplyStyle (:: typeof (\ ), :: Type{<:SubQuasiArray{<:Any,2,<:Basis}} , :: Type{<:AbstractQuasiMatrix} ) = LdivApplyStyle ()
37
46
ApplyStyle (:: typeof (\ ), :: Type{<:SubQuasiArray{<:Any,2,<:Basis}} , :: Type{<:AbstractQuasiVector} ) = LdivApplyStyle ()
38
47
39
- copy (L:: Ldiv{BasisLayout,BroadcastLayout{typeof(+)}} ) = + (broadcast (\ ,Ref (L. A),arguments (L. B))... )
40
- function copy (L:: Ldiv{BasisLayout,BroadcastLayout{typeof(-)}} )
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))... )
51
+
52
+ function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)}} )
53
+ a,b = arguments (L. B)
54
+ (L. A\ a)- (L. A\ b)
55
+ end
56
+
57
+ function copy (L:: Ldiv{<:AbstractBasisLayout,BroadcastLayout{typeof(-)},<:Any,<:AbstractQuasiVector} )
41
58
a,b = arguments (L. B)
42
59
(L. A\ a)- (L. A\ b)
43
60
end
44
61
62
+ function copy (P:: Ldiv{BasisLayout,BasisLayout} )
63
+ A, B = P. A, P. B
64
+ A == B || throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
65
+ Eye (size (A,2 ))
66
+ end
67
+ function copy (P:: Ldiv{SubBasisLayout,SubBasisLayout} )
68
+ A, B = P. A, P. B
69
+ (parent (A) == parent (B) && parentindices (A) == parentindices (B)) ||
70
+ throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
71
+ Eye (size (A,2 ))
72
+ end
73
+
74
+ function copy (P:: Ldiv{MappedBasisLayout,MappedBasisLayout} )
75
+ A, B = P. A, P. B
76
+ demap (A)\ demap (B)
77
+ 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
83
+
45
84
for Bas1 in (:Basis , :WeightedBasis ), Bas2 in (:Basis , :WeightedBasis )
46
- @eval begin
47
- function copy (P:: Ldiv{<:Any,<:Any,<:$Bas1,<:$Bas2} )
48
- A, B = P. A, P. B
49
- A == B || throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
50
- Eye (size (A,2 ))
51
- end
52
- function copy (P:: Ldiv{<:Any,<:Any,<:SubQuasiArray{<:Any,2,<:$Bas1},<:SubQuasiArray{<:Any,2,<:$Bas2}} )
53
- A, B = P. A, P. B
54
- (parent (A) == parent (B) && parentindices (A) == parentindices (B)) ||
55
- throw (ArgumentError (" Override materialize for $(typeof (A)) \\ $(typeof (B)) " ))
56
- Eye (size (A,2 ))
57
- end
58
-
59
- function copy (P:: Ldiv {<: Any ,<: Any ,<: SubQuasiArray{<:Any,2,<:$Bas1,<:Tuple{<:AffineQuasiVector,<:Slice}} ,
60
- <: SubQuasiArray{<:Any,2,<:$Bas2,<:Tuple{<:AffineQuasiVector,<:Slice}} })
61
- A, B = P. A, P. B
62
- parent (A)\ parent (B)
63
- end
64
- function copy (P:: Ldiv {<: Any ,<: Any ,<: SubQuasiArray{<:Any,2,<:$Bas1,<:Tuple{<:AffineQuasiVector,<:Slice}} ,
65
- <: SubQuasiArray{<:Any,2,<:$Bas2,<:Tuple{<:AffineQuasiVector,<:Any}} })
66
- A, B = P. A, P. B
67
- # use lazy_getindex to avoid sparse arrays
68
- lazy_getindex (parent (A)\ parent (B),:,parentindices (B)[2 ])
69
- end
70
-
71
- function == (A:: SubQuasiArray{<:Any,2,<:$Bas1} , B:: SubQuasiArray{<:Any,2,<:$Bas2} )
72
- all (parentindices (A) == parentindices (B)) && parent (A) == parent (B)
73
- end
74
- end
85
+ @eval == (A:: SubQuasiArray{<:Any,2,<:$Bas1} , B:: SubQuasiArray{<:Any,2,<:$Bas2} ) =
86
+ all (parentindices (A) == parentindices (B)) && parent (A) == parent (B)
75
87
end
76
88
77
89
@@ -82,15 +94,15 @@ function transform(L)
82
94
p,L[p,:]
83
95
end
84
96
85
- function copy (L:: Ldiv{BasisLayout ,<:Any,<:Any,<:AbstractQuasiVector} )
97
+ function copy (L:: Ldiv{<:AbstractBasisLayout ,<:Any,<:Any,<:AbstractQuasiVector} )
86
98
p,T = transform (L. A)
87
99
T \ L. B[p]
88
100
end
89
101
90
- copy (L:: Ldiv{BasisLayout ,ApplyLayout{typeof(*)},<:Any,<:AbstractQuasiVector} ) =
102
+ copy (L:: Ldiv{<:AbstractBasisLayout ,ApplyLayout{typeof(*)},<:Any,<:AbstractQuasiVector} ) =
91
103
copy (Ldiv {LazyLayout,ApplyLayout{typeof(*)}} (L. A, L. B))
92
104
93
- function copy (L:: Ldiv{BasisLayout ,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix,<:AbstractQuasiVector} )
105
+ function copy (L:: Ldiv{<:AbstractBasisLayout ,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix,<:AbstractQuasiVector} )
94
106
p,T = transform (L. A)
95
107
T \ L. B[p]
96
108
end
101
113
# *(arguments(S)...)
102
114
103
115
104
- # Differentiation of sub-arrays
116
+ # Differentiation of sub-arrays
105
117
function copy (M:: QMul2{<:Derivative,<:SubQuasiArray{<:Any,2,<:AbstractQuasiMatrix,<:Tuple{<:Inclusion,<:Any}}} )
106
118
A, B = M. args
107
119
P = parent (B)
@@ -115,7 +127,7 @@ function copy(M::QMul2{<:Derivative,<:SubQuasiArray{<:Any,2,<:AbstractQuasiMatri
115
127
(Derivative (axes (P,1 ))* P* kr. A)[kr,jr]
116
128
end
117
129
118
- function copy (L:: Ldiv{BasisLayout ,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix} )
130
+ function copy (L:: Ldiv{<:AbstractBasisLayout ,BroadcastLayout{typeof(*)},<:AbstractQuasiMatrix} )
119
131
args = arguments (L. B)
120
132
# this is a temporary hack
121
133
if args isa Tuple{AbstractQuasiMatrix,Number}
129
141
130
142
131
143
# we represent as a Mul with a banded matrix
132
- sublayout (:: BasisLayout , :: Type{<:Tuple{<:Inclusion,<:AbstractUnitRange}} ) = ApplyLayout {typeof(*)} ()
133
- sublayout (:: BasisLayout , :: Type{<:Tuple{<:AffineQuasiVector,<:AbstractUnitRange}} ) = BasisLayout ()
144
+ sublayout (:: AbstractBasisLayout , :: Type{<:Tuple{<:Inclusion,<:AbstractUnitRange}} ) = SubBasisLayout ()
145
+ sublayout (:: BasisLayout , :: Type{<:Tuple{<:AffineQuasiVector,<:AbstractUnitRange}} ) = MappedBasisLayout ()
146
+
147
+ demap (x) = x
148
+ demap (V:: SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:Any,<:Slice}} ) = parent (V)
149
+ function demap (V:: SubQuasiArray{<:Any,2} )
150
+ kr, jr = parentindices (V)
151
+ demap (parent (V)[kr,:])[:,jr]
152
+ end
153
+
154
+
155
+ # #
156
+ # SubLayout behaves like ApplyLayout{typeof(*)}
157
+
158
+ combine_mul_styles (:: SubBasisLayout ) = combine_mul_styles (ApplyLayout {typeof(*)} ())
159
+ _arguments (:: SubBasisLayout , A) = _arguments (ApplyLayout {typeof(*)} (), A)
160
+ call (:: SubBasisLayout , :: SubQuasiArray ) = *
161
+
162
+ combine_mul_styles (:: AdjointSubBasisLayout ) = combine_mul_styles (ApplyLayout {typeof(*)} ())
163
+ _arguments (:: AdjointSubBasisLayout , A) = _arguments (ApplyLayout {typeof(*)} (), A)
164
+ arguments (:: AdjointSubBasisLayout , A) = arguments (ApplyLayout {typeof(*)} (), A)
165
+ call (:: AdjointSubBasisLayout , :: SubQuasiArray ) = *
166
+
134
167
function arguments (V:: SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:Inclusion,<:AbstractUnitRange}} )
135
168
A = parent (V)
136
169
_,jr = parentindices (V)
@@ -139,8 +172,8 @@ function arguments(V::SubQuasiArray{<:Any,2,<:Any,<:Tuple{<:Inclusion,<:Abstract
139
172
A,P
140
173
end
141
174
142
-
143
- include (" splines.jl" )
175
+ copy (L:: Ldiv{BasisLayout,SubBasisLayout} ) = apply (\ , L. A, ApplyQuasiArray (L. B))
144
176
145
177
146
178
179
+ include (" splines.jl" )
0 commit comments