Skip to content

Commit 8f83390

Browse files
committed
added tests for roots
1 parent 2e85ed1 commit 8f83390

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/roots.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ hesseneigvals!(C::UpperHessenberg{T,Matrix{T}}) where {T} = eigvals!(C.data)
6666
"""
6767
roots(c::ChebPoly{1,<:Real}; tol=5eps, maxsize::Integer=50)
6868
69-
Returns an array of the real roots of `c` on the interval `[lb,ub]` (the lower and
69+
Returns a sorted array of the real roots of `c` on the interval `[lb,ub]` (the lower and
7070
upper bounds of the interpolation domain).
7171
7272
Uses a colleague-matrix method combined with recursive subdivision of the domain

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ Random.seed!(314159) # make chainrules tests deterministic
2424
@test chebgradient(interp, x1) ′ (f(x1), f′(x1))
2525
test_frule(interp, x1, rtol=sqrt(eps(T)), atol=sqrt(eps(T)))
2626
test_rrule(interp, x1, rtol=sqrt(eps(T)), atol=sqrt(eps(T)))
27+
28+
@test roots(chebinterp(x -> 1.1, 10, 0,1)) Float64[]
29+
@test roots(chebinterp(x -> x - 0.1, 10, 0,1)) [0.1]
30+
@test roots(chebinterp(x -> (x - 0.1)*(x-0.2), 10, 0,1)) [0.1, 0.2]
31+
@test roots(chebinterp(cos, 10000, 0, 1000))/pi (0:317) .+ T(0.5)
2732
end
2833
end
2934

0 commit comments

Comments
 (0)