Minor corrections based on Jim Roseborough's comments
Change-Id: I4a8c7a454ddf038a3ed2567c101f9aee582044bf
diff --git a/internal/ceres/polynomial.cc b/internal/ceres/polynomial.cc
index 2134d6e..3238b89 100644
--- a/internal/ceres/polynomial.cc
+++ b/internal/ceres/polynomial.cc
@@ -185,6 +185,14 @@
Vector DifferentiatePolynomial(const Vector& polynomial) {
const int degree = polynomial.rows() - 1;
CHECK_GE(degree, 0);
+
+ // Degree zero polynomials are constants, and their derivative does
+ // not result in a smaller degree polynomial, just a degree zero
+ // polynomial with value zero.
+ if (degree == 0) {
+ return Eigen::VectorXd::Zero(1);
+ }
+
Vector derivative(degree);
for (int i = 0; i < degree; ++i) {
derivative(i) = (degree - i) * polynomial(i);