We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec3e0de commit b5473ddCopy full SHA for b5473dd
src/poly.jl
@@ -104,9 +104,9 @@ MP.extdegree(p::Polynomial) = extdegree(p.x)
104
MP.mindegree(p::Polynomial) = mindegree(p.x)
105
MP.maxdegree(p::Polynomial) = maxdegree(p.x)
106
107
-MP.leadingcoefficient(p::Polynomial) = first(p.a)
108
-MP.leadingmonomial(p::Polynomial) = first(p.x)
109
-MP.leadingterm(p::Polynomial) = first(p)
+MP.leadingcoefficient(p::Polynomial{C, T}) where {C, T} = iszero(p) ? zero(T) : first(p.a)
+MP.leadingmonomial(p::Polynomial) = iszero(p) ? constantmonomial(p) : first(p.x)
+MP.leadingterm(p::Polynomial) = iszero(p) ? zeroterm(p) : first(terms(p))
110
111
function MP.removeleadingterm(p::Polynomial)
112
Polynomial(p.a[2:end], p.x[2:end])
0 commit comments