@@ -153,100 +153,78 @@ end
153
153
@test u[0.1 ] ≈ 0.00012678835289369413
154
154
end
155
155
156
+ @testset " Jacobi" begin
157
+ S = Jacobi (true ,true )
158
+ W = Diagonal (JacobiWeight (true ,true ))
159
+ D = Derivative (axes (W,1 ))
160
+ P = Legendre ()
156
161
157
- S = Jacobi (true ,true )
158
- W = Diagonal (JacobiWeight (true ,true ))
159
- D = Derivative (axes (W,1 ))
160
-
161
- A = @inferred (PInv (Jacobi (2 ,2 ))* D* S)
162
- @test A isa BandedMatrix
163
- @test size (A) == (∞,∞)
164
- @test A[1 : 10 ,1 : 10 ] == diagm (1 => 1 : 0.5 : 5 )
165
-
166
- M = @inferred (D* S)
167
- @test M isa Mul
168
- @test M. factors[1 ] == Jacobi (2 ,2 )
169
- @test M. factors[2 ][1 : 10 ,1 : 10 ] == A[1 : 10 ,1 : 10 ]
170
-
171
-
172
- L = Diagonal (JacobiWeight (true ,false ))
173
- A = @inferred (PInv (Jacobi (false ,true ))* L* S)
174
- @test A isa BandedMatrix
175
- @test size (A) == (∞,∞)
176
-
177
- L = Diagonal (JacobiWeight (false ,true ))
178
- A = @inferred (PInv (Jacobi (true ,false ))* L* S)
179
- @test A isa BandedMatrix
180
- @test size (A) == (∞,∞)
162
+ A = @inferred (PInv (Jacobi (2 ,2 ))* D* S)
163
+ @test A isa BandedMatrix
164
+ @test size (A) == (∞,∞)
165
+ @test A[1 : 10 ,1 : 10 ] == diagm (1 => 1 : 0.5 : 5 )
181
166
167
+ M = @inferred (D* S)
168
+ @test M isa Mul
169
+ @test M. factors[1 ] == Jacobi (2 ,2 )
170
+ @test M. factors[2 ][1 : 10 ,1 : 10 ] == A[1 : 10 ,1 : 10 ]
182
171
183
- L = Diagonal (JacobiWeight (true ,true ))
172
+ L = Diagonal (JacobiWeight (true ,false ))
173
+ A = @inferred (PInv (Jacobi (false ,true ))* L* S)
174
+ @test A isa BandedMatrix
175
+ @test size (A) == (∞,∞)
184
176
177
+ L = Diagonal (JacobiWeight (false ,true ))
178
+ A = @inferred (PInv (Jacobi (true ,false ))* L* S)
179
+ @test A isa BandedMatrix
180
+ @test size (A) == (∞,∞)
185
181
186
- L = Legendre ( )
182
+ A,B = (P ' P),( PInv (P) * W * S )
187
183
188
- A, B = (L' L),(PInv (L)* W* S)
184
+ M = Mul (A,B)
185
+ @test M[1 ,1 ] == 4 / 3
189
186
190
- M = A* B
191
- @which M. mul[1 ,1 ]
187
+ M = MulMatrix {Float64} (A,B)
188
+ M̃ = M[1 : 10 ,1 : 10 ]
189
+ @test M̃ isa BandedMatrix
190
+ @test bandwidths (M̃) == (2 ,0 )
192
191
193
- @which materialize ( Mul (A,B))
192
+ @test A * B isa MulArray
194
193
195
- M = LazyArrays. MulArray (Mul (A,B))
196
- axes (M)
197
194
198
- @time A[1 : 100000 ,1 : 100000 ]
199
- @profiler A. data[:,1 : 10_000 ]
200
-
201
- V = view (A. data,:,1 : 100 )
202
-
203
- N = 10_000 ; M = randn (3 ,N)
204
-
205
- A. data. arrays[2 ]
206
-
207
- @time begin
208
- M[1 ,:] .= view (A. data. arrays[1 ]' , 1 : N)
209
- M[2 ,:] .= view (A. data. arrays[2 ], 1 , 1 : N)
210
- M[3 ,:] .= view (A. data. arrays[3 ]' , 1 : N)
195
+ A,B,C = (PInv (P)* W* S)' ,(P' P),(PInv (P)* W* S)
196
+ M = MulArray (A,B,C)
197
+ @test typeof (A* B* C) == typeof (M)
198
+ @test M[1 ,1 ] ≈ 1 + 1 / 15
211
199
end
212
- M
213
-
214
- @which copyto! (M, V)
215
-
216
- @time
217
-
218
- typeof (V)
219
-
220
- using Profile
221
- Profile. clear ()
222
- @time randn (3 ,10_000 )
223
-
224
- W* S
225
-
226
-
227
200
201
+ S = Jacobi (true ,true )
202
+ W = Diagonal (JacobiWeight (true ,true ))
203
+ D = Derivative (axes (W,1 ))
204
+ P = Legendre ()
228
205
229
- M = Mul (S ' ,W ' ,W,S)
230
- materialize (M)
231
- materialize ( Mul (S ' ,W ' ,W))
206
+ N = 10
207
+ L = D * W * S[:, 1 : N]
208
+ Δ = L ' L # weak second derivative
232
209
233
- @which materialize (M)
210
+ M = Mul (Δ. factors[1 : 3 ])
211
+ LazyArrays. fullmaterialize (M)
212
+ P' * W* S
234
213
235
214
W* W
236
215
237
216
S' W' W* S
238
217
239
218
N = 10
240
- L = D* W* S[:,1 : N]
219
+ B = S[:,1 : N]
220
+ L = D* W*
241
221
# temporary work around to force 3-term materialize
242
222
L = * (L. factors[1 : 3 ]. .. ) * L. factors[4 ]
243
223
224
+ M = (D* W* S)' * (D* W* S)
225
+ M. factors[1 ]. mul. factors
244
226
245
- * (L. factors[1 : 3 ]. .. )
246
-
247
- @test L. factors isa Tuple{<: Legendre ,<: BandedMatrix ,<: BandedMatrix }
248
227
249
- Δ = L' L # weak second derivative
250
228
@test size (Δ) == (10 ,10 )
251
229
252
230
0 commit comments