Skip to content

Commit

Permalink
Improved logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jun 27, 2024
1 parent 7142864 commit 7c6c171
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/sparse-vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ class SparseVector {
this.values = [];

for (const [i, v] of value.entries()) {
if (v != 0) {
const f = Number(v);
if (f != 0) {
this.indices.push(Number(i));
this.values.push(Number(v));
this.values.push(f);
}
}
}
Expand All @@ -64,9 +65,10 @@ class SparseVector {

const entries = map instanceof Map ? map.entries() : Object.entries(map);
for (const [i, v] of entries) {
if (v != 0) {
const f = Number(v);
if (f != 0) {
this.indices.push(Number(i));
this.values.push(Number(v));
this.values.push(f);
}
}
}
Expand Down

0 comments on commit 7c6c171

Please sign in to comment.