From e2f72ae2359a6f1875bcfd2f27e4a165f7be078b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 19 May 2016 15:22:16 +0200 Subject: [PATCH 1/2] prevent hash table capacity to be shrinked during forEachNonZero --- package.json | 2 +- src/SparseMatrix.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a3d9961..621f13b 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,6 @@ "should": "^8.3.1" }, "dependencies": { - "ml-hash-table": "^0.1.2" + "ml-hash-table": "^0.2.0" } } diff --git a/src/SparseMatrix.js b/src/SparseMatrix.js index 6b05ff2..4924b26 100644 --- a/src/SparseMatrix.js +++ b/src/SparseMatrix.js @@ -147,13 +147,14 @@ class SparseMatrix { if (this.threshold && Math.abs(r) < this.threshold) r = 0; if (r !== value) { if (r === 0) { - this.elements.remove(key); + this.elements.remove(key, true); } else { this.elements.set(key, r); } } return true; }); + this.elements.maybeShrinkCapacity(); return this; } From c74ae33195133dc730b8adb8740e69dbf23fa14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 19 May 2016 15:22:33 +0200 Subject: [PATCH 2/2] 0.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 621f13b..304550d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ml-sparse-matrix", - "version": "0.2.0", + "version": "0.2.1", "description": "Sparse matrix library", "main": "src/SparseMatrix.js", "scripts": {