Commit 8af234d1 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

Math::CubicSpline

- fixed input parameter checks and exception messages
parent 4c7fe97b
......@@ -19,18 +19,18 @@ CPiecewisePolynomial Math::CubicSpline(const std::vector<float>& vdSupportingPoi
if (vdSupportingPoints.size() != vdDataPoints.size())
ITA_EXCEPT_INVALID_PARAMETER("vdSupportingPoints and vdDataPoints need to have the same size");
if (vdSupportingPoints.size() < 2)
ITA_EXCEPT_INVALID_PARAMETER("vdSupportingPoints and vdDataPoints need to contain at least 3 elements");
if (vdSupportingPoints.size() < 4)
ITA_EXCEPT_INVALID_PARAMETER("vdSupportingPoints and vdDataPoints need to contain at least 4 elements");
//Calculate h_i, formular 1.27b
int iPolynomialOrder = 3;
int iPoints = vdSupportingPoints.size();
const int iPolynomialOrder = 3;
const int iPoints = vdSupportingPoints.size();
std::vector<float> vdH(iPoints - 1);
for (int i = 0; i < iPoints - 1; i++) {
vdH[i] = vdSupportingPoints[i + 1] - vdSupportingPoints[i];
if (vdH[i] < 0) {
ITA_EXCEPT_INVALID_PARAMETER("vdSupportingPoints needs to be sorted in ascending order");
if (vdH[i] <= 0) {
ITA_EXCEPT_INVALID_PARAMETER("vdSupportingPoints needs to be sorted in ascending order and not be duplicates");
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment