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). |
Classes
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. |
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). |
Returns:
This Matrix instance for chaining.
- Type
- Matrix
toVector() → {Vector}
Creates a new Vector from a Matrix.
Returns:
- Type
- Vector
(static) add(a, b) → {Matrix}
Adds two Matrixes and returns the result.
Parameters:
Name | Type | Description |
---|---|---|
a |
Matrix | |
b |
Matrix |
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. |
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 |
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 |
Returns:
The result of matrix multiplication.
- Type
- Matrix