Class: Matrix

Matrix~Matrix(a)

A matrix (plural matrices) is a rectangular array or table of numbers, arranged in rows and columns, which is used to represent a mathematical object or a property of such an object.

Constructor

new Matrix(a)

Parameters:
Name Type Description
a Array 2-dimensional array that initializes the matrix.
Source:
See:
Example
const matrix = new Matrix( [[1, 2],[3, 4]] );

Members

length

returns the number of rows in the matrix.
Source:

Methods

forEach()

calls a function for each row in the matrix.
Source:
See:

multiply(b)

Multiplies this matrix by another matrix
Parameters:
Name Type Description
b Matrix | Array multiplication matrix or 2-dimensional array that is the matrix or 1-dimensional array that is the vector.
Source:
See:
Returns:
new matrix as result of multiplication of matrices.
Example
const matrix = new Matrix( [[1, 2], [3, 4], [5, 6]] );
const res = matrix.multiply( [[7, 8, 9, 10], [11, 12, 13,14] );
res is : [[29, 32, 35, 38], [65, 72, 79, 86], [101, 112, 123, 134]]