Home > @josh-brown/vector > SparseVector
Implements Vector as a map of indices to nonzero values.
Signature:
export declare abstract class SparseVector<S = number> implements Vector<S> Implements: Vector<S>
For large vectors with many entries equal to 0, some operations are more efficient with a Vector implementation that only stores the non-zero values.
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 SparseVector class.
|
Method |
Modifiers |
Description |
|---|---|---|
|
Implements vector addition | ||
|
| ||
|
Returns the dimension of the vector | ||
|
Tests if two vectors are equal | ||
|
Returns the dimension of the vector | ||
|
Returns the dimension of the vector | ||
|
Returns the entry of the matrix located at the provided index ( | ||
|
Returns the contents of the vector as a map of indices to nonzero values | ||
|
Implements the inner product (scalar product or dot product) of two vectors | ||
|
Returns the dimension of the vector | ||
|
| ||
|
| ||
|
Implements the outer product (matrix product) of two vectors | ||
|
Returns a new vector in the direction of | ||
|
Implements vector multiplication by a scalar | ||
|
Returns a new vector equal to the old one, except with the entry at | ||
|
Returns the contents of the vector as an array |