Skip to content

Commit

Permalink
Merge pull request #79 from aytekinar/78-bug-horner
Browse files Browse the repository at this point in the history
Bugfix in Horner's scheme
  • Loading branch information
jverzani authored Dec 12, 2016
2 parents 783fa05 + b8a6bf4 commit b53802d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Polynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function polyval{T,S}(p::Poly{T}, x::S)
if lenp == 0
return zero(R) * x
else
y = convert(R, p[end]) + zero(T)*x
y = convert(R, p[end])
for i = (endof(p)-1):-1:0
y = p[i] + x*y
end
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,11 @@ r = Poly([1.0, 2, 3])
p = poly([1,2,3])
q = poly([1,2,3])
@test hash(p) == hash(q)

## Check for Inf/NaN operations
p1 = Poly([Inf, Inf])
p2 = Poly([0, Inf])
@test p1(Inf) == Inf
@test isnan(p1(-Inf))
@test isnan(p1(0))
@test p2(-Inf) == -Inf

0 comments on commit b53802d

Please # to comment.