public class DenseVector extends AbstractVector implements Serializable
Vector implementation backed by a double[].| Constructor and Description |
|---|
DenseVector(DenseVector other) |
DenseVector(double[] values) |
DenseVector(ImmutableVector other)
Instantiates a new DenseVector by copying the given other vector.
|
DenseVector(int size)
Creates a dense vector of the given size.
|
| Modifier and Type | Method and Description |
|---|---|
double |
dot(Vector that)
Computes the inner product with another Vector.
|
double |
get(int i)
Access the value of the Vector at dimension i.
|
double[] |
getValues()
Access the underlying storage.
|
Tuple<Integer,Double> |
min()
Computes the min of all entries in the Vector.
|
Vector |
newInstance()
Create a new instance of the current type.
|
double |
norm2()
Computes the L2 norm of this Vector.
|
double |
norm2Sqr()
Computes the square of the L2 norm of this Vector.
|
static DenseVector |
rand(int size)
Creates a random Vector of size 'size' where each element is individually.
|
static DenseVector |
rand(int size,
Random random)
Creates a random Vector of size 'size' where each element is individually.
|
void |
set(int i,
double v)
Set dimension i of the Vector to value v.
|
int |
size()
The size (dimensionality) of the Vector.
|
double |
sum()
Computes the computeSum of all entries in the Vector.
|
String |
toString() |
add, multAdd, normalize, scalepublic DenseVector(int size)
public DenseVector(double[] values)
public DenseVector(ImmutableVector other)
public DenseVector(DenseVector other)
public void set(int i, double v)
Vectorset in interface Vectorset in class AbstractVectori - the indexv - valuepublic double get(int i)
ImmutableVectorget in interface ImmutableVectori - indexpublic int size()
ImmutableVectorsize in interface ImmutableVectorpublic double[] getValues()
public static DenseVector rand(int size)
public static DenseVector rand(int size, Random random)
random - the random number generator to use.public Vector newInstance()
VectornewInstance in interface Vectorpublic double dot(Vector that)
ImmutableVectordot in interface ImmutableVectorpublic double sum()
ImmutableVectorsum in interface ImmutableVectorpublic double norm2()
ImmutableVectornorm2 in interface ImmutableVectorpublic double norm2Sqr()
ImmutableVectornorm2Sqr in interface ImmutableVectorpublic Tuple<Integer,Double> min()
ImmutableVectormin in interface ImmutableVectorCopyright © 2017 The Apache Software Foundation. All rights reserved.