Home > @josh-brown/vector > VectorBuilder > elementaryVector
Constructs a vector that has the value 1 at one index, and 0 at the others
Signature:
elementaryVector(dimension: number, oneIndex: number): V;|
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
vectorBuilder.elementaryVector(4, 2); // [ 0 0 1 0 ]
vectorBuilder.elementaryVector(3, 0); // [ 1 0 0 ]