@@ -79,19 +79,20 @@ Fun(::typeof(identity), S::DiracSpace) = Fun(PointSpace(S.points),S.points)
79
79
transform (S:: PointSpace ,v:: AbstractVector ,plan... ) = v
80
80
values (f:: Fun{S} ) where S<: PointSpace = coefficient (f,:)
81
81
82
- function evaluate (f:: AbstractVector ,PS:: PointSpace ,x:: Number )
83
- p = findfirst (y-> isapprox (x,y),PS. points)
82
+ first (f:: Fun{<:PointSpace} ) = coefficients (f)[1 ]
83
+ last (f:: Fun{<:PointSpace} ) = coefficients (f)[end ]
84
+
85
+ function evaluate (f:: AbstractVector , PS:: PointSpace , x)
86
+ p = findfirst (≈ (convert (Number,x)), PS. points)
84
87
if p === nothing
85
88
zero (eltype (f))
86
89
else
87
90
f[p]
88
91
end
89
92
end
90
93
91
- function evaluate (f:: AbstractVector , PS:: DiracSpace , x:: Number )
92
- x ∉ domain (PS) && return zero (eltype (f))
93
-
94
- p = findfirst (y-> isapprox (x,y), PS. points)
94
+ function evaluate (f:: AbstractVector , PS:: DiracSpace , x)
95
+ p = findfirst (≈ (convert (Number,x)), PS. points)
95
96
if p === nothing
96
97
zero (eltype (f))
97
98
else
@@ -100,7 +101,7 @@ function evaluate(f::AbstractVector, PS::DiracSpace, x::Number)
100
101
end
101
102
102
103
Base. sum (f:: Fun{DS} ) where DS<: DiracSpace =
103
- sum (f. coefficients[1 : dimension (space (f))])
104
+ sum (@view f. coefficients[1 : dimension (space (f))])
104
105
105
106
DiracDelta (x:: Number )= Fun (DiracSpace (x),[1. ])
106
107
DiracDelta ()= DiracDelta (0. )
0 commit comments