enhancedmath
Version:
This package contains some enhanced mathematical operations
102 lines (101 loc) • 3.61 kB
TypeScript
/**
* Check if the parameter is of type number
* @param a Any input
*/
export declare const isNumber: <T>(a: T) => boolean;
/**
* Check if the parameter is a fractional value
* @param a The number a
*/
export declare const isFraction: (a: number) => boolean;
/**
* Gets the dimensions of the matrix a
* @param a A matrix (2D array)
*/
export declare const getDimensions: <T>(a: T[][]) => {
rows: number;
cols: number;
};
/**
* Check if the matrix contains string values.
* @param matrix The matrix
*/
export declare const containsStringValues: <T>(matrix: T[][]) => boolean;
/**
* Checks if the matrix is a square one
* @param matrix The matrix
*/
export declare const isSquareMatrix: <T>(matrix: T[][]) => boolean;
/**
* Loops through the matrix to find the row with the most elements an returns how many elements there are
* @param matrix The given matrix
* @returns The amount of elements
*/
export declare const getHighestRowLength: <T>(matrix: T[][]) => number;
export declare const fillEmptyRows: <T>(matrix: T[][], rowLength: number, value: T) => (T | null)[][];
/**
* Generates an identity matrix of size n
* @param n The size of the identity matrix
*/
export declare const generateIdentityMatrix: (n: number) => number[][] | undefined;
/**
* Generates a 0 matrix the size of n
* @param n The size of the 0 matrix
*/
export declare const generateZeroMatrix: (n: number) => number[][] | undefined;
/**
* Swaps 2 rows.
* @param matrix The matrix
* @param r1 First row
* @param r2 Second row
*/
export declare const swapRow: <T>(matrix: T[][], r1: number, r2: number) => T[][] | undefined;
/**
* Swaps two columns
* @param matrix The matrix
* @param c1 First column
* @param c2 Second column
*/
export declare const swapCol: <T>(matrix: T[][], c1: number, c2: number) => T[][] | undefined;
/**
* Swaps 2 elements in an array
* @param matrix The matrix
* @param r1 The first element's row index
* @param c1 The first element's column index
* @param r2 The second element's row index
* @param c2 The second element's column index
*/
export declare const swapElement: <T>(matrix: T[][], r1: number, c1: number, r2: number, c2: number) => T[][] | undefined;
/**
* Multiplies the whole matrix with lambda λX
* @param matrix The matrix
* @param λ The number with which you want to multiply the matrix
* @param precision [precision = 3] The specificity to which you want to round the numbers
*/
export declare const multiplyMatrix: (matrix: number[][], λ: number, precision?: number) => number[][] | undefined;
/**
* Multiplies a single row of the matrix with λ
* @param matrix The matrix
* @param row The row which you want to multiply
* @param λ The number with which you want to multiply the row
*/
export declare const multiplyRow: (matrix: number[][], row: number, λ: number) => number[][] | undefined;
/**
* Multiplies a single column of the matrix with λ
* @param matrix The matrix
* @param col The column which you want to multiply
* @param λ The number with which you want to multiply the column
*/
export declare const multiplyCol: (matrix: number[][], col: number, λ: number) => number[][] | undefined;
/**
* Counts the amount of non 0 rows and subtracts it from the amount of rows in the matrix
* @param matrix The matrix
*/
export declare const rank: (matrix: number[][]) => number;
/**
* Calculates the minor of a given matrix
* @param matrix The matrix
* @param row The row
* @param column The column
*/
export declare const getMatrixMinor: (matrix: number[][], row: number, column: number) => number[][] | undefined;