Package org.apache.spark.mllib.linalg
Class DenseVector
Object
org.apache.spark.mllib.linalg.DenseVector
- All Implemented Interfaces:
- Serializable,- Vector
A dense vector represented by a value array.
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiondoubleapply(int i) Gets the value of the ith element.intargmax()Find the index of a maximal element.asML()Convert this vector to the new mllib-local representation.copy()Makes a deep copy of this vector.booleanstatic DenseVectorConvert new linalg type to spark.mllib type.inthashCode()Returns a hash code value for the vector.intNumber of active entries.intNumber of nonzero elements.intsize()Size of the vector.double[]toArray()Converts the instance to a double array.toJson()Converts the vector to a JSON string.toString()static scala.Option<double[]>unapply(DenseVector dv) Extracts the value array from a dense vector.double[]values()Methods inherited from interface org.apache.spark.mllib.linalg.Vectorcompressed, dot, foreach, foreachActive, foreachNonZero, nonZeroIterator, sparsity, toDense, toSparse
- 
Constructor Details- 
DenseVectorpublic DenseVector(double[] values) 
 
- 
- 
Method Details- 
unapplyExtracts the value array from a dense vector.
- 
fromMLConvert new linalg type to spark.mllib type. Light copy; only copies references- Parameters:
- v- (undocumented)
- Returns:
- (undocumented)
 
- 
valuespublic double[] values()
- 
sizepublic int size()Description copied from interface:VectorSize of the vector.
- 
toString
- 
toArraypublic double[] toArray()Description copied from interface:VectorConverts the instance to a double array.
- 
applypublic double apply(int i) Description copied from interface:VectorGets the value of the ith element.
- 
copyDescription copied from interface:VectorMakes a deep copy of this vector.
- 
equals
- 
hashCodepublic int hashCode()Description copied from interface:VectorReturns a hash code value for the vector. The hash code is based on its size and its first 128 nonzero entries, using a hash algorithm similar tojava.util.Arrays.hashCode.
- 
numActivespublic int numActives()Description copied from interface:VectorNumber of active entries. An "active entry" is an element which is explicitly stored, regardless of its value.- Specified by:
- numActivesin interface- Vector
- Returns:
- (undocumented)
 
- 
numNonzerospublic int numNonzeros()Description copied from interface:VectorNumber of nonzero elements. This scans all active values and count nonzeros.- Specified by:
- numNonzerosin interface- Vector
- Returns:
- (undocumented)
 
- 
argmaxpublic int argmax()Description copied from interface:VectorFind the index of a maximal element. Returns the first maximal element in case of a tie. Returns -1 if vector has length 0.
- 
toJsonDescription copied from interface:VectorConverts the vector to a JSON string.
- 
asMLDescription copied from interface:VectorConvert this vector to the new mllib-local representation. This does NOT copy the data; it copies references.
 
-