org.apache.spark.mllib.linalg
Class DenseVector

Object
  extended by org.apache.spark.mllib.linalg.DenseVector
All Implemented Interfaces:
java.io.Serializable, Vector

public class DenseVector
extends Object
implements Vector

A dense vector represented by a value array.

See Also:
Serialized Form

Constructor Summary
DenseVector(double[] values)
           
 
Method Summary
 double apply(int i)
          Gets the value of the ith element.
 DenseVector copy()
          Makes a deep copy of this vector.
 int hashCode()
          Returns a hash code value for the vector.
 int numActives()
          Number of active entries.
 int numNonzeros()
          Number of nonzero elements.
 int size()
          Size of the vector.
 double[] toArray()
          Converts the instance to a double array.
 SparseVector toSparse()
          Converts this vector to a sparse vector with all explicit zeros removed.
 String toString()
           
static scala.Option<double[]> unapply(DenseVector dv)
          Extracts the value array from a dense vector.
 double[] values()
           
 
Methods inherited from class Object
equals, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.spark.mllib.linalg.Vector
compressed, equals, toDense
 

Constructor Detail

DenseVector

public DenseVector(double[] values)
Method Detail

unapply

public static scala.Option<double[]> unapply(DenseVector dv)
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.

Specified by:
size in interface Vector
Returns:
(undocumented)

toString

public String toString()
Overrides:
toString in class Object

toArray

public double[] toArray()
Description copied from interface: Vector
Converts the instance to a double array.

Specified by:
toArray in interface Vector
Returns:
(undocumented)

apply

public double apply(int i)
Description copied from interface: Vector
Gets the value of the ith element.

Specified by:
apply in interface Vector
Parameters:
i - index
Returns:
(undocumented)

copy

public DenseVector copy()
Description copied from interface: Vector
Makes a deep copy of this vector.

Specified by:
copy in interface Vector
Returns:
(undocumented)

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 nonzeros in the first 16 entries, using a hash algorithm similar to java.util.Arrays.hashCode.

Specified by:
hashCode in interface Vector
Overrides:
hashCode in class Object
Returns:
(undocumented)

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 interface Vector
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 interface Vector
Returns:
(undocumented)

toSparse

public SparseVector toSparse()
Description copied from interface: Vector
Converts this vector to a sparse vector with all explicit zeros removed.

Specified by:
toSparse in interface Vector
Returns:
(undocumented)