This commit is contained in:
Dylan Vorster
2020-09-23 10:24:36 +02:00
parent c92313f9b1
commit 1e95edbc6f
2 changed files with 9 additions and 14 deletions

View File

@ -5,23 +5,18 @@ export class Matrix {
this.matrix = matrix; this.matrix = matrix;
} }
mmul = (matrix: Matrix): Matrix => { mmul(matrix: Matrix): Matrix {
// prettier-ignore
this.matrix = this.matrix.map((row, i) => this.matrix = this.matrix.map((row, i) =>
matrix.asArray()[0].map((_, j) => matrix.asArray()[0].map((_, j) => row.reduce((acc, _, n) => acc + this.matrix[i][n] * matrix.asArray()[n][j], 0))
row.reduce((acc, _, n) => );
acc + this.matrix[i][n] * matrix.asArray()[n][j], 0
)
)
);
return this; return this;
}; }
asArray = (): number[][] => { asArray(): number[][] {
return this.matrix; return this.matrix;
}; }
get = (rowIndex: number, columnIndex: number): number => { get(rowIndex: number, columnIndex: number): number {
return this.asArray()[rowIndex][columnIndex]; return this.asArray()[rowIndex][columnIndex];
}; }
} }