From 47ee87fe72f6b29a9f821301dcb3a4904f2345f2 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 9 Jan 2018 09:03:22 -0800 Subject: [PATCH] adding logging --- libs/matrix/matrix.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/matrix/matrix.ts b/libs/matrix/matrix.ts index 75fe4140..07dadceb 100644 --- a/libs/matrix/matrix.ts +++ b/libs/matrix/matrix.ts @@ -140,7 +140,7 @@ namespace matrix { /** * Clones the matrix */ - dup(): Matrix { + clone(): Matrix { const r = new Matrix(this._rows, this._cols, this._values.slice(0)); return r; } @@ -151,7 +151,7 @@ namespace matrix { */ cholesky(): Matrix { pre(this._rows == this._cols); - const l = this.dup(); + const l = this.clone(); const n = this._rows; const L = l._values; @@ -166,5 +166,21 @@ namespace matrix { return l; } + + /** + * Renders the matrix to the console + */ + logToConsole(): void { + let k = 0; + for(let i = 0; i < this._rows; ++i) { + let s = "" + for(let j = 0; j < this._cols; ++j) { + if (j > 0) + s += " " + s += Math.round((this._values[k++] * 100) / 100); + } + console.log(s) + } + } } } \ No newline at end of file