Skip to content

Latest commit

 

History

History
285 lines (126 loc) · 3.95 KB

File metadata and controls

285 lines (126 loc) · 3.95 KB

Home > @josh-brown/vector > ArrayVector

ArrayVector class

Implements Vector with an array of values.

Signature:

export declare abstract class ArrayVector<S = number> implements Vector<S> 

Implements: Vector<S>

Remarks

Subclasses must specify the usual scalar operations on their contents.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the ArrayVector class.

Methods

Method

Modifiers

Description

add(other)

Implements vector addition

builder()

abstract

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

combine(other, combineEntries)

Returns the dimension of the vector

equals(other)

Tests if two vectors are equal

forEach(callback)

Returns the dimension of 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)

Returns the dimension of the vector

matrixBuilder()

abstract

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

ops()

abstract

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