export declare class Matrix { /** The row size of matrix. */ readonly row: number; /** The column size of matrix. */ readonly col: number; /** The elements length of matrix. It's NOT magnitude of matrix. */ readonly size: number; /** All of matrix's elements. */ readonly elements: T[]; constructor(row: number, col: number, elements: T | T[]); /** Returns a clone of matrix. */ get clone(): Matrix; /** Returns a length of matrix. This follows the calculation of Euclidean norm. */ get magnitude(): number; /** * Creates a new matrix instance with same row and col size. * @param row The row size of new matrix. * @param col The column size of new matrix. * @param elements The elements of new matrix. If `elements` argument is not array, it will be filled with `elements` argument. * @returns The new matrix instance. */ static Create(row: number, col: number, elements: T | T[]): Matrix; /** * Create matrix instance from 2d-array data type. * @param array Source of matrix elements as 2d-array data type. * @returns Matrix instance. */ static From2DArray(array: T[][]): Matrix; /** * Returns added result matrix between both matrix. It will returns `a + b`. * @param a The matrix. * @param b The matrix. */ static Add(a: Matrix, b: Matrix): Matrix; /** * Returns subtracted result matrix between both matrix. It will returns `a - b`. * @param a The matrix. * @param b The matrix. */ static Sub(a: Matrix, b: Matrix): Matrix; /** * Returns multiplied result matrix between both matrix. It will returns `a * b`. * WARNING! This method is not product matrix. It's just a multiply each element of matrix. * If you want to product matrix, use `Prod` method. * @param a The matrix. * @param b The matrix. */ static Mul(a: Matrix, b: Matrix): Matrix; /** * Returns divided result matrix between both matrix. It will returns `a / b`. * It's just a divide each element of matrix. * @param a The matrix. * @param b The matrix. */ static Div(a: Matrix, b: Matrix): Matrix; /** * Returns multiplied result matrix between both matrix. * The matrix product must be same `a.col` and `b.row` size. If not, it will throw an error. * @param a The first matrix. * @param b The second matrix. * @returns New matrix instance. */ static Prod(a: Matrix, b: Matrix): Matrix; /** * Returns the scalar product results of two matrices. * WARNING! This does NOT distinguish between the rows and columns of the matrix. List all the elements of the matrix and convert it to a vector, Returns the value that adds all the elements. * @param a The first matrix. * @param b The second matrix. * @returns The scalar value. */ static VecDot(a: Matrix, b: Matrix): number; /** * Calculate and return cosine similarity between the two matrices. * WARNING! This does NOT distinguish between the rows and columns of the matrix. List all the elements of the matrix and convert it to a vector, then compare the similarity. * @param a The first matrix. * @param b The second matrix. * @returns The similarity value of matrix as number `-1` to `1`. If not similar, `-1`, `1` if it is similar. */ static VecCosSim(a: Matrix, b: Matrix): number; /** * Returns whether the matrix has same size. It calculates with `row` and `col` properties. * @param a The matrix. * @param b The matrix. */ static IsSameSize(a: Matrix, b: Matrix): boolean; /** * Returns whether the index has exceeded the range. Returns `true` if exceeded. * @param index The index number. * @param max Maximum index. * @param min Minimum index. Default value is `0` */ static OutOfRange(index: number, max: number, min?: number): boolean; protected static ERR_EXCEED_RANGE(min: number, max: number, index: number): Error; protected static ERR_SIZE_NOT_MATCH(): Error; protected static ERR_MULTIPLY_SIZE_NOT_MATCH(): Error; /** * Get new matrix from part of source matrix. It returns neighbor elements from point of coordinates of source matrix. * The size of new matrix is multiple of row and column of arguments. * @param source The source matrix. * @param rowIndex Point of row index. * @param colIndex Point of column index. * @param row The matrix row size of result. Default value is `3` * @param col The matrix column size of result. Default value is `3` * @param fill Fill element if neighbor elements are out of range. */ static GetLocalMatrix(source: Matrix, rowIndex: number, colIndex: number, row?: number, col?: number, fill?: U): Matrix; /** * Returns all elements in matrix's row vector as array. * @param index The matrix index of row. */ getRowElements(index: number): T[]; /** * Returns all elements in matrix's column vector as array. * @param index The matrix index of column. */ getColElements(index: number): T[]; /** * Get elements index of `matrix.elements` property with calculates row and column. * @param rowIndex The matrix index of row. * @param colIndex The matrix index of column. * @returns */ getIndex(rowIndex: number, colIndex: number): number; /** * Sets element for matrix. * @param rowIndex The matrix index of row. * @param colIndex The matrix index of column. * @param element The element what you want set. */ setElement(rowIndex: number, colIndex: number, element: T): void; /** * Returns row index of matrix from calculated with element index. * @param elOffset The index of `matrix.elements` */ getRowIndex(elOffset: number): number; /** * Returns column index of matrix of calculated with element index. * @param elOffset The index of `matrix.elements` */ getColIndex(elOffset: number): number; /** * Returns whether the positions of rows and columns are within the range of the current matrix. * If the position is within the range of the matrix, it returns `true`. Otherwise, it returns `false`. * You can use this method to get element safely. * ``` * if (matrix.reachable(rowIndex, colIndex)) { * const element = matrix.getElement(rowIndex, colIndex) * } * ``` * @param rowIndex The row index of matrix. * @param colIndex The column index of matrix. */ reachable(rowIndex: number, colIndex: number): boolean; /** * Returns element what you find in point of coordinates in matrix. * @param rowIndex The row index of matrix. * @param colIndex The column index of matrix. */ getElement(rowIndex: number, colIndex: number): T; /** * Fill matrix with a element. * It is useful with `Matrix.Add`, `Matrix.Sub`, `Matrix.Mul`, `Matrix.Div` like methods. * ``` * const mat = Matrix.Create(3, 3, [1,2,3,4,5,6,7,8,9]) * const result = Matrix.Mul(mat, mat.clone.fill(3)) * ``` * @param element The fill element. */ fill(element: T): this; /** * Returns all elements in matrix as 2d-array data type. */ as2DArray(): T[][]; }