* Inverts a given matrix. * * This method inverts a matrix based on its dimensions. Currently, it supports * 3x3 and 4x4 matrices. If the matrix dimension is greater than 4, an error is thrown. * * For 4x4 matrices, it uses a specialized algorithm to compute the inverse. * For 3x3
(a)
| 644 | * } |
| 645 | */ |
| 646 | invert(a) { |
| 647 | if (this.#sqDimention === 4) { |
| 648 | return this.#invert4x4(a); |
| 649 | } else if (this.#sqDimention === 3) { |
| 650 | return this.#invert3x3(a); |
| 651 | } else { |
| 652 | throw new Error( |
| 653 | 'Invert is not implemented for N>4 at the moment, we are working on it' |
| 654 | ); |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | /** |
| 659 | * Creates a 3x3 matrix whose entries are the top left 3x3 part and returns it. This function is only for 4x4 matrices. |
no test coverage detected