mirror of
https://github.com/projectstorm/react-diagrams.git
synced 2025-08-14 08:43:42 +08:00
pretty
This commit is contained in:
@ -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[][] => {
|
||||
return this.matrix;
|
||||
};
|
||||
|
||||
get = (rowIndex: number, columnIndex: number): number => {
|
||||
return this.asArray()[rowIndex][columnIndex];
|
||||
};
|
||||
}
|
||||
|
||||
asArray(): number[][] {
|
||||
return this.matrix;
|
||||
}
|
||||
|
||||
get(rowIndex: number, columnIndex: number): number {
|
||||
return this.asArray()[rowIndex][columnIndex];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user