Skip to content

Latest commit

 

History

History
133 lines (64 loc) · 1.61 KB

File metadata and controls

133 lines (64 loc) · 1.61 KB

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

MatrixBuilder.slice() method

Constructs a new matrix based on a rectangular slice of a larger matrix

Signature:

slice(matrix: Matrix<S>, rowStartIndex?: number, columnStartIndex?: number, rowEndIndex?: number, columnEndIndex?: number): M;

Parameters

Parameter

Type

Description

matrix

Matrix<S>

The original matrix

rowStartIndex

number

(Optional) The (inclusive) first row of the slice

columnStartIndex

number

(Optional) The (inclusive) first column of the slice

rowEndIndex

number

(Optional) The (exclusive) last row of the slice

columnEndIndex

number

(Optional) The (exclusive) last column of the slice

Returns:

M

The new matrix

Example

const matrix = matrixBuilder.identity(4);
const slice = matrixBuilder.slice(matrix, 2, 2, 3, 4);

// [  1  0  0  0  ]
// [  0  1* 0* 0* ]  =>  [ 1 0 0 ]
// [  0  0* 1* 0* ]      [ 0 1 0 ]
// [  0  0  0  1  ]