1- using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, Test
1+ using ClassicalOrthogonalPolynomials, ContinuumArrays, QuasiArrays, BandedMatrices, Test
22import ClassicalOrthogonalPolynomials: Hilbert, StieltjesPoint, ChebyshevInterval, associated, Associated, orthogonalityweight, Weighted, gennormalizedpower, * , dot, PowerLawMatrix, PowKernelPoint
33import InfiniteArrays: I
44
2323
2424
2525@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+
2646 @testset " Stieltjes" begin
2747 T = Chebyshev ()
2848 wT = ChebyshevWeight () .* T
3656
3757 f = wT * [[1 ,2 ,3 ]; zeros (∞)];
3858 J = T \ (x .* T)
39-
59+
4060 @test π* ((z* I- J) \ f. args[2 ])[1 ,1 ] ≈ (S* f)[1 ]
4161 @test π* ((z* I- J) \ f. args[2 ])[1 ,1 ] ≈ (S* f. args[1 ]* f. args[2 ])[1 ]
4262
5575 x = axes (T,1 )
5676 @test inv .(t .- x' ) * Weighted (T) ≈ inv .((t+ eps ()im) .- x' ) * Weighted (T)
5777 @test (inv .(t .- x' ) * Weighted (U))[1 : 10 ] ≈ (inv .((t+ eps ()im) .- x' ) * Weighted (U))[1 : 10 ]
58-
78+
5979 t = 0.5
6080 @test_broken inv .(t .- x' ) * Weighted (T)
6181 @test_broken inv .(t .- x' ) * Weighted (U)
7191
7292 @testset " weights" begin
7393 @test H * ChebyshevTWeight () ≡ QuasiZeros {Float64} ((x,))
74- @test H * ChebyshevUWeight () ≡ QuasiFill ( 1.0 π,(x,))
94+ @test H * ChebyshevUWeight () == π * x
7595 @test (H * LegendreWeight ())[0.1 ] ≈ log ((0.1 + 1 )/ (1 - 0.1 ))
7696 end
7797
82102 @test (Ultraspherical (1 ) \ (H* wT) * (wT \ wU))[1 : 10 ,1 : 10 ] ==
83103 ((Ultraspherical (1 ) \ Chebyshev ()) * (Chebyshev () \ (H* wU)))[1 : 10 ,1 : 10 ]
84104
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' )
89109
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
94115
95116 @testset " Legendre" begin
96117 P = Legendre ()
99120 X = jacobimatrix (P)
100121 @test Q[0.1 ,1 : 11 ]' * X[1 : 11 ,1 : 10 ] ≈ (0.1 * Array (Q[0.1 ,1 : 10 ])' - [2 zeros (1 ,9 )])
101122 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
102131 end
103132
104133 @testset " Log kernel" begin
122151 u = wT * (2 * (T \ exp .(x)))
123152 @test u[0.1 ] ≈ exp (0.1 )/ sqrt (0.1 - 0.1 ^ 2 )
124153 @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
125161 end
126162
127163 @testset " pow kernel" begin
143179
144180 u = Weighted (U) * ((H * Weighted (U)) \ imag (c * x))
145181
146- ε = eps ();
182+ ε = eps ();
147183 @test (inv .(0.1 + ε* im .- x' ) * u + inv .(0.1 - ε* im .- x' ) * u)/ 2 ≈ imag (c* 0.1 )
148184 @test real (inv .(0.1 + ε* im .- x' ) * u ) ≈ imag (c* 0.1 )
149185
284320 @time D = ClassicalOrthogonalPolynomials. LanczosData ((1.001 .- x). ^ 0.5 , P);
285321 @time ClassicalOrthogonalPolynomials. resizedata! (D,100 );
286322 end
287- end
323+ end
0 commit comments