Skip to content

Latest commit

 

History

History
77 lines (42 loc) · 1.24 KB

File metadata and controls

77 lines (42 loc) · 1.24 KB

Home > @josh-brown/vector > MatrixBuilder > block

MatrixBuilder.block() method

Constructs a single matrix consisting of a grid of matrices combined together. Throws an error if any of the dimensions are incompatible.

Signature:

block(grid: Matrix<S>[][]): M;

Parameters

Parameter

Type

Description

grid

Matrix<S>[][]

A 2-dimensional array of matrices that will be combined into the new matrix

Returns:

M

The new matrix

Example

const upperLeft = matrixBuilder.ones(1, 1);
const upperRight = matrixBuilder.fill(2, 1, 2);
const lowerLeft = matrixBuilder.fill(3, 2, 1);
const lowerRight = matrixBuilder.fill(4, 2, 2);

const grid = [
  [ upperLeft, upperRight ],
  [ lowerLeft, lowerRight ]
];

const block = matrixBuilder.block(grid);

// [ 1 2 2 ]
// [ 3 4 4 ]
// [ 3 4 4 ]