Skip to content

Commit cd8ced2

Browse files
Fix roots eltype when there are no roots (#286)
1 parent 3f26a36 commit cd8ced2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/polynomials/standard-basis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function roots(p::P; kwargs...) where {T, P <: StandardBasisPolynomial{T}}
270270
R = eltype(one(T)/one(T))
271271
d = degree(p)
272272
if d < 1
273-
return []
273+
return R[]
274274
end
275275
d == 1 && return R[-p[0] / p[1]]
276276

test/StandardBasis.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ end
459459
@test sort(roots(p)) r
460460

461461
@test roots(p0) == roots(p1) == roots(pNULL) == []
462+
@test eltype(roots(p0)) == eltype(roots(p1)) == eltype(roots(pNULL)) == Float64
462463
@test P == LaurentPolynomial ? roots(variable(P)) == [0.0] : roots(P([0,1,0])) == [0.0]
463464

464465
@test roots(p2) == [-1]

0 commit comments

Comments
 (0)