diff --git a/.vscode/launch.json b/.vscode/launch.json index 4d023ae..c865479 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "program": "${workspaceRoot}/sample/build/sample", "args": [ - "test" + "mfeat-factors" ], "stopAtEntry": false, "cwd": "${workspaceRoot}/sample/build/", diff --git a/CPPFImdlp.cpp b/CPPFImdlp.cpp index 59b9b4b..1c6234f 100644 --- a/CPPFImdlp.cpp +++ b/CPPFImdlp.cpp @@ -32,10 +32,12 @@ namespace mdlp { pair CPPFImdlp::valueCutPoint(size_t start, size_t cut, size_t end) { - size_t n, m, idxPrev = cut - 1 <= start ? cut - 1 : cut; + size_t n, m, idxPrev = cut - 1 >= start ? cut - 1 : cut; size_t idxNext = cut + 1 < end ? cut + 1 : cut; bool backWall; // true if duplicates reach begining of the interval precision_t previous, actual, next; + if (cut - 1 < start || cut + 1 >= end) + throw logic_error("Invalid cutpoint index"); previous = X[indices[idxPrev]]; actual = X[indices[cut]]; next = X[indices[idxNext]];