/** @typedef {(row: number, column: number, value: number) => void} WithEachNonZeroCallback */ /** @typedef {(row: number, column: number, value: number) => number | false} ForEachNonZeroCallback */ export class SparseMatrix { static eye(rows?: number, columns?: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static add(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static sub(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static subtract(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static mul(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static multiply(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static div(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static divide(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static mod(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static modulus(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static and(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static or(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static xor(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static leftShift(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static signPropagatingRightShift(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static rightShift(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @param {number} value * @returns {SparseMatrix} */ static zeroFillRightShift(matrix: SparseMatrix, value: number): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static not(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static abs(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static acos(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static acosh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static asin(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static asinh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static atan(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static atanh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static cbrt(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static ceil(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static clz32(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static cos(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static cosh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static exp(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static expm1(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static floor(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static fround(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static log(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static log1p(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static log10(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static log2(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static round(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static sign(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static sin(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static sinh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static sqrt(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static tan(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static tanh(matrix: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} matrix * @returns {SparseMatrix} */ static trunc(matrix: SparseMatrix): SparseMatrix; constructor(rows: any, columns: any, options?: {}); _init(rows: any, columns: any, elements: any, threshold: any): void; rows: any; columns: any; elements: any; threshold: any; clone(): SparseMatrix; /** * @returns {number[][]} */ to2DArray(): number[][]; isSquare(): boolean; isSymmetric(): boolean; /** * Search for the wither band in the main diagonals * @returns {number} */ bandWidth(): number; /** * Test if a matrix is consider banded using a threshold * @param {number} width * @returns {boolean} */ isBanded(width: number): boolean; /** * @returns {number} */ get cardinality(): number; /** * @returns {number} */ get size(): number; /** * @param {number} row * @param {number} column * @returns {number} */ get(row: number, column: number): number; /** * @param {number} row * @param {number} column * @param {number} value * @returns {this} */ set(row: number, column: number, value: number): this; /** * Matrix multiplication, does not modify the current instance. * @param {SparseMatrix} other * @returns {SparseMatrix} returns a new matrix instance. * @throws {Error} If the number of columns of this matrix does not match the number of rows of the other matrix. */ mmul(other: SparseMatrix): SparseMatrix; /** * @param {SparseMatrix} other * @returns {SparseMatrix} */ kroneckerProduct(other: SparseMatrix): SparseMatrix; /** * Calls `callback` for each value in the matrix that is not zero. * Unlike `forEachNonZero`, the callback's return value has no effect. * @param {WithEachNonZeroCallback} callback * @param {boolean} [sort] * @returns {void} */ withEachNonZero(callback: WithEachNonZeroCallback, sort?: boolean): void; /** * Calls `callback` for each value in the matrix that is not zero. * The callback can return: * - `false` to stop the iteration immediately * - the same value to keep it unchanged * - 0 to remove the value * - something else to change the value * @param {ForEachNonZeroCallback} callback * @returns {this} */ forEachNonZero(callback: ForEachNonZeroCallback): this; /** * Returns the non-zero elements of the matrix in coordinates (COO) or CSR format. * * **COO (Coordinate) format:** * Stores the non-zero elements as three arrays: `rows`, `columns`, and `values`, where each index corresponds to a non-zero entry at (row, column) with the given value. * * **CSR (Compressed Sparse Row) format:** * Stores the matrix using three arrays: * - `rows`: Row pointer array of length `numRows + 1`, where each entry indicates the start of a row in the `columns` and `values` arrays. * - `columns`: Column indices of non-zero elements. * - `values`: Non-zero values. * This format is efficient for row slicing and matrix-vector multiplication. * * @param {Object} [options={}] - Options for output format and sorting. * @param {boolean} [options.csr] - If true, returns the result in CSR format. Otherwise, returns COO format. * @param {boolean} [options.sort] - If true, sorts the non-zero elements by their indices. * @returns {Object} If `csr` is not specified, returns an object with Float64Array `rows`, `columns`, and `values` (COO format). * If `csr` is true, returns `{ rows, columns, values }` in CSR format. */ getNonZeros(options?: { csr?: boolean | undefined; sort?: boolean | undefined; }): any; /** * @param {number} newThreshold * @returns {this} */ setThreshold(newThreshold: number): this; /** * @returns {SparseMatrix} - New transposed sparse matrix */ transpose(): SparseMatrix; /** * @returns {boolean} */ isEmpty(): boolean; /** * @param {number|SparseMatrix} value * @returns {this} */ add(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ addS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ addM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ sub(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ subS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ subM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ subtract(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ subtractS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ subtractM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ mul(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ mulS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ mulM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ multiply(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ multiplyS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ multiplyM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ div(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ divS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ divM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ divide(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ divideS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ divideM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ mod(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ modS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ modM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ modulus(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ modulusS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ modulusM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ and(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ andS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ andM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ or(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ orS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ orM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ xor(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ xorS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ xorM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ leftShift(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ leftShiftS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ leftShiftM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ signPropagatingRightShift(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ signPropagatingRightShiftS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ signPropagatingRightShiftM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ rightShift(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ rightShiftS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ rightShiftM(matrix: SparseMatrix): this; /** * @param {number|SparseMatrix} value * @returns {this} */ zeroFillRightShift(value: number | SparseMatrix): this; /** * @param {number} value * @returns {this} */ zeroFillRightShiftS(value: number): this; /** * @param {SparseMatrix} matrix * @returns {this} */ zeroFillRightShiftM(matrix: SparseMatrix): this; /** * @returns {this} */ not(): this; /** * @returns {this} */ abs(): this; /** * @returns {this} */ acos(): this; /** * @returns {this} */ acosh(): this; /** * @returns {this} */ asin(): this; /** * @returns {this} */ asinh(): this; /** * @returns {this} */ atan(): this; /** * @returns {this} */ atanh(): this; /** * @returns {this} */ cbrt(): this; /** * @returns {this} */ ceil(): this; /** * @returns {this} */ clz32(): this; /** * @returns {this} */ cos(): this; /** * @returns {this} */ cosh(): this; /** * @returns {this} */ exp(): this; /** * @returns {this} */ expm1(): this; /** * @returns {this} */ floor(): this; /** * @returns {this} */ fround(): this; /** * @returns {this} */ log(): this; /** * @returns {this} */ log1p(): this; /** * @returns {this} */ log10(): this; /** * @returns {this} */ log2(): this; /** * @returns {this} */ round(): this; /** * @returns {this} */ sign(): this; /** * @returns {this} */ sin(): this; /** * @returns {this} */ sinh(): this; /** * @returns {this} */ sqrt(): this; /** * @returns {this} */ tan(): this; /** * @returns {this} */ tanh(): this; /** * @returns {this} */ trunc(): this; klass: string; tensorProduct: (other: SparseMatrix) => SparseMatrix; } export namespace SparseMatrix { import identity = SparseMatrix.eye; export { identity }; } export type WithEachNonZeroCallback = (row: number, column: number, value: number) => void; export type ForEachNonZeroCallback = (row: number, column: number, value: number) => number | false; //# sourceMappingURL=index.d.ts.map