Skip to content

Latest commit

 

History

History
80 lines (39 loc) · 1.05 KB

File metadata and controls

80 lines (39 loc) · 1.05 KB

Home > @josh-brown/vector > VectorBuilder > elementaryVector

VectorBuilder.elementaryVector() method

Constructs a vector that has the value 1 at one index, and 0 at the others

Signature:

elementaryVector(dimension: number, oneIndex: number): V;

Parameters

Parameter

Type

Description

dimension

number

The dimension of the new vector

oneIndex

number

The index of the element that should be the multiplicative identity

Returns:

V

The new vector

Example

vectorBuilder.elementaryVector(4, 2); // [ 0 0 1 0 ]
vectorBuilder.elementaryVector(3, 0); // [ 1 0 0 ]