Package org.apache.spark.mllib.linalg
Class Vectors
Object
org.apache.spark.mllib.linalg.Vectors
Factory methods for 
Vector.
 We don't use the name Vector because Scala imports
 scala.collection.immutable.Vector by default.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic Vectordense(double[] values) Creates a dense vector from a double array.static Vectordense(double firstValue, double... otherValues) Creates a dense vector from its values.static VectorCreates a dense vector from its values.static VectorParses the JSON representation of a vector into aVector.static VectorConvert new linalg type to spark.mllib type.static doubleReturns the p-norm of this vector.static VectorParses a string resulted fromVector.toStringinto aVector.static Vectorsparse(int size, int[] indices, double[] values) Creates a sparse vector providing its index array and value array.static VectorCreates a sparse vector using unordered (index, value) pairs in a Java friendly way.static VectorCreates a sparse vector using unordered (index, value) pairs.static doubleReturns the squared distance between two Vectors.static Vectorzeros(int size) Creates a vector of all zeros.
- 
Constructor Details- 
Vectorspublic Vectors()
 
- 
- 
Method Details- 
denseCreates a dense vector from its values.- Parameters:
- firstValue- (undocumented)
- otherValues- (undocumented)
- Returns:
- (undocumented)
 
- 
denseCreates a dense vector from its values.- Parameters:
- firstValue- (undocumented)
- otherValues- (undocumented)
- Returns:
- (undocumented)
 
- 
denseCreates a dense vector from a double array.- Parameters:
- values- (undocumented)
- Returns:
- (undocumented)
 
- 
sparseCreates 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)
 
- 
sparsepublic 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)
 
- 
sparseCreates 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)
 
- 
zerosCreates a vector of all zeros.- Parameters:
- size- vector size
- Returns:
- a zero vector
 
- 
parseParses a string resulted fromVector.toStringinto aVector.- Parameters:
- s- (undocumented)
- Returns:
- (undocumented)
 
- 
fromJsonParses the JSON representation of a vector into aVector.- Parameters:
- json- (undocumented)
- Returns:
- (undocumented)
 
- 
normReturns the p-norm of this vector.- Parameters:
- vector- input vector.
- p- norm.
- Returns:
- norm in L^p^ space.
 
- 
sqdistReturns the squared distance between two Vectors.- Parameters:
- v1- first Vector.
- v2- second Vector.
- Returns:
- squared distance between two Vectors.
 
- 
fromMLConvert new linalg type to spark.mllib type. Light copy; only copies references- Parameters:
- v- (undocumented)
- Returns:
- (undocumented)
 
 
-