doubly-linked-list-typed
Version:
Doubly Linked List
169 lines (168 loc) • 8.28 kB
TypeScript
/**
* data-structure-typed
*
* @author Pablo Zeng
* @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
* @license MIT License
*/
import type { MatrixOptions } from '../../types';
/**
*
*/
export declare class Matrix {
/**
* The constructor function initializes a matrix object with the provided data and options, or with
* default values if no options are provided.
* @param {number[][]} data - A 2D array of numbers representing the data for the matrix.
* @param [options] - The `options` parameter is an optional object that can contain the following
* properties:
*/
constructor(data: number[][], options?: MatrixOptions);
protected _rows: number;
/**
* The function returns the number of rows.
* @returns The number of rows.
*/
get rows(): number;
protected _cols: number;
/**
* The function returns the value of the protected variable _cols.
* @returns The number of columns.
*/
get cols(): number;
protected _data: number[][];
/**
* The function returns a two-dimensional array of numbers.
* @returns The data property, which is a two-dimensional array of numbers.
*/
get data(): number[][];
/**
* The above function returns the value of the _addFn property.
* @returns The value of the property `_addFn` is being returned.
*/
get addFn(): (a: number | undefined, b: number) => number | undefined;
/**
* The function returns the value of the _subtractFn property.
* @returns The `_subtractFn` property is being returned.
*/
get subtractFn(): (a: number, b: number) => number;
/**
* The function returns the value of the _multiplyFn property.
* @returns The `_multiplyFn` property is being returned.
*/
get multiplyFn(): (a: number, b: number) => number;
/**
* The `get` function returns the value at the specified row and column index if it is a valid index.
* @param {number} row - The `row` parameter represents the row index of the element you want to
* retrieve from the data array.
* @param {number} col - The parameter "col" represents the column number of the element you want to
* retrieve from the data array.
* @returns The `get` function returns a number if the provided row and column indices are valid.
* Otherwise, it returns `undefined`.
*/
get(row: number, col: number): number | undefined;
/**
* The set function updates the value at a specified row and column in a two-dimensional array.
* @param {number} row - The "row" parameter represents the row index of the element in a
* two-dimensional array or matrix. It specifies the row where the value will be set.
* @param {number} col - The "col" parameter represents the column index of the element in a
* two-dimensional array.
* @param {number} value - The value parameter represents the number that you want to set at the
* specified row and column in the data array.
* @returns a boolean value. It returns true if the index (row, col) is valid and the value is
* successfully set in the data array. It returns false if the index is invalid and the value is not
* set.
*/
set(row: number, col: number, value: number): boolean;
/**
* The function checks if the dimensions of the given matrix match the dimensions of the current
* matrix.
* @param {Matrix} matrix - The parameter `matrix` is of type `Matrix`.
* @returns a boolean value.
*/
isMatchForCalculate(matrix: Matrix): boolean;
/**
* The `add` function adds two matrices together, returning a new matrix with the result.
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
* @returns The `add` method returns a new `Matrix` object that represents the result of adding the
* current matrix with the provided `matrix` parameter.
*/
add(matrix: Matrix): Matrix | undefined;
/**
* The `subtract` function performs element-wise subtraction between two matrices and returns a new
* matrix with the result.
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class. It
* represents the matrix that you want to subtract from the current matrix.
* @returns a new Matrix object with the result of the subtraction operation.
*/
subtract(matrix: Matrix): Matrix | undefined;
/**
* The `multiply` function performs matrix multiplication between two matrices and returns the result
* as a new matrix.
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
* @returns a new Matrix object.
*/
multiply(matrix: Matrix): Matrix | undefined;
/**
* The transpose function takes a matrix and returns a new matrix that is the transpose of the
* original matrix.
* @returns The transpose() function returns a new Matrix object with the transposed data.
*/
transpose(): Matrix;
/**
* The `inverse` function calculates the inverse of a square matrix using Gaussian elimination.
* @returns a Matrix object, which represents the inverse of the original matrix.
*/
inverse(): Matrix | undefined;
/**
* The dot function calculates the dot product of two matrices and returns a new matrix.
* @param {Matrix} matrix - The `matrix` parameter is an instance of the `Matrix` class.
* @returns a new Matrix object.
*/
dot(matrix: Matrix): Matrix | undefined;
/**
* The function checks if a given row and column index is valid within a specified range.
* @param {number} row - The `row` parameter represents the row index of a two-dimensional array or
* matrix. It is a number that indicates the specific row in the matrix.
* @param {number} col - The "col" parameter represents the column index in a two-dimensional array
* or grid. It is used to check if the given column index is valid within the bounds of the grid.
* @returns A boolean value is being returned.
*/
isValidIndex(row: number, col: number): boolean;
/**
* The `clone` function returns a new instance of the Matrix class with the same data and properties
* as the original instance.
* @returns The `clone()` method is returning a new instance of the `Matrix` class with the same data
* and properties as the current instance.
*/
clone(): Matrix;
protected _addFn(a: number | undefined, b: number): number | undefined;
protected _subtractFn(a: number, b: number): number;
protected _multiplyFn(a: number, b: number): number;
/**
* The function `_swapRows` swaps the positions of two rows in an array.
* @param {number} row1 - The `row1` parameter is the index of the first row that you want to swap.
* @param {number} row2 - The `row2` parameter is the index of the second row that you want to swap
* with the first row.
*/
protected _swapRows(row1: number, row2: number): void;
/**
* The function scales a specific row in a matrix by a given scalar value.
* @param {number} row - The `row` parameter represents the index of the row in the matrix that you
* want to scale. It is a number that indicates the position of the row within the matrix.
* @param {number} scalar - The scalar parameter is a number that is used to multiply each element in
* a specific row of a matrix.
*/
protected _scaleRow(row: number, scalar: number): void;
/**
* The function `_addScaledRow` multiplies a row in a matrix by a scalar value and adds it to another
* row.
* @param {number} targetRow - The targetRow parameter represents the index of the row in which the
* scaled values will be added.
* @param {number} sourceRow - The sourceRow parameter represents the index of the row from which the
* values will be scaled and added to the targetRow.
* @param {number} scalar - The scalar parameter is a number that is used to scale the values in the
* source row before adding them to the target row.
*/
protected _addScaledRow(targetRow: number, sourceRow: number, scalar: number): void;
}