Hide menu
Loading...
Searching...
No Matches
Matrix

Describes base class for a matrix of an arbitrary size.

Extended by

Constructors

new Matrix()

new Matrix(dimension): Matrix

Parameters

dimension

number

Matrix dimension.

Returns

Matrix

Properties

dimension

readonly dimension: number

Matrix dimension.

Accessors

elements

Get Signature

get elements(): number[]

Returns matrix elements array in row-major order.

Returns

number[]

Set Signature

set elements(elements): void

Sets matrix elements. Throw exception if elements length not equal to Matrix::dimension x Matrix::dimension.

Parameters

elements

number[]

Elements array in row-major order.

Returns

void

Methods

add()

add(other): this

Adds elements of other matrix to this matrix. Do nothing if other matrix Matrix::dimension not equal to this matrix Matrix::dimension.

Parameters

other

Matrix

Other matrix.

Returns

this


added()

added(other): Matrix

Returns new Matrix object received by performing a add() operation to this object.

Parameters

other

Matrix

Other matrix.

Returns

Matrix


clone()

abstract clone(): Matrix

Creates new Matrix object same as this.

Returns

Matrix


column()

column(column): number[]

Returns array of elements from column. Throws exception if column greater or equal than Matrix::dimension.

Parameters

column

number

Column index.

Returns

number[]


copy()

copy(other): this

Copies values from another matrix.

Parameters

other

Matrix

Copied object.

Returns

this


determinant()

abstract determinant(): number

Returns this matrix determinant.

Returns

number


diagonal()

diagonal(): number[]

Returns array of diagonal elements.

Returns

number[]


divide()

divide(scalar): this

Divides elements of this matrix by scalar.

Parameters

scalar

number

Scalar.

Returns

this


divided()

divided(scalar): Matrix

Returns new Matrix object received by performing a divide() operation to this object.

Parameters

scalar

number

Scalar.

Returns

Matrix


fill()

fill(value): this

Fill matrix with defined value.

Parameters

value

number

Value to fill matrix.

Returns

this


get()

get(index): number

Returns value of the matrix element placed in row-major order array at index position. Throws exception if index greater or equal than Matrix::dimension x Matrix::dimension.

Parameters

index

number

Element index in row-major order array.

Returns

number


invert()

abstract invert(): this

Inverts this matrix.

Returns

this


inverted()

inverted(): Matrix

Returns new Matrix object received by performing a invert() operation to this object.

Returns

Matrix


isEqual()

isEqual(other, tolerance): boolean

Returns true if this matrix have same Matrix::dimension as other matrix and all the elements are equal within provided tolerance (1e-7 by default).

Parameters

other

Matrix

tolerance

number = Matrix.coincidenceTolerance

Returns

boolean


isIdentity()

isIdentity(): boolean

Returns true if matrix is identity.

Returns

boolean


isSingular()

isSingular(): boolean

Returns true if this matrix determinant tends to 0.

Returns

boolean


multiplied()

Call Signature

multiplied(other): Matrix

Returns new Matrix object received by performing a multiply() operation to this object.

Parameters

other

Matrix

Other matrix.

Returns

Matrix

Call Signature

multiplied(scalar): Matrix

Returns new Matrix object received by performing a multiply() operation to this object.

Parameters

scalar

number

Scalar.

Returns

Matrix


multiply()

Call Signature

multiply(other): this

Multiplies this matrix by other matrix. Throws exception if dimensions of this and other matrixes are not equal.

Parameters

other

Matrix

Other matrix.

Returns

this

Call Signature

multiply(scalar): this

Multiplies elements of this matrix by scalar.

Parameters

scalar

number

Scalar.

Returns

this


power()

power(num): this

Powers this matrix.

Parameters

num

number

Power value.

Returns

this


powered()

powered(num): Matrix

Returns new Matrix object received by performing a power() operation to this object.

Parameters

num

number

Power value.

Returns

Matrix


reset()

reset(): this

Makes this matrix as identity matrix.

Returns

this


row()

row(row): number[]

Returns array of elements from row. Throws exception if row greater or equal than Matrix::dimension.

Parameters

row

number

Row index.

Returns

number[]


set()

set(index, value): this

Sets value of the matrix element placed in row-major order array at index position. Throws exception if index greater or equal than Matrix::dimension x Matrix::dimension.

Parameters

index

number

Element index in row-major order array.

value

number

Element value.

Returns

this


setColumn()

setColumn(column, elements): this

Sets elements in column. Throws exception if column greater or equal than Matrix::dimension or elements length not equal to Matrix::dimension.

Parameters

column

number

Column index.

elements

number[]

Column elements.

Returns

this


setDiagonal()

setDiagonal(elements): this

Sets diagonal elements. Throws exception if elements length not equal to Matrix::dimension.

Parameters

elements

number[]

Diagonal elements.

Returns

this


setElements()

setElements(elements): this

Sets matrix elements. Throw exception if elements length not equal to Matrix::dimension x Matrix::dimension.

Parameters

elements

number[]

Elements array in row-major order.

Returns

this


setRow()

setRow(row, elements): this

Sets elements in row. Throws exception if row greater or equal than Matrix::dimension or elements length not equal to Matrix::dimension.

Parameters

row

number

Row index.

elements

number[]

Row elements.

Returns

this


setScale()

setScale(scale): this

Makes this matrix as identity matrix and fill diagonal with scale values.

Parameters

scale

number

Scale.

Returns

this


setValue()

setValue(row, column, value): this

Sets value from [row][column] of the matrix. Throws exception if row and / or column greater or equal than Matrix::dimension.

Parameters

row

number

Row index.

column

number

Column index.

value

number

New value.

Returns

this


subtract()

subtract(other): this

Subtracts elements of other matrix from this matrix. Do nothing if other matrix Matrix::dimension not equal to this matrix Matrix::dimension.

Parameters

other

Matrix

Other matrix.

Returns

this


subtracted()

subtracted(other): Matrix

Returns new Matrix object received by performing a subtract() operation to this object.

Parameters

other

Matrix

Other matrix.

Returns

Matrix


toString()

toString(precision): string

Returns string representation of this matrix with provided precision (3 by default).

Parameters

precision

number = 3

Precision.

Returns

string


transpose()

transpose(): this

Transposes this matrix.

Returns

this


transposed()

transposed(): Matrix

Returns new Matrix object received by performing a transpose() operation to this object.

Returns

Matrix


value()

value(row, column): number

Returns value from [row][column] of the matrix. Throws exception if row and / or column greater or equal than Matrix::dimension.

Parameters

row

number

Row index.

column

number

Column index.

Returns

number