Skip to content

Commit

Permalink
Merge pull request #88 from kokkos/Fix-11
Browse files Browse the repository at this point in the history
Fix #11 (replaceValues / sumIntoValues bug)
  • Loading branch information
crtrott authored Sep 20, 2017
2 parents c8a823b + 14f071f commit ba2d3dd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/sparse/KokkosSparse_CrsMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ class CrsMatrix {
ordinal_type numValid = 0; // number of valid local column indices

for (ordinal_type i = 0; i < ncol; ++i) {
// NOTE (mfh 19 Sep 2017) This assumes that row_view stores
// column indices contiguously. It does, but one could imagine
// changing that at some point.
const ordinal_type offset =
findRelOffset (&(row_view.colidx(0)), length, cols[i], hint, is_sorted);
if (offset != length) {
Expand All @@ -648,9 +651,13 @@ class CrsMatrix {
else {
row_view.value(offset) += vals[i];
}
++numValid;
// If the hint is out of range, findRelOffset will ignore it.
// Thus, while it's harmless to have a hint out of range, it
// may slow down searches for subsequent valid input column
// indices.
hint = offset + 1;
}
hint = offset + 1;
++numValid;
}
return numValid;
}
Expand All @@ -672,6 +679,9 @@ class CrsMatrix {
ordinal_type numValid = 0; // number of valid local column indices

for (ordinal_type i = 0; i < ncol; ++i) {
// NOTE (mfh 19 Sep 2017) This assumes that row_view stores
// column indices contiguously. It does, but one could imagine
// changing that at some point.
const ordinal_type offset =
findRelOffset (&(row_view.colidx(0)), length, cols[i], hint, is_sorted);
if (offset != length) {
Expand All @@ -681,9 +691,13 @@ class CrsMatrix {
else {
row_view.value(offset) = vals[i];
}
++numValid;
// If the hint is out of range, findRelOffset will ignore it.
// Thus, while it's harmless to have a hint out of range, it
// may slow down searches for subsequent valid input column
// indices.
hint = offset + 1;
}
hint = offset + 1;
++numValid;
}
return numValid;
}
Expand Down

0 comments on commit ba2d3dd

Please sign in to comment.