From 79c029832a6a4d2981053547813ba62308d51549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Tue, 21 Feb 2023 18:49:57 +0100 Subject: [PATCH] Fix a sign mistake in valueCutPoint --- .vscode/launch.json | 2 +- CPPFImdlp.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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]];