File tree Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Expand file tree Collapse file tree 2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -6,20 +6,27 @@ is a quasi-vector representing `exp(-x^2)` on ℝ.
6
6
struct HermiteWeight{T} <: Weight{T} end
7
7
8
8
HermiteWeight () = HermiteWeight {Float64} ()
9
- axes (:: HermiteWeight{T} ) where T = (Inclusion (ℝ),)
9
+ axes (:: HermiteWeight{T} ) where T = (Inclusion {T} (ℝ),)
10
10
function getindex (w:: HermiteWeight , x:: Number )
11
11
x ∈ axes (w,1 ) || throw (BoundsError ())
12
12
exp (- x^ 2 )
13
13
end
14
14
15
15
sum (:: HermiteWeight{T} ) where T = sqrt (convert (T, π))
16
16
17
+ function broadcasted (:: typeof (^ ), H:: HermiteWeight , k:: Number )
18
+ x = axes (H,1 )
19
+ exp .((- k) .* x .^ 2 )
20
+ end
21
+
22
+ broadcasted (:: typeof (sqrt), H:: HermiteWeight{T} ) where T = H .^ (one (T)/ 2 )
23
+
17
24
struct Hermite{T} <: OrthogonalPolynomial{T} end
18
25
Hermite () = Hermite {Float64} ()
19
26
orthogonalityweight (:: Hermite{T} ) where T = HermiteWeight {T} ()
20
27
21
28
== (:: Hermite , :: Hermite ) = true
22
- axes (:: Hermite{T} ) where T = (Inclusion (ℝ), oneto (∞))
29
+ axes (:: Hermite{T} ) where T = (Inclusion {T} (ℝ), oneto (∞))
23
30
24
31
"""
25
32
hermiteh(n, z)
Original file line number Diff line number Diff line change @@ -31,12 +31,15 @@ import DomainSets: ℝ
31
31
end
32
32
33
33
@testset " OrthonormalWeighted" begin
34
- H = Hermite ()
35
- Q = OrthonormalWeighted (H)
36
-
37
- @test Q' Q == Eye (∞)
34
+ @testset " orthogonality" begin
35
+ H = Hermite ()
36
+ Q = OrthonormalWeighted (H)
37
+ @test Q' Q == Eye (∞)
38
+ end
38
39
39
40
@testset " evaluation" begin
41
+ H = Hermite ()
42
+ Q = OrthonormalWeighted (H)
40
43
x = 0.1
41
44
@test Q[x,1 ] ≈ exp (- x^ 2 / 2 )/ π^ (1 / 4 )
42
45
@test Q[x,2 ] ≈ 2 x* exp (- x^ 2 / 2 )/ (sqrt (2 )π^ (1 / 4 ))
@@ -46,6 +49,8 @@ import DomainSets: ℝ
46
49
end
47
50
48
51
@testset " Differentiation" begin
52
+ H = Hermite ()
53
+ Q = OrthonormalWeighted (H)
49
54
x = axes (Q,1 )
50
55
D = Derivative (x)
51
56
D¹ = Q \ (D * Q)
@@ -54,5 +59,10 @@ import DomainSets: ℝ
54
59
X = Q \ (x .* Q)
55
60
@test (D² - X^ 2 )[1 : 10 ,1 : 10 ] ≈ - Diagonal (1 : 2 : 19 )
56
61
end
62
+
63
+ @testset " BigFloat" begin
64
+ Q = OrthonormalWeighted (Hermite {BigFloat} ())
65
+ @test Q[40.0 , 1 ] ≈ exp (- big (40 )^ 2 / 2 ) * big (π)^ (- 1 / 4 )
66
+ end
57
67
end
58
68
end
You can’t perform that action at this time.
0 commit comments