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; } diff --git a/cubool/tests/test_matrix_ewisemult_inverted.cpp b/cubool/tests/test_matrix_ewisemult_inverted.cpp index f29430b..e29a7de 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