From bdde07eda7b46f62df4a7a250cd03583d4711a0b Mon Sep 17 00:00:00 2001 From: vano105 Date: Sun, 29 Mar 2026 03:16:43 +0300 Subject: [PATCH 1/3] Fix error in eWiseMultInverted --- cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu index e070409..80d81ab 100644 --- a/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu +++ b/cubool/sources/cuda/cuda_matrix_ewisemult_inverted.cu @@ -44,7 +44,7 @@ namespace cubool { assert(b->getNrows() == M); assert(b->getNcols() == N); - if (a->isMatrixEmpty() || b->isMatrixEmpty()) { + if (a->isMatrixEmpty()) { this->clearAndResizeStorageToDim(); return; } From 4e3ab7fbf9655024bd60645d3b8806da83b5e01c Mon Sep 17 00:00:00 2001 From: vano105 Date: Sun, 29 Mar 2026 14:41:57 +0300 Subject: [PATCH 2/3] Add tests for empty matrix in eWiseMultInverted --- .../tests/test_matrix_ewisemult_inverted.cpp | 59 +++++++++++++++++++ scripts/run_tests_all.sh | 3 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp index f29430b..1c4f7d4 100644 --- a/cubool/tests/test_matrix_ewisemult_inverted.cpp +++ b/cubool/tests/test_matrix_ewisemult_inverted.cpp @@ -106,5 +106,64 @@ TEST(cuBool_Matrix, ApplyMatrixRandom) { ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); } +TEST(cuBool_Matrix, ApplyMatrixEmptyMask) { + ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); + + DataMatrix matrix{ + {1, 0, 1}, + {0, 1, 0}, + {1, 1, 0}, + }; + + DataMatrix mask{ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + }; + + testApplyNotMask(matrix, mask); + + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); +} + +TEST(cuBool_Matrix, ApplyMatrixEmptySource) { + ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); + + DataMatrix matrix{ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + }; + + DataMatrix mask{ + {1, 0, 1}, + {0, 1, 0}, + {1, 1, 0}, + }; + + testApplyNotMask(matrix, mask); + + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); +} + +TEST(cuBool_Matrix, ApplyMatrixBothEmpty) { + ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); + + DataMatrix matrix{ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + }; + + DataMatrix mask{ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + }; + + testApplyNotMask(matrix, mask); + + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); +} CUBOOL_GTEST_MAIN diff --git a/scripts/run_tests_all.sh b/scripts/run_tests_all.sh index 1fd405f..a2b70eb 100644 --- a/scripts/run_tests_all.sh +++ b/scripts/run_tests_all.sh @@ -19,4 +19,5 @@ ./cubool/tests/test_vector_ewisemult ./cubool/tests/test_vector_mxv ./cubool/tests/test_vector_vxm -./cubool/tests/test_vector_sub_vector \ No newline at end of file +./cubool/tests/test_vector_sub_vector +./cubool/tests/test_matrix_ewisemult_inverted \ No newline at end of file From 37ccfd818f3bc9c5cb6483a2e76fc73ee93a01f3 Mon Sep 17 00:00:00 2001 From: vano105 Date: Sun, 29 Mar 2026 14:59:02 +0300 Subject: [PATCH 3/3] Fixed error in clang-format --- .../tests/test_matrix_ewisemult_inverted.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp index 1c4f7d4..e29a7de 100644 --- a/cubool/tests/test_matrix_ewisemult_inverted.cpp +++ b/cubool/tests/test_matrix_ewisemult_inverted.cpp @@ -108,61 +108,61 @@ TEST(cuBool_Matrix, ApplyMatrixRandom) { TEST(cuBool_Matrix, ApplyMatrixEmptyMask) { ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); - + DataMatrix matrix{ {1, 0, 1}, {0, 1, 0}, {1, 1, 0}, }; - + DataMatrix mask{ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, }; - + testApplyNotMask(matrix, mask); - + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); } TEST(cuBool_Matrix, ApplyMatrixEmptySource) { ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); - + DataMatrix matrix{ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, }; - + DataMatrix mask{ {1, 0, 1}, {0, 1, 0}, {1, 1, 0}, }; - + testApplyNotMask(matrix, mask); - + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); } TEST(cuBool_Matrix, ApplyMatrixBothEmpty) { ASSERT_EQ(cuBool_Initialize(CUBOOL_HINT_NO), CUBOOL_STATUS_SUCCESS); - + DataMatrix matrix{ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, }; - + DataMatrix mask{ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, }; - + testApplyNotMask(matrix, mask); - + ASSERT_EQ(cuBool_Finalize(), CUBOOL_STATUS_SUCCESS); }