import Vector from './Vector'; export default class Matrix { /** Number of rows of the matrix */ private _rows; /** Number of columns of the matrix */ private _columns; /** Values of the matrix as a two dimensional array */ private _values; constructor(rows: number, columns: number, values?: number[][]); get rows(): number; get columns(): number; get values(): number[][]; /** * Set values into the matrix. * If the parameters matrix is to wide, the values are cropped to the current matrix size. * It the parameters matrix is to small, remaining cells will be filled with 0. * @param newValues Arrays of new values. */ set values(newValues: number[][]); /** * Get a matrix value, from its position * @param row Matrix line, from 0 to `rows` * @param col Matric column, from 0 to `columns` */ at(row: number, col: number): number; /** * Sets all matrix values to 0 */ reset(): void; /** * Get a copy of this matrix * @return A new matrix with the same values */ copy(): Matrix; /** * Computes the trace of the matrix, i.e. the sum of its diagonal values * @throws Error if the matrix is not squared */ trace(): number; /** * Add new columns to the matrix, filled with 0 * @param count Number of columns to add (default: 1) */ addColumns(count?: number): Matrix; /** * Add new rows to the matrix, filled with 0 * @param count Number of rows to add (default: 1) */ addRows(count?: number): Matrix; /** * Check if two matrix are equals, value by value * @param mat The matrix against to check equality * @param threshold The maximum allowed difference between two values to still be considered equal (default: 0, i.e. exact equality) */ equals(mat: Matrix, threshold?: number): boolean; /** * Sets the matrix as an identity matrix */ setIdentity(): this; /** * Gets an identity matrix (1 on diagonal) * @param dimension Dimension of the squared matrix */ static identity(dimension: number): Matrix; /** * Builds a matrix from a flat, row-major array of values * @param values Flat array of values, read row by row * @param rows Number of rows * @param columns Number of columns * @throws Error if values.length !== rows * columns * @return A new Matrix built from the given values */ static fromArray(values: number[], rows: number, columns: number): Matrix; /** * Add all matrix values with the same position value of the operand matrix * @param mat The operand matrix * @throws Error if the two matrices don't have the same dimensions * @return A new Matrix with the result values */ add(mat: Matrix): Matrix; /** * Subtract all matrix values with the same position value of the operand matrix * @param mat The operand matrix * @throws Error if the two matrices don't have the same dimensions * @return A new Matrix with the result values */ subtract(mat: Matrix): Matrix; /** * Multiply all matrix values by the given number * @param scale The number to multiply with the values * @return A new Matrix with the result values */ scale(scale: number): Matrix; /** * Run a function on all matrix values, as a map. * @param operation The mapping method * @return a new Matrix with the operation done on all its values */ private operateOnAllValues; /** * Computes the product with another matrix * @param mat The second operand matrix * @throws Error if matrixA.columns != matrixB.rows * @return A new Matrix, result of the multiplication */ multiply(mat: Matrix): Matrix; /** * Computes the product with a vector * @param vec The vector to multiply with * @throws Error if matrix.columns != vector.rows * @return A new Vector, result of the multiplication */ multiplyVector(vec: Vector): Vector; /** * Get the position, from its matrix value * @param value The value to search * @return The position of the value, or -1 if not found */ indexOf(value: number): [number, number]; /** * Computes the maximum value of the matrix * @return The maximum value */ max(): number; /** * Computes the minimum value of the matrix * @return The minimum value * @throws Error if the matrix is empty */ min(): number; /** * Rounds all matrix values to the nearest integer * @return A new matrix with the rounded values */ round(): Matrix; /** * Computes the determinant of the matrix via LU decomposition with partial * pivoting, in O(n^3) instead of the O(n!) of a cofactor expansion. * @throws Error if the matrix is not squared */ determinant(): number; /** * Gets a cofactor matrix * @param row The row to omit in the matrix * @param col The column to omit in the matrix * @return The cofactor matrix sized (r-1)x(c-1) */ cofactor(row: number, col: number): Matrix; /** * Computes a transposed the matrix * @return A new matrix sized (columns) x (rows) */ transpose(): Matrix; /** * Computes the inversed matrix via Gauss-Jordan elimination with partial * pivoting, in O(n^3) instead of the O(n!) of a cofactor/adjugate approach. * @return A new matrix inversed * @throws Error if the matrix is not squared, or is singular (not invertible) */ inverse(): Matrix; toString(): string; } //# sourceMappingURL=Matrix.d.ts.map