Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Matrix

Hierarchy

  • Matrix

Index

Constructors

constructor

  • new Matrix(values: number[], options?: { numCols: number; numRows: number }): Matrix
  • Parameters

    • values: number[]
    • Optional options: { numCols: number; numRows: number }
      • numCols: number
      • numRows: number

    Returns Matrix

Properties

numCols

numCols: number

numRows

numRows: number

values

values: number[]

Methods

add

colAt

  • colAt(column: number): number[]
  • get column at a given index

    Parameters

    • column: number

      index of column starting from 0

    Returns number[]

    column as an array of numbers

determinant

  • determinant(): number
  • calculate determinant, implemented for mat2, mat3, mat4

    Returns number

div

equals

  • equals(otherMatrix: Matrix): boolean
  • check for equality

    Parameters

    • otherMatrix: Matrix

      matrix to compare

    Returns boolean

    true or false

inverse

isFinite

  • isFinite(): boolean
  • Checks if the matrix contains NaN or Infinity values

    Returns boolean

    true if all values are finite (neither NaN nor Infinity)

isNaN

  • isNaN(): boolean
  • Checks if the matrix contains NaN values

    Returns boolean

    true if one of the values is NaN

mul

  • matrix multiplication

    throws

    dimension Mismatch if dimensions doesn't match

    Parameters

    • param: number | Vector | Matrix

      can be a matrix, a number or a vector

    Returns Vector | Matrix

    a vector in case of matrix vector multiplication, else a matrix

roughlyEquals

  • roughlyEquals(otherMatrix: Matrix, delta?: number): boolean
  • check for rough equality (because in JS, .1+.2 !== .3)

    Parameters

    • otherMatrix: Matrix

      matrix to compare

    • delta: number = 1e-14

      tolerance, by default 1e-14

    Returns boolean

    true or false

rowAt

  • rowAt(row: number): number[]
  • get row at a given index

    Parameters

    • row: number

      index of row starting from 0

    Returns number[]

    row as an array of numbers

sub

toArray

  • toArray(): number[]

toString

  • toString(): string
  • convert matrix to string

    Returns string

    a string containing matROWSxCOLS(comma-separated-values)

transpose

valueAt

  • valueAt(row: number, column: number): number
  • get value at a given position

    Parameters

    • row: number

      row index starting from 0

    • column: number

      column index starting from 0

    Returns number

Static fromVector

  • Converts a vector with dimension n into a matrix with 1 col and n rows useful for matrix multiplication

    Parameters

    • value: Vector

      the input vector

    Returns Matrix

Static fromVectors

Static identity

  • identity(dimension: number): Matrix

Generated using TypeDoc