Skip to content

Latest commit

 

History

History
103 lines (51 loc) · 1.88 KB

File metadata and controls

103 lines (51 loc) · 1.88 KB

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

MatrixBuilder.tridiagonal() method

Constructs a square tridiagonal matrix whose diagonal entries correspond to the entries of diagonalEntries, whose entries in the left-off-diagonal correspond to the entries of leftEntries, and whose entries in the right-off-diagonal correspond fo the entries of rightEntries. The off-diagonals must have one fewer entry than the diagonal. Throws an error if the dimensions are not correct.

Signature:

tridiagonal(leftEntries: Vector<S>, diagonalEntries: Vector<S>, rightEntries: Vector<S>): M;

Parameters

Parameter

Type

Description

leftEntries

Vector<S>

A vector whose entries will be used in the left off-diagonal

diagonalEntries

Vector<S>

A vector whose entries will be used in the diagonal

rightEntries

Vector<S>

A vector whose entries will be used in the right off-diagonal

Returns:

M

The new matrix

Example

const leftEntries = NumberVector.fromEntries(1, 2);
const diagonalEntries = NumberVector.fromEntries(3, 4, 5);
const rightEntries = NumberVector.fromEntries(6, 7);

const tridiagonal = matrixBuilder.tridiagonal(leftEntries, diagonalEntries, rightEntries);

// [ 3 6 0 ]
// [ 1 4 7 ]
// [ 0 2 5 ]