Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Matrix

classdesc

Works with any n x m dimensional array.

Hierarchy

Index

Constructors

constructor

  • new Matrix(matrix2D: number[][]): Matrix
  • new Matrix(row: number, col: number, defaultFill?: undefined | number): Matrix
  • constructs

    Creates a new 2 dimensional Matrix object.

    Parameters

    • matrix2D: number[][]

      A general 2 dimensional array which represents the data in the matrix object to be created

    Returns Matrix

  • constructs

    Creates a new 2 dimensional Matrix object with given rows and columns

    Parameters

    • row: number

      Number of rows the matrix should have.

    • col: number

      Number of columns the matrix should have.

    • Optional defaultFill: undefined | number

      Optional | The default value with which to fill all elements in the matrix.

    Returns Matrix

Properties

col

col: number

elements

elements: number[][]

row

row: number

Accessors

data

  • get data(): dataAt

Methods

add

  • Adds two matrices algebraically.

    throws

    If the orders of the matrices do not match.

    Parameters

    • that: Matrix

      Matrix to add to this matrix.

    Returns Matrix

    The matrix sum of the two matrices.

cofactor

  • cofactor(i: number, j: number): number
  • Calculates the cofactor of an element in the matrix given by its row and column.

    Parameters

    • i: number

      Row index of element.

    • j: number

      Column index of element,

    Returns number

copy

inv

  • Calculates the inverse of the given matrix.

    throws

    If Matrix.det(this) == 0

    Returns Matrix

minor

  • minor(i: number, j: number): number
  • Calculates the minor of an element in the matrix given by its row and column.

    Parameters

    • i: number

      Row index of element.

    • j: number

      Column index of element,

    Returns number

mul

  • Multiplies two matrices. The number of columns of this matrix must be equal to the number of rows of that matrix. The resulting matrix has the same number of rows as this matrix and the same number of columns as that matrix.

    Parameters

    • that: Matrix

      Matrix with which to multiply.

    Returns Matrix

    The matrix product of the two matrices.

scale

  • Scales this matrix by a given scale factor. Scaling implies multiplying each element of this matrix by some scale factor k

    Parameters

    • k: number

      The scale factor.

    Returns Matrix

sub

  • Subtracts one matrix from another algebraically.

    throws

    If the orders of the matrices do not match.

    Parameters

    • that: Matrix

      Matrix to subtract from this matrix.

    Returns Matrix

    The matrix difference of the two matrices.

Static add

Static adjoint

Static comatrix

  • Calculates the cofactors of each element in some matrix A and stores them in their corresponding indices in the form of another matrix.

    Parameters

    Returns Matrix

Static det

  • Computes the determinant value of some matrix A.

    Parameters

    Returns number

Static mul

  • Performs matrix multiplication on given matrices A and B.

    throws

    If A.col != B.row

    Parameters

    Returns Matrix

Static sub

Static transpose

Static unit

  • Creates and returns a unit matrix with dim rows and columns.

    Parameters

    • dim: number

      Dimension of the desired matrix

    Returns Matrix

Generated using TypeDoc