From 32bd7d29e892f88e3c35af3818c48ce4c2025f03 Mon Sep 17 00:00:00 2001 From: tpoisseau <22891227+tpoisseau@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:16:42 +0200 Subject: [PATCH] chore: lint --- src/__tests__/matrix/utility.test.js | 5 +++++ src/inspect.js | 4 ++++ src/mathOperations.js | 4 ++-- src/stat.js | 6 +++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/__tests__/matrix/utility.test.js b/src/__tests__/matrix/utility.test.js index 7bf7b501..e8328fc9 100644 --- a/src/__tests__/matrix/utility.test.js +++ b/src/__tests__/matrix/utility.test.js @@ -45,6 +45,11 @@ describe('utility methods', () => { matrix.set(0, 0, 10); let called = 0; + /** + * @this {Matrix} + * @param i + * @param j + */ function cb(i, j) { called++; expect(this).toBeInstanceOf(Matrix); diff --git a/src/inspect.js b/src/inspect.js index 66927dda..79500a4b 100644 --- a/src/inspect.js +++ b/src/inspect.js @@ -1,6 +1,10 @@ const indent = ' '.repeat(2); const indentData = ' '.repeat(4); +/** + * @this {Matrix} + * @returns {string} + */ export function inspectMatrix() { return inspectMatrixWithOptions(this); } diff --git a/src/mathOperations.js b/src/mathOperations.js index 221886b0..2b8c3068 100644 --- a/src/mathOperations.js +++ b/src/mathOperations.js @@ -801,7 +801,7 @@ export function installMathOperations(AbstractMatrix, Matrix) { AbstractMatrix.prototype.powS = function powS(value) { for (let i = 0; i < this.rows; i++) { for (let j = 0; j < this.columns; j++) { - this.set(i, j, Math.pow(this.get(i, j), value)); + this.set(i, j, this.get(i, j) ** value); } } return this; @@ -815,7 +815,7 @@ export function installMathOperations(AbstractMatrix, Matrix) { } for (let i = 0; i < this.rows; i++) { for (let j = 0; j < this.columns; j++) { - this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j))); + this.set(i, j, this.get(i, j) ** matrix.get(i, j)); } } return this; diff --git a/src/stat.js b/src/stat.js index dc9d7053..dbe558d6 100644 --- a/src/stat.js +++ b/src/stat.js @@ -157,7 +157,7 @@ export function getScaleByRow(matrix) { for (let i = 0; i < matrix.rows; i++) { let sum = 0; for (let j = 0; j < matrix.columns; j++) { - sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1); + sum += matrix.get(i, j) ** 2 / (matrix.columns - 1); } scale.push(Math.sqrt(sum)); } @@ -177,7 +177,7 @@ export function getScaleByColumn(matrix) { for (let j = 0; j < matrix.columns; j++) { let sum = 0; for (let i = 0; i < matrix.rows; i++) { - sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1); + sum += matrix.get(i, j) ** 2 / (matrix.rows - 1); } scale.push(Math.sqrt(sum)); } @@ -197,7 +197,7 @@ export function getScaleAll(matrix) { let sum = 0; for (let j = 0; j < matrix.columns; j++) { for (let i = 0; i < matrix.rows; i++) { - sum += Math.pow(matrix.get(i, j), 2) / divider; + sum += matrix.get(i, j) ** 2 / divider; } } return Math.sqrt(sum);