Package org.apache.spark.ml.linalg
Class DenseVector
Object
org.apache.spark.ml.linalg.DenseVector
- All Implemented Interfaces:
Serializable
,Vector
A dense vector represented by a value array.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
apply
(int i) Gets the value of the ith element.int
argmax()
Find the index of a maximal element.copy()
Makes a deep copy of this vector.boolean
int
hashCode()
Returns a hash code value for the vector.int
Number of active entries.int
Number of nonzero elements.int
size()
Size of the vector.double[]
toArray()
Converts the instance to a double array.toString()
static scala.Option<double[]>
unapply
(DenseVector dv) Extracts the value array from a dense vector.double[]
values()
Methods inherited from interface org.apache.spark.ml.linalg.Vector
compressed, compressedWithNNZ, dot, foreach, foreachActive, foreachNonZero, nonZeroIterator, toDense, toSparse
-
Constructor Details
-
DenseVector
public DenseVector(double[] values)
-
-
Method Details
-
unapply
Extracts the value array from a dense vector. -
values
public double[] values() -
size
public int size()Description copied from interface:Vector
Size of the vector. -
toString
-
toArray
public double[] toArray()Description copied from interface:Vector
Converts the instance to a double array. -
apply
public double apply(int i) Description copied from interface:Vector
Gets the value of the ith element. -
copy
Description copied from interface:Vector
Makes a deep copy of this vector. -
equals
-
hashCode
public int hashCode()Description copied from interface: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 tojava.util.Arrays.hashCode
. -
numActives
public int numActives()Description copied from interface:Vector
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.- Specified by:
numActives
in interfaceVector
- Returns:
- (undocumented)
-
numNonzeros
public int numNonzeros()Description copied from interface:Vector
Number of nonzero elements. This scans all active values and count nonzeros.- Specified by:
numNonzeros
in interfaceVector
- Returns:
- (undocumented)
-
argmax
public int argmax()Description copied from interface:Vector
Find the index of a maximal element. Returns the first maximal element in case of a tie. Returns -1 if vector has length 0.
-