From d0c86c918d5a9f3397ffee09110cd2025c0d7fe0 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 26 Apr 2023 21:49:58 +0200 Subject: [PATCH] Fix logic in MLPPMatrix's remove_row_unordered. --- mlpp/lin_alg/mlpp_matrix.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mlpp/lin_alg/mlpp_matrix.cpp b/mlpp/lin_alg/mlpp_matrix.cpp index f3e0515..b49b886 100644 --- a/mlpp/lin_alg/mlpp_matrix.cpp +++ b/mlpp/lin_alg/mlpp_matrix.cpp @@ -154,10 +154,12 @@ void MLPPMatrix::remove_row_unordered(int p_index) { } int start_ind = p_index * _size.x; - int end_ind = (p_index + 1) * _size.x; + int last_row_start_ind = _size.y * _size.x; - for (int i = start_ind; i < end_ind; ++i) { - _data[i] = _data[ds + i]; + if (start_ind != last_row_start_ind) { + for (int i = 0; i < _size.x; ++i) { + _data[start_ind + i] = _data[last_row_start_ind + i]; + } } _data = (real_t *)memrealloc(_data, data_size() * sizeof(real_t));