// creates a 2x3 matrix
const A = new Matrix([
[1, 2, 3],
[4, 5, 6],
]);
// creates a 2x3 matrix
const B = new Matrix([1, 2, 3, 4, 5, 6], 2, 3);
// creates a 3x2 matrix
const B = new Matrix([1, 2, 3, 4, 5, 6], 3, 2);
// creates an 1x6 matrix
const B = new Matrix([1, 2, 3, 4, 5, 6], 1, 6);
// results [[0, 0, 0, 0], [0, 0, 0, 0]];
const matrix = zeros(2, 4);
// results [[1], [1], [1]];
const matrix = zeros(3, 1);
// [[0, 0, 0], [0, 1, 0], [0, 0, 1]];
const matrix = identity(3);
Make a full copy of source matrix
const A = new Matrix([
[1, 2, 3],
[4, 5, 6],
]);
const B = A.clone();
Creates a diagonal matrix using elements from a 1D array
const v = [-1, 4, 2);
const B = diagonal(v);
// B is [[-1, 0, 0], [0, 4, 0], [0, 0, 2]];