diff --git a/src/algebra/CRSMatrix.hpp b/src/algebra/CRSMatrix.hpp index 4b88cd80c1e0c55b8a725f84106ddf13a283eb2f..c2df50e454fa883bf402c56ac81f8617cf9b7742 100644 --- a/src/algebra/CRSMatrix.hpp +++ b/src/algebra/CRSMatrix.hpp @@ -123,12 +123,12 @@ class CRSMatrix ++i_row_B; } else if (A_column_idx < B_column_idx) { column_indices[i_value] = A_column_idx; - values[i_value] = A.m_values[i_row_A]; + values[i_value] = BinOp()(A.m_values[i_row_A], 0); ++i_row_A; } else { Assert(B_column_idx < A_column_idx); column_indices[i_value] = B_column_idx; - values[i_value] = B.m_values[i_row_B]; + values[i_value] = BinOp()(0, B.m_values[i_row_B]); ++i_row_B; } ++i_value; diff --git a/tests/test_CRSMatrix.cpp b/tests/test_CRSMatrix.cpp index f4bce5a429a0b88ee0c6ce2c58661c3874692e42..cf6d65b87b10c362e89935ce89dc7ac79f490cd4 100644 --- a/tests/test_CRSMatrix.cpp +++ b/tests/test_CRSMatrix.cpp @@ -240,8 +240,8 @@ TEST_CASE("CRSMatrix", "[algebra]") std::ostringstream ost; ost << A - B; - std::string ref = R"(0| 0:2 1:2 2:3 -1| 0:-2 1:6 2:3 + std::string ref = R"(0| 0:2 1:2 2:-3 +1| 0:-2 1:6 2:-3 2| 0:2 2:-11 3:12 3| 0:10 3:8 )"; @@ -327,10 +327,10 @@ TEST_CASE("CRSMatrix", "[algebra]") std::ostringstream ost; ost << A - B; - std::string ref = R"(0| 0:2 1:2 2:3 -1| 0:-2 1:6 2:3 + std::string ref = R"(0| 0:2 1:2 2:-3 +1| 0:-2 1:6 2:-3 2| 0:2 2:1 -3| 0:10 1:8 2:16 +3| 0:10 1:-8 2:16 )"; REQUIRE(ost.str() == ref);