Skip to content
Snippets Groups Projects
Commit cd25d595 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Merge branch 'feature/CRSMatrix-sum' into 'develop'

Change CRSMatrixDescriptor constructors

See merge request !107
parents dad3173e 82ab455b
Branches
Tags
1 merge request!107Change CRSMatrixDescriptor constructors
......@@ -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;
......
......@@ -248,9 +248,9 @@ class CRSMatrixDescriptor
}
}
CRSMatrixDescriptor(const IndexType nb_rows, const IndexType nb_columns, const Array<IndexType>& non_zeros)
: m_nb_rows{nb_rows},
m_nb_columns{nb_columns},
CRSMatrixDescriptor(const size_t nb_rows, const size_t nb_columns, const Array<IndexType>& non_zeros)
: m_nb_rows(nb_rows),
m_nb_columns(nb_columns),
m_row_map{this->_computeRowMap(non_zeros)},
m_values(m_row_map[m_row_map.size() - 1]),
m_column_indices(m_row_map[m_row_map.size() - 1]),
......@@ -268,6 +268,10 @@ class CRSMatrixDescriptor
}
}
CRSMatrixDescriptor(const size_t nb_rows, const Array<IndexType>& non_zeros)
: CRSMatrixDescriptor(nb_rows, nb_rows, non_zeros)
{}
~CRSMatrixDescriptor() = default;
};
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment