From 2ea5a715cfc742f086666ebb2a237fa54423814f Mon Sep 17 00:00:00 2001 From: Matthew Powelson Date: Tue, 7 Jan 2020 16:20:43 -0600 Subject: Properly initialize b vector in SplineFitting InterpolateWithDerivative does not initialize the be vector correctly. This issue is discussed In stackoverflow question 48382939. --- unsupported/Eigen/src/Splines/SplineFitting.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'unsupported') diff --git a/unsupported/Eigen/src/Splines/SplineFitting.h b/unsupported/Eigen/src/Splines/SplineFitting.h index 850f78a5e..9f6e8afa0 100644 --- a/unsupported/Eigen/src/Splines/SplineFitting.h +++ b/unsupported/Eigen/src/Splines/SplineFitting.h @@ -385,7 +385,7 @@ namespace Eigen { const DenseIndex span = SplineType::Span(parameters[i], degree, knots); - if (derivativeIndices[derivativeIndex] == i) + if (derivativeIndex < derivativeIndices.size() && derivativeIndices[derivativeIndex] == i) { A.block(row, span - degree, 2, degree + 1) = SplineType::BasisFunctionDerivatives(parameters[i], 1, degree, knots); @@ -395,8 +395,9 @@ namespace Eigen } else { - A.row(row++).segment(span - degree, degree + 1) + A.row(row).segment(span - degree, degree + 1) = SplineType::BasisFunctions(parameters[i], degree, knots); + b.col(row++) = points.col(i); } } b.col(0) = points.col(0); -- cgit v1.2.3