Skip to content

Commit 12a4aae

Browse files
committed
[Code] Fix row copy in seq vec extract-row method
1 parent 0475e11 commit 12a4aae

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cubool/sources/sequential/sq_vector.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ namespace cubool {
8181

8282
auto& m = matrix->mData;
8383

84+
auto begin = m.rowOffsets[i];
85+
auto end = m.rowOffsets[i + 1];
86+
8487
VecData r;
8588
r.nrows = m.ncols;
86-
r.nvals = m.rowOffsets[i + 1] - m.rowOffsets[i];
87-
r.indices.reserve(r.nvals);
89+
r.nvals = end - begin;
90+
r.indices.resize(r.nvals);
8891

89-
for (index k = m.rowOffsets[i]; k < m.rowOffsets[i + 1]; k++)
90-
r.indices.push_back(m.colIndices[k]);
92+
std::copy(m.colIndices.begin() + begin, m.colIndices.begin() + end, r.indices.begin());
9193

9294
mData = std::move(r);
9395
}

0 commit comments

Comments
 (0)