public class DenseVector extends Object implements Vector
Constructor and Description |
---|
DenseVector(double[] values) |
Modifier and Type | Method and Description |
---|---|
double |
apply(int i)
Gets the value of the ith element.
|
int |
argmax()
Find the index of a maximal element.
|
DenseVector |
asML()
Convert this vector to the new mllib-local representation.
|
static Vector |
compressed() |
DenseVector |
copy()
Makes a deep copy of this vector.
|
boolean |
equals(Object other) |
void |
foreachActive(scala.Function2<Object,Object,scala.runtime.BoxedUnit> f)
Applies a function
f to all the active elements of dense and sparse vector. |
static DenseVector |
fromML(DenseVector v)
Convert new linalg type to spark.mllib type.
|
int |
hashCode()
Returns a hash code value for the vector.
|
int |
numActives()
Number of active entries.
|
int |
numNonzeros()
Number of nonzero elements.
|
int |
size()
Size of the vector.
|
double[] |
toArray()
Converts the instance to a double array.
|
static DenseVector |
toDense() |
String |
toJson()
Converts the vector to a JSON string.
|
SparseVector |
toSparse()
Converts this vector to a sparse vector with all explicit zeros removed.
|
String |
toString() |
static scala.Option<double[]> |
unapply(DenseVector dv)
Extracts the value array from a dense vector.
|
double[] |
values() |
compressed, toDense
public static scala.Option<double[]> unapply(DenseVector dv)
public static DenseVector fromML(DenseVector v)
v
- (undocumented)public static DenseVector toDense()
public static Vector compressed()
public double[] values()
public int size()
Vector
public String toString()
toString
in class Object
public double[] toArray()
Vector
public double apply(int i)
Vector
public DenseVector copy()
Vector
public void foreachActive(scala.Function2<Object,Object,scala.runtime.BoxedUnit> f)
Vector
f
to all the active elements of dense and sparse vector.
foreachActive
in interface Vector
f
- the function takes two parameters where the first parameter is the index of
the vector with type Int
, and the second parameter is the corresponding value
with type Double
.public boolean equals(Object other)
public int hashCode()
Vector
java.util.Arrays.hashCode
.public int numActives()
Vector
numActives
in interface Vector
public int numNonzeros()
Vector
numNonzeros
in interface Vector
public SparseVector toSparse()
Vector
public int argmax()
Vector
public String toJson()
Vector
public DenseVector asML()
Vector