public class Vectors
extends Object
Vector
.
We don't use the name Vector
because Scala imports
scala.collection.immutable.Vector
by default.Constructor and Description |
---|
Vectors() |
Modifier and Type | Method and Description |
---|---|
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 Vector |
fromJson(String json)
Parses the JSON representation of a vector into a
Vector . |
static Vector |
fromML(Vector v)
Convert new linalg type to spark.mllib type.
|
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.
|
public static Vector dense(double firstValue, double... otherValues)
firstValue
- (undocumented)otherValues
- (undocumented)public static Vector dense(double firstValue, scala.collection.Seq<Object> otherValues)
firstValue
- (undocumented)otherValues
- (undocumented)public static Vector dense(double[] values)
values
- (undocumented)public static Vector sparse(int size, int[] indices, double[] values)
size
- vector size.indices
- index array, must be strictly increasing.values
- value array, must have the same length as indices.public static Vector sparse(int size, scala.collection.Seq<scala.Tuple2<Object,Object>> elements)
size
- vector size.elements
- vector elements in (index, value) pairs.public static Vector sparse(int size, Iterable<scala.Tuple2<Integer,Double>> elements)
size
- vector size.elements
- vector elements in (index, value) pairs.public static Vector zeros(int size)
size
- vector sizepublic static Vector parse(String s)
Vector.toString
into a Vector
.s
- (undocumented)public static Vector fromJson(String json)
Vector
.json
- (undocumented)public static double norm(Vector vector, double p)
vector
- input vector.p
- norm.public static double sqdist(Vector v1, Vector v2)
v1
- first Vector.v2
- second Vector.