Skip to content

Commit f13e1f6

Browse files
committed
add degree test, modify divrem for 0 degree
1 parent 709cf0b commit f13e1f6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Polynomials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function divrem{T, S}(num::Poly{T}, den::Poly{S})
199199
error("Polynomials must have same variable")
200200
end
201201
m = degree(den)
202-
if m < 0
202+
if m == 0 && den[0] == 0
203203
throw(DivideError())
204204
end
205205
R = typeof(one(T)/one(S))

test/tests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ sprint(show, pNULL)
3232
@test pNULL^3 == pNULL
3333
@test pNULL*pNULL == pNULL
3434

35+
@test map(Polynomials.degree, [pNULL,p0,p1,p2,p3,p4,p5,pN,pR,p1000]) == [0,0,0,1,2,3,4,4,2,999]
36+
3537
@test polyval(pN, -.125) == 276.9609375
3638
@test polyval(pNULL, 10) == 0
3739
@test polyval(p0, -10) == 0

0 commit comments

Comments
 (0)