Skip to content

Latest commit

 

History

History
89 lines (46 loc) · 1.2 KB

File metadata and controls

89 lines (46 loc) · 1.2 KB

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

MatrixBuilder.pascal() method

Constructs a lower-triangular matrix whose entries are the binomial coefficients (j choose i). Constructs an upper triangular matrix when the second argument is true.

Signature:

pascal(size: number, upper?: boolean): M;

Parameters

Parameter

Type

Description

size

number

The size of the Pascal matrix

upper

boolean

(Optional) Construct an upper-triangular matrix (i choose j)

Returns:

M

Example

const pascalLower = matrixBuilder.pascal(4);

// [ 1 0 0 0 ]
// [ 1 1 0 0 ]
// [ 1 2 1 0 ]
// [ 1 3 3 1 ]

const pascalUpper = matrixBuilder.pascal(4, true);

// [ 1 1 1 1 ]
// [ 0 1 2 3 ]
// [ 0 0 1 3 ]
// [ 0 0 0 1 ]