Matrix

The "matrix" type which can be used in the custom JavaScript functions (primitives) in formulas.

NameTypeDefaultDescription

height

number

Indicate the height of the matrix.

width

number

Indicate the width of the matrix.

Constructors

Matrix

(context: Context)

Parameters

context

Context

Methods

clone

Returns a new matrix with the same data.

Returns

Matrix

determinant

Returns the determinant of this matrix. The matrix should contain only numbers and be square. Note that there are no checks for this.

Returns

number

each

Iterates through elements of the matrix and calling the func for each element (first columns, then rows).

Parameters

func

(value: any, row: number, column: number) => void

The function which will be called for each element.

includeEmpty

boolean

If true, it will call the function for empty (null) elements as well. Otherwise, it only calls it where a value exists.

get

Returns the element at a given location.

Parameters

row

number

col

number

Returns

any

inverse

Returns the inverse of this matrix. The matrix should contain only numbers and be square. Note that there are no checks for this. If the inverse does not exist, the determinant is zero, then it returns null.

Returns

"null" | Matrix

map

Similar to each, but produces a new matrix of the same shape as the original one with the values returned by the function.

Parameters

func

(value: any, row: number, column: number) => void

The function which will be called for each element.

includeEmpty

boolean

If true, it will call the function for empty (null) elements as well. Otherwise, it only calls it where a value exists.

Returns

Matrix

multiply

Multiplies the current matrix by the given matrix, and returns a new matrix as the result.

Parameters

m

Matrix

Returns

Matrix

set

Sets the element at a given location.

Parameters

row

number

col

number

value

any

transpose

Returns the transposed matrix. The rows of the original matrix become columns of the transposed one.

Returns

Matrix

unit

Returns the unit square matrix of size n.

Parameters

n

number

Returns

Matrix