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, scale
public DenseVector(int size)
public DenseVector(double[] values)
public DenseVector(ImmutableVector other)
public DenseVector(DenseVector other)
public void set(int i, double v)
Vector
set
in interface Vector
set
in class AbstractVector
i
- the indexv
- valuepublic double get(int i)
ImmutableVector
get
in interface ImmutableVector
i
- indexpublic int size()
ImmutableVector
size
in interface ImmutableVector
public 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()
Vector
newInstance
in interface Vector
public double dot(Vector that)
ImmutableVector
dot
in interface ImmutableVector
public double sum()
ImmutableVector
sum
in interface ImmutableVector
public double norm2()
ImmutableVector
norm2
in interface ImmutableVector
public double norm2Sqr()
ImmutableVector
norm2Sqr
in interface ImmutableVector
public Tuple<Integer,Double> min()
ImmutableVector
min
in interface ImmutableVector
Copyright © 2017 The Apache Software Foundation. All rights reserved.