org.apache.spark.mllib.linalg
Interface Vector

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
DenseVector, SparseVector

public interface Vector
extends scala.Serializable

Represents a numeric vector, whose index type is Int and value type is Double.

Note: Users should not implement this interface.


Method Summary
 double apply(int i)
          Gets the value of the ith element.
 Vector compressed()
          Returns a vector in either dense or sparse format, whichever uses less storage.
 Vector copy()
          Makes a deep copy of this vector.
 boolean equals(Object other)
           
 void foreachActive(scala.Function2<Object,Object,scala.runtime.BoxedUnit> f)
          Applies a function f to all the active elements of dense and sparse 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.
 breeze.linalg.Vector<Object> toBreeze()
          Converts the instance to a breeze vector.
 DenseVector toDense()
          Converts this vector to a dense vector.
 SparseVector toSparse()
          Converts this vector to a sparse vector with all explicit zeros removed.
 

Method Detail

size

int size()
Size of the vector.

Returns:
(undocumented)

toArray

double[] toArray()
Converts the instance to a double array.

Returns:
(undocumented)

equals

boolean equals(Object other)
Overrides:
equals in class Object

hashCode

int hashCode()
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.

Overrides:
hashCode in class Object
Returns:
(undocumented)

toBreeze

breeze.linalg.Vector<Object> toBreeze()
Converts the instance to a breeze vector.

Returns:
(undocumented)

apply

double apply(int i)
Gets the value of the ith element.

Parameters:
i - index
Returns:
(undocumented)

copy

Vector copy()
Makes a deep copy of this vector.

Returns:
(undocumented)

foreachActive

void foreachActive(scala.Function2<Object,Object,scala.runtime.BoxedUnit> f)
Applies a function f to all the active elements of dense and sparse vector.

Parameters:
f - 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.

numActives

int numActives()
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.

Returns:
(undocumented)

numNonzeros

int numNonzeros()
Number of nonzero elements. This scans all active values and count nonzeros.

Returns:
(undocumented)

toSparse

SparseVector toSparse()
Converts this vector to a sparse vector with all explicit zeros removed.

Returns:
(undocumented)

toDense

DenseVector toDense()
Converts this vector to a dense vector.

Returns:
(undocumented)

compressed

Vector compressed()
Returns a vector in either dense or sparse format, whichever uses less storage.

Returns:
(undocumented)