UNPKG

xen-dev-utils

Version:

Utility functions used by the Scale Workshop ecosystem

60 lines (59 loc) 1.97 kB
/** * Fix a 2-D matrix to have full rows (pad with zeros). * @param M Input matrix. * @returns Height, width, the padded matrix and the corresponding 0 or 0n and 1 or 1n. */ export declare function padMatrix<T extends number | bigint>(M: T[][]): { height: number; width: number; zero: T; one: number | bigint; M: T[][]; }; /** * Compute the Hermite normal form of a matrix of integers. * @param A The input matrix. * @returns The input in Hermite normal form. */ export declare function hnf<T extends number | bigint>(A: T[][]): T[][]; /** * Prune rows filled with falsy values from a 2-D matrix. * @param A Matrix to prune in-place. */ export declare function pruneZeroRows(A: any[][]): void; /** * Compute the determinant of a matrix of integers. * @param A The input matrix. * @returns The determinant. */ export declare function integerDet<T extends number | bigint>(A: T[][]): T; /** * Anti-transpose a 2-D matrix (swap rows and columns along the other diagonal). * @param matrix Matrix to antitranspose. * @returns The antitranspose. */ export declare function antitranspose<T extends number | bigint>(matrix: T[][]): T[][]; /** * Transpose a 2-D matrix (swap rows and columns). * @param matrix Matrix to transpose. * @returns The transpose. */ export declare function transpose<T extends number | bigint>(matrix: T[][]): T[][]; /** * Find the left kernel (nullspace) of the input matrix. * @param A The input matrix. * @returns The kernel matrix. */ export declare function kernel<T extends number | bigint>(A: T[][]): T[][]; /** * Find the right kernel (nullspace) of the input matrix. * @param A The input matrix. * @returns The kernel matrix. */ export declare function cokernel<T extends number | bigint>(A: T[][]): T[][]; /** * Find the preimage X of A such that AX = I. * @param A The input matrix. * @returns The preimage. */ export declare function preimage<T extends number | bigint>(A: T[][]): T[][];