lnagb.js Documentation

IdentityMatrix

Contains the IdentityMatrix class, which encodes read-only identity matrices.

Author: Zach / cszach@proton.me


IdentityMatrix~IdentityMatrix

Encodes read-only identity matrices and their operations. Being read-only means instances of this class cannot have their elements modified (e.g. by matrix addition or row operations).

Properties are encoded similarly to Matrix. Many methods in Matrix are absent in this class. Some are implemented differently. The elements property of an IdentityMatrix instance only serves for compatibility with other matrix classes; IdentityMatrix class methods don’t rely on it themselves.

While rows and columns are getters in the Matrix class, they are properties here. For this reason, if you want to assign a variable to either of them, you should add .slice() to clone, avoiding any unwanted problems with pointers.

Kind: inner class of IdentityMatrix


new IdentityMatrix(size)

Constructs a new IdentityMatrix instance, which encodes an identity matrix.

Param Type Description
size number Number of rows (or columns) in the new identity matrix.

identityMatrix.clone() ⇒ IdentityMatrix

Creates and returns a clone of this identity matrix instance.

Kind: instance method of IdentityMatrix
Returns: IdentityMatrix - A clone of this instance


identityMatrix.equals(matrix) ⇒ boolean

Checks if this matrix and another matrix are equal.

Kind: instance method of IdentityMatrix
Returns: boolean - true if the two matrices are equal, false otherwise

Param Type Description
matrix Matrix The matrix to compare this matrix to.

identityMatrix.entry(r, c) ⇒ number

Returns the entry in the specified row and column in this matrix.

Kind: instance method of IdentityMatrix
Returns: number - The entry

Param Type Description
r number The row that contains the entry (1-indexed).
c number The column that contains the entry (1-indexed).

identityMatrix.row(r) ⇒ Array.<number>

Returns a row in this matrix as a JavaScript array.

Kind: instance method of IdentityMatrix
Returns: Array.<number> - The row’s entries

Param Type Description
r number Row number (1-indexed).

identityMatrix.column(c) ⇒ Array.<number>

Returns a column in this matrix as a JavaScript array.

Kind: instance method of IdentityMatrix
Returns: Array.<number> - The column’s entries

Param Type Description
c number Column number (1-indexed).

identityMatrix.leadingCoefficient(r) ⇒ number

Returns the leading coefficient of a row, which is always 1 since this is an identity matrix.

Kind: instance method of IdentityMatrix
Returns: number - The leading coefficient of the row

Param Type Description
r number Row number (1-indexed) (this will be disregarded).

identityMatrix.forEach(callback, thisArg)

Executes a function for each entry in this matrix.

Kind: instance method of IdentityMatrix

Param Type Description
callback forEach The function to execute per iteration.
thisArg object The argument to use as this in the function.

identityMatrix.forEachRow(callback, thisArg)

Executes a function for each row in this matrix.

Kind: instance method of IdentityMatrix

Param Type Description
callback forEachRow The function to execute per iteration.
thisArg object The argument to use as this in the function.

identityMatrix.forEachColumn(callback, thisArg)

Executes a function for each column in this matrix.

Kind: instance method of IdentityMatrix

Param Type Description
callback forEachColumn The function to execute per iteration.
thisArg object The argument to use as this in the function.

IdentityMatrix~forEach : function

Kind: inner typedef of IdentityMatrix

Param Type Description
entry number The current entry being processed.
i number The entry’s row number (1-indexed).
j number The entry’s column number (1-indexed).
index number The index of the entry in this.elements (0-indexed).
matrix IdentityMatrix The instance that this method was called upon.

IdentityMatrix~forEachRow : function

Kind: inner typedef of IdentityMatrix

Param Type Description
row Array.<number> The current row being processed (with its entries).
r number Current row number (1-indexed).
matrix IdentityMatrix The instance that this method was called upon.

IdentityMatrix~forEachColumn : function

Kind: inner typedef of IdentityMatrix

Param Type Description
column Array.<number> The current column being processed (with its entries).
c number Current column number (1-indexed).
matrix IdentityMatrix The instance that this method was called upon.