1
- using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, Test
1
+ using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, BandedMatrices, Test
2
2
import ClassicalOrthogonalPolynomials: Hilbert, StieltjesPoint, ChebyshevInterval, associated, Associated, orthogonalityweight, Weighted, gennormalizedpower, * , dot, PowerLawMatrix, PowKernelPoint
3
3
import InfiniteArrays: I
4
4
23
23
24
24
25
25
@testset " Singular integrals" begin
26
+ @testset " weights" begin
27
+ w_T = ChebyshevTWeight ()
28
+ w_U = ChebyshevUWeight ()
29
+ w_P = LegendreWeight ()
30
+ x = axes (w_T,1 )
31
+ H = inv .(x .- x' )
32
+ @test iszero (H* w_T)
33
+ @test (H* w_U)[0.1 ] ≈ π/ 10
34
+ @test (H* w_P)[0.1 ] ≈ log (1.1 ) - log (1 - 0.1 )
35
+
36
+ w_T = orthogonalityweight (chebyshevt (0 .. 1 ))
37
+ w_U = orthogonalityweight (chebyshevu (0 .. 1 ))
38
+ w_P = orthogonalityweight (legendre (0 .. 1 ))
39
+ x = axes (w_T,1 )
40
+ H = inv .(x .- x' )
41
+ @test iszero (H* w_T)
42
+ @test (H* w_U)[0.1 ] ≈ (2 * 0.1 - 1 )* π
43
+ @test (H* w_P)[0.1 ] ≈ (log (1 + (- 0.8 )) - log (1 - (- 0.8 )))
44
+ end
45
+
26
46
@testset " Stieltjes" begin
27
47
T = Chebyshev ()
28
48
wT = ChebyshevWeight () .* T
36
56
37
57
f = wT * [[1 ,2 ,3 ]; zeros (∞)];
38
58
J = T \ (x .* T)
39
-
59
+
40
60
@test π* ((z* I- J) \ f. args[2 ])[1 ,1 ] ≈ (S* f)[1 ]
41
61
@test π* ((z* I- J) \ f. args[2 ])[1 ,1 ] ≈ (S* f. args[1 ]* f. args[2 ])[1 ]
42
62
55
75
x = axes (T,1 )
56
76
@test inv .(t .- x' ) * Weighted (T) ≈ inv .((t+ eps ()im) .- x' ) * Weighted (T)
57
77
@test (inv .(t .- x' ) * Weighted (U))[1 : 10 ] ≈ (inv .((t+ eps ()im) .- x' ) * Weighted (U))[1 : 10 ]
58
-
78
+
59
79
t = 0.5
60
80
@test_broken inv .(t .- x' ) * Weighted (T)
61
81
@test_broken inv .(t .- x' ) * Weighted (U)
71
91
72
92
@testset " weights" begin
73
93
@test H * ChebyshevTWeight () ≡ QuasiZeros {Float64} ((x,))
74
- @test H * ChebyshevUWeight () ≡ QuasiFill ( 1.0 π,(x,))
94
+ @test H * ChebyshevUWeight () == π * x
75
95
@test (H * LegendreWeight ())[0.1 ] ≈ log ((0.1 + 1 )/ (1 - 0.1 ))
76
96
end
77
97
82
102
@test (Ultraspherical (1 ) \ (H* wT) * (wT \ wU))[1 : 10 ,1 : 10 ] ==
83
103
((Ultraspherical (1 ) \ Chebyshev ()) * (Chebyshev () \ (H* wU)))[1 : 10 ,1 : 10 ]
84
104
85
- # Other axes
86
- x = Inclusion (0 .. 1 )
87
- y = 2 x .- 1
88
- H = inv .(x .- x' )
105
+ @testset " Other axes" begin
106
+ x = Inclusion (0 .. 1 )
107
+ y = 2 x .- 1
108
+ H = inv .(x .- x' )
89
109
90
- wT2 = wT[y,:]
91
- wU2 = wU[y,:]
92
- @test (Ultraspherical (1 )[y,:]\ (H* wT2))[1 : 10 ,1 : 10 ] == diagm (1 => fill (- π,9 ))
93
- @test (Chebyshev ()[y,:]\ (H* wU2))[1 : 10 ,1 : 10 ] == diagm (- 1 => fill (1.0 π,9 ))
110
+ wT2 = wT[y,:]
111
+ wU2 = wU[y,:]
112
+ @test (Ultraspherical (1 )[y,:]\ (H* wT2))[1 : 10 ,1 : 10 ] == diagm (1 => fill (- π,9 ))
113
+ @test (Chebyshev ()[y,:]\ (H* wU2))[1 : 10 ,1 : 10 ] == diagm (- 1 => fill (1.0 π,9 ))
114
+ end
94
115
95
116
@testset " Legendre" begin
96
117
P = Legendre ()
99
120
X = jacobimatrix (P)
100
121
@test Q[0.1 ,1 : 11 ]' * X[1 : 11 ,1 : 10 ] ≈ (0.1 * Array (Q[0.1 ,1 : 10 ])' - [2 zeros (1 ,9 )])
101
122
end
123
+
124
+ @testset " mapped" begin
125
+ T = chebyshevt (0 .. 1 )
126
+ U = chebyshevu (0 .. 1 )
127
+ x = axes (T,1 )
128
+ H = inv .(x .- x' )
129
+ @test U\ H* Weighted (T) isa BandedMatrix
130
+ end
102
131
end
103
132
104
133
@testset " Log kernel" begin
122
151
u = wT * (2 * (T \ exp .(x)))
123
152
@test u[0.1 ] ≈ exp (0.1 )/ sqrt (0.1 - 0.1 ^ 2 )
124
153
@test (L * u)[0.5 ] ≈ - 7.471469928754152 # Mathematica
154
+
155
+ @testset " mapped" begin
156
+ T = chebyshevt (0 .. 1 )
157
+ x = axes (T,1 )
158
+ L = log .(abs .(x .- x' ))
159
+ @test T[0.2 ,:]' * ((T\ L* Weighted (T)) * (T\ exp .(x))) ≈ - 2.9976362326874373 # Mathematica
160
+ end
125
161
end
126
162
127
163
@testset " pow kernel" begin
143
179
144
180
u = Weighted (U) * ((H * Weighted (U)) \ imag (c * x))
145
181
146
- ε = eps ();
182
+ ε = eps ();
147
183
@test (inv .(0.1 + ε* im .- x' ) * u + inv .(0.1 - ε* im .- x' ) * u)/ 2 ≈ imag (c* 0.1 )
148
184
@test real (inv .(0.1 + ε* im .- x' ) * u ) ≈ imag (c* 0.1 )
149
185
284
320
@time D = ClassicalOrthogonalPolynomials. LanczosData ((1.001 .- x). ^ 0.5 , P);
285
321
@time ClassicalOrthogonalPolynomials. resizedata! (D,100 );
286
322
end
287
- end
323
+ end
0 commit comments