Skip to content

Commit cbe635b

Browse files
committed
subtract, not add; add simple tests
1 parent 7ee9cdc commit cbe635b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/polynomials/standard-basis/immutable-polynomial.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ derivative(p::ImmutableDensePolynomial{B,T,X,0}) where {B<:StandardBasis,T,X} =
145145
derivative(p::ImmutableDensePolynomial{B,T,X,1}) where {B<:StandardBasis,T,X} = zero(p)
146146

147147
function derivative(p::ImmutableDensePolynomial{B,T,X,N}) where {B<:StandardBasis,T,X,N}
148-
N == 0 && return p
149-
N == 1 && return zero(p)
150148
hasnan(p) && return ImmutableDensePolynomial{B,T,X,1}(zero(T)/zero(T)) # NaN{T}
151149
cs = ntuple(i -> i*p.coeffs[i+1], Val(N-1))
152150
R = eltype(cs)

test/StandardBasis.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,12 @@ end
10941094
@test_throws ArgumentError derivative(pR, -1)
10951095
@test integrate(P([1,1,0,0]), 0, 2) == 4.0
10961096

1097+
p₀, p₁, p₂ = zero(P), one(P), variable(P)
1098+
@test derivative(p₂) == p₁
1099+
@test derivative(p₁) == p₀
1100+
@test integrate(p₀, 1) == p₁
1101+
@test integrate(p₁) == p₂
1102+
10971103
P <: FactoredPolynomial && continue
10981104

10991105
@testset for i in 1:10

0 commit comments

Comments
 (0)