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;
}
mmul = (matrix: Matrix): Matrix => {
// prettier-ignore
mmul(matrix: Matrix): Matrix {
this.matrix = this.matrix.map((row, i) =>
matrix.asArray()[0].map((_, j) =>
row.reduce((acc, _, n) =>
acc + this.matrix[i][n] * matrix.asArray()[n][j], 0
)
)
);
matrix.asArray()[0].map((_, j) => row.reduce((acc, _, n) => acc + this.matrix[i][n] * matrix.asArray()[n][j], 0))
);
return this;
};
}
asArray = (): number[][] => {
asArray(): number[][] {
return this.matrix;
};
}
get = (rowIndex: number, columnIndex: number): number => {
get(rowIndex: number, columnIndex: number): number {
return this.asArray()[rowIndex][columnIndex];
};
}
}