Skip to content

Latest commit

 

History

History
216 lines (100 loc) · 3.25 KB

File metadata and controls

216 lines (100 loc) · 3.25 KB

Home > @josh-brown/vector > Vector

Vector interface

A generalized Vector - one of the core data types

Signature:

export interface Vector<S = number> 

Methods

Method

Description

add(other)

Implements vector addition

builder()

Returns a VectorBuilder which will build new vectors of the same type

combine(other, combineEntries)

Constructs a vector by combining the values of two other vectors

equals(other)

Tests if two vectors are equal

forEach(callback)

Executes the callback function for each entry in the vector.

getDimension()

Returns the dimension of the vector

getEntry(index)

Returns the entry of the matrix located at the provided index (index)

getSparseData()

Returns the contents of the vector as a map of indices to nonzero values

innerProduct(other)

Implements the inner product (scalar product or dot product) of two vectors

map(valueFromEntry)

Constructs a vector by transforming the values of another vector.

matrixBuilder()

Returns a MatrixBuilder which will build new matrices of a compatible type

ops()

Returns a ScalarOperations object which will allow consumers to work generically with the scalars contained in the vector.

outerProduct(other)

Implements the outer product (matrix product) of two vectors

projectOnto(u)

Returns a new vector in the direction of u but with magnitude equal to the amount of the original vector that lies in that direction

scalarMultiply(scalar)

Implements vector multiplication by a scalar

set(index, value)

Returns a new vector equal to the old one, except with the entry at index replaced with value

toArray()

Returns the contents of the vector as an array