Skip to content

Commit b53802d

Browse files
authored
Merge pull request #79 from aytekinar/78-bug-horner
Bugfix in Horner's scheme
2 parents 783fa05 + b8a6bf4 commit b53802d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Polynomials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ function polyval{T,S}(p::Poly{T}, x::S)
368368
if lenp == 0
369369
return zero(R) * x
370370
else
371-
y = convert(R, p[end]) + zero(T)*x
371+
y = convert(R, p[end])
372372
for i = (endof(p)-1):-1:0
373373
y = p[i] + x*y
374374
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,11 @@ r = Poly([1.0, 2, 3])
250250
p = poly([1,2,3])
251251
q = poly([1,2,3])
252252
@test hash(p) == hash(q)
253+
254+
## Check for Inf/NaN operations
255+
p1 = Poly([Inf, Inf])
256+
p2 = Poly([0, Inf])
257+
@test p1(Inf) == Inf
258+
@test isnan(p1(-Inf))
259+
@test isnan(p1(0))
260+
@test p2(-Inf) == -Inf

0 commit comments

Comments
 (0)