|
1 | 1 | @testset "Densities" begin |
2 | | - f = x -> sin(2π*x) |
3 | | - g = x -> x*exp(-x) |
4 | | - h = x -> sin(2π*x)*x*exp(-x) |
5 | | - |
6 | | - rmin = 0.01 |
7 | | - rmax = 10.0 |
8 | | - ρ = 0.05 |
9 | | - N = ceil(Int, rmax/ρ) |
10 | | - k = 7 |
11 | | - Nn = 71 |
12 | | - |
13 | | - ρmin=rmin |
14 | | - ρmax=0.5 |
15 | | - α=0.01 |
16 | | - |
17 | | - @testset "$R" for (R,kind,rtol) in [ |
18 | | - (FiniteDifferences(N, ρ), :orthogonal_uniform, 1e-14), |
19 | | - (StaggeredFiniteDifferences(ρmin, ρmax, α, rmax, 0.0), :orthogonal_non_uniform, 1e-14), |
20 | | - (FEDVR(range(0, stop=rmax, length=Nn), k), :orthogonal_non_uniform, 1e-14), |
21 | | - (BSpline(LinearKnotSet(k, 0, rmax, Nn)), :non_orthogonal, 1e-5), |
22 | | - ] |
23 | | - r = axes(R,1) |
24 | | - |
25 | | - cf = R \ f.(r) |
26 | | - cg = R \ g.(r) |
27 | | - ch = R \ h.(r) |
28 | | - |
29 | | - ρ = Density(applied(*,R,cf), applied(*,R,cg)) |
30 | | - ch2 = ρ.ρ |
31 | | - |
32 | | - @test eltype(ρ) == eltype(cf) |
33 | | - |
34 | | - if kind == :orthogonal_uniform |
35 | | - @test ρ.LV == I |
36 | | - @test ρ.RV == I |
37 | | - @test ρ.C == I |
38 | | - elseif kind == :orthogonal_non_uniform |
39 | | - @test ρ.LV == I |
40 | | - @test ρ.RV == I |
41 | | - end |
| 2 | + @testset "Single functions" begin |
| 3 | + rmin = 0.01 |
| 4 | + rmax = 10.0 |
| 5 | + δr = 0.05 |
| 6 | + N = ceil(Int, rmax/δr) |
| 7 | + k = 7 |
| 8 | + Nn = 71 |
| 9 | + |
| 10 | + δrmin=rmin |
| 11 | + δrmax=0.5 |
| 12 | + α=0.01 |
| 13 | + |
| 14 | + @testset "$R" for (R,kind,rtol) in [ |
| 15 | + (FiniteDifferences(N, δr), :orthogonal_uniform, 1e-14), |
| 16 | + (StaggeredFiniteDifferences(δrmin, δrmax, α, rmax, 0.0), :orthogonal_non_uniform, 1e-14), |
| 17 | + (FEDVR(range(0, stop=rmax, length=Nn), k), :orthogonal_non_uniform, 1e-14), |
| 18 | + (BSpline(LinearKnotSet(k, 0, rmax, Nn)), :non_orthogonal, 1e-5), |
| 19 | + ] |
| 20 | + f = x -> sin(2π*x) |
| 21 | + g = x -> x*exp(-x) |
| 22 | + h = x -> sin(2π*x)*x*exp(-x) |
| 23 | + |
| 24 | + r = axes(R,1) |
| 25 | + |
| 26 | + cf = R \ f.(r) |
| 27 | + cg = R \ g.(r) |
| 28 | + ch = R \ h.(r) |
| 29 | + |
| 30 | + ρ = Density(applied(*,R,cf), applied(*,R,cg)) |
| 31 | + ch2 = ρ.ρ |
| 32 | + |
| 33 | + @test eltype(ρ) == eltype(cf) |
| 34 | + |
| 35 | + if kind == :orthogonal_uniform |
| 36 | + @test ρ.LV == I |
| 37 | + @test ρ.RV == I |
| 38 | + @test ρ.C == I |
| 39 | + elseif kind == :orthogonal_non_uniform |
| 40 | + @test ρ.LV == I |
| 41 | + @test ρ.RV == I |
| 42 | + end |
42 | 43 |
|
43 | | - @test ch2 ≈ ch atol=1e-14 rtol=rtol |
| 44 | + @test ch2 ≈ ch atol=1e-14 rtol=rtol |
| 45 | + end |
44 | 46 | end |
45 | 47 |
|
46 | 48 | @testset "Multiple functions" begin |
|
86 | 88 | end |
87 | 89 | end |
88 | 90 |
|
| 91 | + @testset "Restricted bases" begin |
| 92 | + rmin = 0.0 |
| 93 | + rmax = 10.0 |
| 94 | + δr = 0.05 |
| 95 | + N = ceil(Int, rmax/δr) |
| 96 | + k = 7 |
| 97 | + Nn = 71 |
| 98 | + |
| 99 | + δrmin=0.01 |
| 100 | + δrmax=0.5 |
| 101 | + α=0.01 |
| 102 | + |
| 103 | + f = x -> sinpi(x/rmax) |
| 104 | + g = x -> cospi(x/rmax) |
| 105 | + @testset "$(label)" for (w,label) in [(one,"Unweighted"),(exp,"Weighted")] |
| 106 | + h = x -> f(x)*w(x)*g(x) |
| 107 | + |
| 108 | + @testset "$R" for (R,rtol) in [ |
| 109 | + (FiniteDifferences(N, δr), 1e-15), |
| 110 | + (StaggeredFiniteDifferences(δrmin, δrmax, α, rmax, 0.0), 1e-15), |
| 111 | + (FEDVR(range(0, stop=rmax, length=Nn), k), 1e-15), |
| 112 | + (BSpline(LinearKnotSet(k, 0, rmax, Nn)), 1e-14), |
| 113 | + ] |
| 114 | + display(R) |
| 115 | + R̃ = R[:,1:ceil(Int, size(R,2))] |
| 116 | + |
| 117 | + r = axes(R̃,1) |
| 118 | + |
| 119 | + u = R̃ \ f.(r) |
| 120 | + v = R̃ \ g.(r) |
| 121 | + |
| 122 | + ρ = Density(applied(*, R̃, u), applied(*, R̃, v), w=w) |
| 123 | + @test ρ.ρ ≈ (R̃ \ h.(r)) rtol=rtol |
| 124 | + end |
| 125 | + end |
| 126 | + end |
| 127 | + |
89 | 128 | @testset "Pretty-printing" begin |
90 | 129 | R = FiniteDifferences(99, 0.1) |
91 | 130 | u = R*rand(size(R,2)) |
|
0 commit comments