Skip to content

Commit 709cf0b

Browse files
committed
modify degree for Poly([0.0]); polyder
Two small suggestions: * modify degree to return 0 for Poly([0.0]). Otherwise, recent change to * has issues * change factorial(i)/factorial(i-order) to prod(i-order+1:i) in polyder to avoid OverFlow error.
1 parent 8b9ebdf commit 709cf0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Polynomials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function degree{T}(p::Poly{T})
191191
return i
192192
end
193193
end
194-
return -1
194+
return 0
195195
end
196196

197197
function divrem{T, S}(num::Poly{T}, den::Poly{S})
@@ -278,7 +278,7 @@ function polyder{T}(p::Poly{T}, order::Int=1)
278278
else
279279
p2 = Poly(Array(T, n-order), p.var)
280280
for i = order:n-1
281-
p2[i-order] = p[i] * factorial(i)/factorial(i-order)
281+
p2[i-order] = p[i] * prod((i-order+1):i)
282282
end
283283
return p2
284284
end

0 commit comments

Comments
 (0)