Skip to content

Commit e63df3d

Browse files
committed
Include a method for derivative of constant ImmutableDensePolynomial (N=1). The method returns the zero ImmutableDensePolynomial. This is a possible fix of a bug, since previously derivative of an ImmutablePolynomial returned an unusable polynomial of type ImmutablePolynomial{Union{},:x,0}`.
1 parent 607acca commit e63df3d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ end
142142

143143
# special cases are much more performant
144144
derivative(p::ImmutableDensePolynomial{B,T,X,0}) where {B<:StandardBasis,T,X} = p
145+
function derivative(p::ImmutableDensePolynomial{B,T,X,1}) where {B<:StandardBasis,T,X}
146+
ImmutableDensePolynomial{B,T,X,1}(zero(T))
147+
end
145148
function derivative(p::ImmutableDensePolynomial{B,T,X,N}) where {B<:StandardBasis,T,X,N}
146149
N == 0 && return p
147150
hasnan(p) && return ImmutableDensePolynomial{B,T,X,1}(zero(T)/zero(T)) # NaN{T}

0 commit comments

Comments
 (0)