Class: Matrix

Matrix(rows, cols)

Class representing a Matrix.

Constructor

new Matrix(rows, cols)

Creates a new Matrix.

Parameters:
Name Type Description
rows number

Rows (must be positive integer).

cols number

Columns (must be positive integer).

Source:

Classes

Matrix

Methods

add(n) → {Matrix}

Adds values to a Matrix. Input can either be a single number, or another instance of Matrix if it has the same dimensionality.

Parameters:
Name Type Description
n Matrix | number

The input to add to this matrix.

Source:
Returns:

The current Matrix instance for chaining.

Type
Matrix

scale(n) → {Matrix}

Multiplies a Matrix by a scalar, either a single number or another Matrix.

Parameters:
Name Type Description
n Matrix | number

The scalar (must be a number or a Matrix).

Source:
Returns:

This Matrix instance for chaining.

Type
Matrix

toVector() → {Vector}

Creates a new Vector from a Matrix.

Source:
Returns:
Type
Vector

(static) add(a, b) → {Matrix}

Adds two Matrixes and returns the result.

Parameters:
Name Type Description
a Matrix
b Matrix
Source:
Returns:

A Matrix with data resulting from element-wise addition.

Type
Matrix

(static) fromVector(v) → {Matrix}

Returns a new Matrix from a given Vector.

Parameters:
Name Type Description
v Vector

The input vector.

Source:
Returns:

A matrix with data rows corresponding to the vector components.

Type
Matrix

(static) hasEqualDimensions(a, b) → {boolean}

Checks if two Matrixes have the same number of rows and columns.

Parameters:
Name Type Description
a Matrix
b Matrix
Source:
Returns:

True if Matrixes are of the same dimensionality, otherwise false.

Type
boolean

(static) multiply(a, b) → {Matrix}

Multiply two Matrixes and return the result.

Parameters:
Name Type Description
a Matrix
b Matrix
Source:
Returns:

The result of matrix multiplication.

Type
Matrix