Semagle.Numerics.Vectors Library
The library provides two DenseVector and SparseVector with corresponding operations,
which are commonly used in machine learning applications.
Creating Vectors
DenseVector is constructed from the array of float32 values.
This type of vector stores zero and non-zero values and suits well for feature
vectors with many non-zero elements.
1: 2: |
|
SparseVector is constructed from the array of int indices of non-zero elements
and the array of float32 values of non-zero elements. This type of vector suits well
for feature vectors with a few non-zero elements.
1: 2: |
|
Operations
Indexing and Slicing
DenseVector and SparseVector support indexing and slicing operations, but
implementations of SparseVector operations are more expensive because they require
binary search for finding item indeces.
1: 2: 3: 4: |
|
Element-wise Operations
DenseVector and SparseVector support element wise addition, subtraction, multiplication and division.
1: 2: 3: 4: |
|
Negation and Multiplication/Division by Scalar
DenseVector and SparseVector support unary negation and multiplication/division by scalar.
1: 2: 3: |
|
Dot/Inner Product
Dot product is a key operation of many machine learning algoritms and DenseVector and SparseVector
provide the effective implementations of this operation.
1:
|
|