org.apache.spark.mllib.linalg
Class Vectors

Object
  extended by org.apache.spark.mllib.linalg.Vectors

public class Vectors
extends Object


Constructor Summary
Vectors()
           
 
Method Summary
static Vector dense(double[] values)
          Creates a dense vector from a double array.
static Vector dense(double firstValue, double... otherValues)
          Creates a dense vector from its values.
static Vector dense(double firstValue, scala.collection.Seq<Object> otherValues)
          Creates a dense vector from its values.
static double norm(Vector vector, double p)
          Returns the p-norm of this vector.
static Vector parse(String s)
          Parses a string resulted from Vector.toString into a Vector.
static Vector sparse(int size, int[] indices, double[] values)
          Creates a sparse vector providing its index array and value array.
static Vector sparse(int size, Iterable<scala.Tuple2<Integer,Double>> elements)
          Creates a sparse vector using unordered (index, value) pairs in a Java friendly way.
static Vector sparse(int size, scala.collection.Seq<scala.Tuple2<Object,Object>> elements)
          Creates a sparse vector using unordered (index, value) pairs.
static double sqdist(Vector v1, Vector v2)
          Returns the squared distance between two Vectors.
static Vector zeros(int size)
          Creates a vector of all zeros.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vectors

public Vectors()
Method Detail

dense

public static Vector dense(double firstValue,
                           double... otherValues)
Creates a dense vector from its values.

Parameters:
firstValue - (undocumented)
otherValues - (undocumented)
Returns:
(undocumented)

dense

public static Vector dense(double firstValue,
                           scala.collection.Seq<Object> otherValues)
Creates a dense vector from its values.

Parameters:
firstValue - (undocumented)
otherValues - (undocumented)
Returns:
(undocumented)

dense

public static Vector dense(double[] values)
Creates a dense vector from a double array.

Parameters:
values - (undocumented)
Returns:
(undocumented)

sparse

public static Vector sparse(int size,
                            int[] indices,
                            double[] values)
Creates a sparse vector providing its index array and value array.

Parameters:
size - vector size.
indices - index array, must be strictly increasing.
values - value array, must have the same length as indices.
Returns:
(undocumented)

sparse

public static Vector sparse(int size,
                            scala.collection.Seq<scala.Tuple2<Object,Object>> elements)
Creates a sparse vector using unordered (index, value) pairs.

Parameters:
size - vector size.
elements - vector elements in (index, value) pairs.
Returns:
(undocumented)

sparse

public static Vector sparse(int size,
                            Iterable<scala.Tuple2<Integer,Double>> elements)
Creates a sparse vector using unordered (index, value) pairs in a Java friendly way.

Parameters:
size - vector size.
elements - vector elements in (index, value) pairs.
Returns:
(undocumented)

zeros

public static Vector zeros(int size)
Creates a vector of all zeros.

Parameters:
size - vector size
Returns:
a zero vector

parse

public static Vector parse(String s)
Parses a string resulted from Vector.toString into a Vector.

Parameters:
s - (undocumented)
Returns:
(undocumented)

norm

public static double norm(Vector vector,
                          double p)
Returns the p-norm of this vector.

Parameters:
vector - input vector.
p - norm.
Returns:
norm in L^p^ space.

sqdist

public static double sqdist(Vector v1,
                            Vector v2)
Returns the squared distance between two Vectors.

Parameters:
v1 - first Vector.
v2 - second Vector.
Returns:
squared distance between two Vectors.