Gets the value of the ith element.
Find the index of a maximal element.
Find the index of a maximal element. Returns the first maximal element in case of a tie. Returns -1 if vector has length 0.
Returns a vector in either dense or sparse format, whichever uses less storage.
Returns a vector in either dense or sparse format, whichever uses less storage.
Makes a deep copy of this vector.
Makes a deep copy of this vector.
Applies a function f
to all the active elements of dense and sparse vector.
Applies a function f
to all the active elements of dense and sparse vector.
the function takes two parameters where the first parameter is the index of
the vector with type Int
, and the second parameter is the corresponding value
with type Double
.
Returns a hash code value for the vector.
Returns a hash code value for the vector. The hash code is based on its size and its first 128 nonzero entries, using a hash algorithm similar to java.util.Arrays.hashCode.
index array, assume to be strictly increasing.
index array, assume to be strictly increasing.
Number of active entries.
Number of active entries. An "active entry" is an element which is explicitly stored, regardless of its value. Note that inactive entries have value 0.
Number of nonzero elements.
Number of nonzero elements. This scans all active values and count nonzeros.
size of the vector.
size of the vector.
Converts the instance to a double array.
Converts the instance to a double array.
Converts this vector to a dense vector.
Converts this vector to a dense vector.
Converts the vector to a JSON string.
Converts the vector to a JSON string.
Converts this vector to a sparse vector with all explicit zeros removed.
Converts this vector to a sparse vector with all explicit zeros removed.
value array, must have the same length as the index array.
value array, must have the same length as the index array.
A sparse vector represented by an index array and an value array.