public class Vectors
extends Object
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 boolean |
equals(scala.collection.IndexedSeq<Object> v1Indices,
double[] v1Values,
scala.collection.IndexedSeq<Object> v2Indices,
double[] v2Values)
Check equality between sparse/dense vectors
|
static Vector |
fromBreeze(breeze.linalg.Vector<Object> breezeVector)
Creates a vector instance from a breeze vector.
|
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
an Vector . |
static Vector |
parseNumeric(Object any) |
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 Vector |
zeros(int size)
Creates a dense vector of all zeros.
|
public static Vector dense(double firstValue, double... otherValues)
public static Vector dense(double firstValue, scala.collection.Seq<Object> otherValues)
public static Vector dense(double[] values)
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
an Vector
.public static Vector parseNumeric(Object any)
public static Vector fromBreeze(breeze.linalg.Vector<Object> breezeVector)
public static double norm(Vector vector, double p)
vector
- input vector.p
- norm.public static boolean equals(scala.collection.IndexedSeq<Object> v1Indices, double[] v1Values, scala.collection.IndexedSeq<Object> v2Indices, double[] v2Values)