Skip to content

Commit

Permalink
reserve storage in matrix_data constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed May 9, 2022
1 parent cbb53cf commit a4174ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/ginkgo/core/base/matrix_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ struct matrix_data {
if (is_zero(value)) {
return;
}
nonzeros.reserve(size[0] * size[1]);
for (size_type row = 0; row < size[0]; ++row) {
for (size_type col = 0; col < size[1]; ++col) {
nonzeros.emplace_back(row, col, value);
Expand All @@ -190,6 +191,7 @@ struct matrix_data {
matrix_data(dim<2> size_, RandomDistribution&& dist, RandomEngine&& engine)
: size{size_}
{
nonzeros.reserve(size[0] * size[1]);
for (size_type row = 0; row < size[0]; ++row) {
for (size_type col = 0; col < size[1]; ++col) {
const auto value =
Expand Down

0 comments on commit a4174ec

Please sign in to comment.