ml-sparse-matrix
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "ml-sparse-matrix", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Sparse matrix library", | ||
@@ -5,0 +5,0 @@ "main": "src/SparseMatrix.js", |
@@ -142,7 +142,8 @@ const HashTable = require('ml-hash-table'); | ||
forEachNonZero(callback) { | ||
return this.elements.forEachPair((key, value) => { | ||
this.elements.forEachPair((key, value) => { | ||
const i = (key / this.columns) | 0; | ||
const j = key % this.columns; | ||
const r = callback(i, j, value); | ||
let r = callback(i, j, value); | ||
if (r === false) return false; // stop iteration | ||
if (this.threshold && Math.abs(r) < this.threshold) r = 0; | ||
if (r !== value) { | ||
@@ -157,2 +158,3 @@ if (r === 0) { | ||
}); | ||
return this; | ||
} | ||
@@ -175,2 +177,10 @@ | ||
} | ||
setThreshold(newThreshold) { | ||
if (newThreshold !== 0 && newThreshold !== this.threshold) { | ||
this.threshold = newThreshold; | ||
this.forEachNonZero((i, j, v) => v); | ||
} | ||
return this; | ||
} | ||
} | ||
@@ -177,0 +187,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10110
253
6