@@ -49,164 +49,37 @@ let P = (n,k,a,b,c,x,y) -> x == 1.0 ? ((1-x))^k*jacobip(n-k,2k+b+c+1,a,1.0)*jaco
49
49
end
50
50
51
51
@testset " JacobiTriangle constructors" begin
52
- @time f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 )); # 0.08s
53
- @test f (0.1 ,0.2 ) ≈ cos (100 * 0.1 * 0.2 )
54
- P = plan_evaluate (f)
55
- @test values (f) ≈ P .(points (f))
56
-
57
- @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ),40_000 ); # 0.2
58
- @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
59
-
60
- @time f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,0.5 ,- 0.5 )); # 0.08s
61
- @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,0.5 ,- 0.5 ),40_000 ); # 0.2
62
- @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
63
-
64
- f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,0.5 ,0.5 )); # 1.15s
65
- f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,0.5 ,0.5 ),40_000 ); # 0.2
66
- @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
67
-
68
- f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 )); # 1.15s
69
- f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 ),40_000 ); # 0.2
70
- @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
71
-
72
- d = Triangle (Vec (0 ,0 ),Vec (3 ,4 ),Vec (1 ,6 ))
73
- @time f = Fun ((x,y)-> cos (x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ,d)); # 0.08s
74
- @test f (2 ,4 ) ≈ cos (2 * 4 )
75
- @time f = Fun ((x,y)-> cos (x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 ,d)); # 0.08s
76
- @test f (2 ,4 ) ≈ cos (2 * 4 )
77
- end
78
-
79
- @time f = Fun ((x,y)-> 1 ,JacobiTriangle (0.0 ,0.5 ,- 0.5 ),10 ); # 0.2
80
- p = points (JacobiTriangle (0.0 ,0.5 ,- 0.5 ),10 )
81
- S = space (f)
82
- P = plan_transform (S, f)
83
- v = (_ -> 1.0 ). (p)
84
-
85
- v̂ = P. duffyplan* v
86
- F = MultivariateOrthogonalPolynomials. tridevec_trans (v̂)
87
- @which P. tri2cheb \ F
88
- P = MultivariateOrthogonalPolynomials. c_plan_tri2cheb (4 , 0.0 , 0.5 , - 0.5 )
89
- F = zeros (4 ,4 ); F[1 ]= 1 ;
90
- MultivariateOrthogonalPolynomials. c_cheb2tri (P, F)
91
-
92
- P = MultivariateOrthogonalPolynomials. c_plan_tri2cheb (4 , 0.0 , - 0.5 , - 0.5 )
93
- F = zeros (4 ,4 ); F[1 ]= 1 ;
94
- MultivariateOrthogonalPolynomials. c_cheb2tri (P, F)
95
-
96
- F
97
-
98
- n = floor (Integer,sqrt (2 length (v)) + 1 / 2 )
99
- F̌ = P. tri2cheb \ F
100
- trivec (tridenormalize! (F̌,P. a,P. b,P. c))
101
-
102
- @time P (0.1 ,0.2 )
103
-
104
-
105
- @time f = Fun ((x,y) -> begin
106
- # ret = 0.0
107
- # for n = 18:18, k=8:8
108
- # ret += P(n,k,0.,-0.5,-0.5,x,y)
109
- # end
110
- # ret
111
- P (18 ,8 ,0. ,- 0.5 ,- 0.5 ,x,y)
112
- end ,
113
- JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ),600 ); # 0.08s
114
- sum (f. coefficients)
115
-
116
- n = 600
117
- S = JacobiTriangle (0.0 ,- 0.5 ,- 0.5 )
118
- ff = (xy) -> P (18 ,8 ,0. ,- 0.5 ,- 0.5 ,xy... )
119
- p = points (S,n)
120
- v = ff .(p)
121
- PP = plan_transform (S,v)
122
- v̂ = PP. duffyplan* v
123
- F = tridevec_trans (v̂)
124
- F̌ = FastTransforms. cheb2tri (F,0. ,- 0.5 ,- 0.5 )
125
- F̌₂ = PP. tri2cheb \ F
126
- norm (F̌ - F̌₂)
127
- size (F)
128
- F̃ = copy (F)
129
- c_cheb2tri (c_plan_tri2cheb (size (F,1 ),0.0 ,- 0.5 ,- 0.5 ),F̃)
130
- F̃ |> chopm
131
-
132
- @which PP. tri2cheb \ F
133
- trivec (tridenormalize! (F̌,P. a,P. b,P. c))
52
+ @time f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 )); # 0.08s
53
+ @test f (0.1 ,0.2 ) ≈ cos (100 * 0.1 * 0.2 )
54
+ P = plan_evaluate (f)
55
+ @test values (f) ≈ P .(points (f))
134
56
135
- sum (1 : 18 )
57
+ @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ),40_000 ); # 0.2
58
+ @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
136
59
60
+ @time f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,0.5 ,- 0.5 )); # 0.08s
61
+ @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,0.5 ,- 0.5 ),40_000 ); # 0.2
62
+ @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
137
63
138
- using SO
139
- tridevec (f. coefficients) |> chopm
64
+ f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,0.5 ,0.5 )); # 1.15s
65
+ f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,0.5 ,0.5 ),40_000 ); # 0.2
66
+ @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
140
67
68
+ f = Fun ((x,y)-> cos (100 x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 )); # 1.15s
69
+ f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 ),40_000 ); # 0.2
70
+ @test f (0.1 ,0.2 ) ≈ cos (500 * 0.1 * 0.2 )
141
71
142
- sum (1 : 16 )
143
-
144
- @test f (0.1 ,0.2 ) ≈ cos (0.1 * 0.2 )
145
-
146
- p = points (space (f), 150 )
147
-
148
- ff = (xy) -> cos (xy[1 ]* xy[2 ])
149
- ff .(p)
150
-
151
-
152
-
153
-
154
- @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ),40_000 ); # 0.2
155
- @time f = Fun ((x,y)-> cos (500 x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 )); # 0.2
156
-
157
- plot (f)
158
- ncoefficients (f)
159
-
160
- P = (n,k,a,b,c,x,y) -> x == 1.0 ? ((1 - x))^ k* jacobip (n- k,2 k+ b+ c+ 1 ,a,1.0 )* jacobip (k,c,b,- 1.0 ) :
161
- ((1 - x))^ k* jacobip (n- k,2 k+ b+ c+ 1 ,a,2 x- 1 )* jacobip (k,c,b,2 y/ (1 - x)- 1 )
162
-
163
- f = Fun ((x,y) -> P (5 ,1 ,0. ,0. ,0. ,x,y), JacobiTriangle (0. ,- 0.5 ,- 0.5 ) )
164
- F = tridevec (f. coefficients)
165
- F[:,2 ] = jjt (F[:,2 ], 2.0 , 0.0 , 3.0 , 0.0 ) # correct
166
- jjt (F[2 ,:], - 0.5 , - 0.5 , 0.0 , 0.0 )
167
- F
168
- jjt (F[:,1 ], 0.0 , 0.0 , 1.0 , 0.0 ) # correct
169
-
170
-
171
-
172
-
173
-
174
- jjt (jjt (F[:,1 ], 0.0 , - 0.5 , 0.0 , 0.0 ),0.0 ,0.0 ,1.0 ,0.0 )
175
-
176
- jac2jac (Fun (Fun (Legendre (),[0 ,0 ,1.0 ]),Jacobi (0.0 ,0.5 )). coefficients,
177
- 0.0 , 0.0 , 0.5 , 0.0 )
178
-
179
- jac2jac (Fun (x -> Fun (Jacobi (0.0 ,0.5 ),[0 ,0 ,1.0 ])(x),Legendre ()). coefficients,
180
- 0.0 , 0.0 , 0.5 , 0.0 )
181
-
182
- jjt (Fun (x -> jacobip (2 ,0.5 ,0.0 ,x),Legendre ()). coefficients,
183
- 0.0 , 0.0 , 0.5 , 0.0 )
184
-
185
- using SO
186
- Fun (Fun (Jacobi (- 0.5 ,0.0 ), [0 ,0 ,0 ,0 ,1.0 ]), Jacobi (0.0 ,0.0 ))
187
-
188
-
189
- Fun (Fun (Jacobi (0.0 ,- 0.5 ), [0 ,0 ,0 ,0 ,1.0 ]), Jacobi (0.0 ,0.0 ))
190
-
191
-
192
- v = f. coefficients
193
- N = floor (Integer,sqrt (2 length (v)) + 1 / 2 )
194
- ret = zeros (Float64, N, N)
195
- j = 1
196
- for n= 1 : N,k= 1 : n
197
- j > length (v) && return
198
- ret[n- k+ 1 ,k] = v[j]
199
- j += 1
200
- end
201
- ret
202
-
203
-
204
- v
72
+ d = Triangle (Vec (0 ,0 ),Vec (3 ,4 ),Vec (1 ,6 ))
73
+ @time f = Fun ((x,y)-> cos (x* y),JacobiTriangle (0.0 ,- 0.5 ,- 0.5 ,d)); # 0.08s
74
+ @test f (2 ,4 ) ≈ cos (2 * 4 )
75
+ @time f = Fun ((x,y)-> cos (x* y),JacobiTriangle (0.0 ,- 0.5 ,0.5 ,d)); # 0.08s
76
+ @test f (2 ,4 ) ≈ cos (2 * 4 )
77
+ end
205
78
206
79
207
80
@testset " old constructors" begin
208
81
f = Fun ((x,y)-> exp (x* cos (y)),JacobiTriangle (1 ,1 ,1 ))
209
- @test Fun (f, ProductTriangle ( 1 , 1 , 1 )) (0.1 ,0.2 ) ≈ exp (0.1 * cos (0.2 ))
82
+ @test f (0.1 ,0.2 ) ≈ exp (0.1 * cos (0.2 ))
210
83
f= Fun ((x,y)-> exp (x* cos (y)),JacobiTriangle (0 ,0 ,0 ))
211
84
@test f (0.1 ,0.2 ) ≈ exp (0.1 * cos (0.2 ))
212
85
d = Triangle (Vec (0 ,0 ),Vec (3 ,4 ),Vec (1 ,6 ))
256
129
f = Fun ((x,y)-> exp (x* cos (y)),JacobiTriangle (1 ,1 ,1 ))
257
130
Jx = MultivariateOrthogonalPolynomials. Lowering {1} (space (f))
258
131
testbandedblockbandedoperator (Jx)
259
- @test Fun (Jx* f,ProductTriangle (0 ,1 ,1 ))(0.1 ,0.2 ) ≈ 0.1 exp (0.1 * cos (0.2 ))
260
132
261
133
Jy = MultivariateOrthogonalPolynomials. Lowering {2} (space (f))
262
134
testbandedblockbandedoperator (Jy)
@@ -269,12 +141,12 @@ end
269
141
@test ApproxFun. colstop (Jy,4 ) == 8
270
142
271
143
272
- @test Fun (Jy* f, ProductTriangle ( 1 , 0 , 1 ) )(0.1 ,0.2 ) ≈ 0.2 exp (0.1 * cos (0.2 ))
144
+ @test (Jy* f)(0.1 ,0.2 ) ≈ 0.2 exp (0.1 * cos (0.2 ))
273
145
@test norm ((Jy* f- Fun ((x,y)-> y* exp (x* cos (y)),JacobiTriangle (1 ,0 ,1 ))). coefficients) < 1E-11
274
146
275
147
Jz = MultivariateOrthogonalPolynomials. Lowering {3} (space (f))
276
148
testbandedblockbandedoperator (Jz)
277
- @test Fun (Jz* f, ProductTriangle ( 1 , 1 , 0 ) )(0.1 ,0.2 ) ≈ (1 - 0.1 - 0.2 )exp (0.1 * cos (0.2 ))
149
+ @test (Jz* f)(0.1 ,0.2 ) ≈ (1 - 0.1 - 0.2 )exp (0.1 * cos (0.2 ))
278
150
279
151
@test f (0.1 ,0.2 ) ≈ exp (0.1 * cos (0.2 ))
280
152
494
366
495
367
f= Fun (S,rand (3 ))
496
368
h= 0.01
497
- QR= qrfact (I- h* Δ)
369
+ QR= qr (I- h* Δ)
498
370
@time u= \ (QR,f;tolerance= 1E-7 )
499
371
@time g= Fun (f,rangespace (QR))
500
372
@time \ (QR,g;tolerance= 1E-7 )
530
402
h= 0.01
531
403
Δ = Laplacian (S)
532
404
@test maxspace (rangespace (Δ), S) == JacobiTriangle (1 ,1 ,1 ,d)
533
- QR= qrfact (I- h* Δ)
405
+ QR= qr (I- h* Δ)
534
406
@time u= \ (QR,f;tolerance= 1E-7 )
535
407
@time g= Fun (f,rangespace (QR))
536
408
@time \ (QR,g;tolerance= 1E-7 )
0 commit comments