Package org.apache.spark.ml.linalg
Class Vectors
Object
org.apache.spark.ml.linalg.Vectors
Factory methods for
Vector
.
We don't use the name Vector
because Scala imports
scala.collection.immutable.Vector
by default.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
Creates a dense vector from its values.static double
Returns the p-norm of this vector.static Vector
sparse
(int size, int[] indices, double[] values) Creates a sparse vector providing its index array and value array.static Vector
Creates a sparse vector using unordered (index, value) pairs in a Java friendly way.static Vector
Creates a sparse vector using unordered (index, value) pairs.static double
Returns the squared distance between two Vectors.static Vector
zeros
(int size) Creates a vector of all zeros.
-
Constructor Details
-
Vectors
public Vectors()
-
-
Method Details
-
dense
Creates a dense vector from its values.- Parameters:
firstValue
- (undocumented)otherValues
- (undocumented)- Returns:
- (undocumented)
-
dense
Creates a dense vector from its values.- Parameters:
firstValue
- (undocumented)otherValues
- (undocumented)- Returns:
- (undocumented)
-
dense
Creates a dense vector from a double array.- Parameters:
values
- (undocumented)- Returns:
- (undocumented)
-
sparse
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.immutable.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
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
Creates a vector of all zeros.- Parameters:
size
- vector size- Returns:
- a zero vector
-
norm
Returns the p-norm of this vector.- Parameters:
vector
- input vector.p
- norm.- Returns:
- norm in L^p^ space.
-
sqdist
Returns the squared distance between two Vectors.- Parameters:
v1
- first Vector.v2
- second Vector.- Returns:
- squared distance between two Vectors.
-