public class DenseVector extends Vector
Constructor and Description |
---|
DenseVector()
Create a zero size vector.
|
DenseVector(double[] data)
Create a dense vector with the user provided data.
|
DenseVector(int n)
Create a size n vector with all elements zero.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int i,
double d)
Add the i-th element of the vector by value "val".
|
DenseVector |
append(double d)
Create a new vector by adding an element to the end of the vector.
|
DenseVector |
clone() |
double |
dot(Vector vec)
Compute the dot product with another vector.
|
boolean |
equals(Object o) |
double |
get(int i)
Get the i-th element of the vector.
|
double[] |
getData()
Get the data array.
|
int |
hashCode() |
VectorIterator |
iterator()
Get the iterator of the vector.
|
DenseVector |
minus(Vector other)
Create a new vector by subtracting another vector.
|
void |
minusEqual(Vector other)
Minus with another vector.
|
void |
normalizeEqual(double p)
Normalize the vector.
|
double |
normInf()
Return the Inf norm of the vector.
|
double |
normL1()
Return the L1 norm of the vector.
|
double |
normL2()
Return the L2 norm of the vector.
|
double |
normL2Square()
Return the square of L2 norm of the vector.
|
static DenseVector |
ones(int n)
Create a dense vector with all elements one.
|
DenseMatrix |
outer()
Compute the outer product with itself.
|
DenseMatrix |
outer(DenseVector other)
Compute the outer product with another vector.
|
DenseVector |
plus(Vector other)
Create a new vector by plussing another vector.
|
void |
plusEqual(Vector other)
Plus with another vector.
|
void |
plusScaleEqual(Vector other,
double alpha)
Plus with another vector scaled by "alpha".
|
DenseVector |
prefix(double d)
Create a new vector by adding an element to the head of the vector.
|
static DenseVector |
rand(int n)
Create a dense vector with random values uniformly distributed in the range of [0.0, 1.0].
|
DenseVector |
scale(double d)
Scale the vector by value "v" and create a new vector to store the result.
|
void |
scaleEqual(double d)
Scale the vector by value "v".
|
void |
set(int i,
double d)
Set the i-th element of the vector to value "val".
|
void |
setData(double[] data)
Set the data array.
|
void |
setEqual(DenseVector other)
Set the data of the vector the same as those of another vector.
|
int |
size()
Get the size of the vector.
|
DenseVector |
slice(int[] indices)
Slice the vector.
|
void |
standardizeEqual(double mean,
double stdvar)
Standardize the vector.
|
String |
toString() |
static DenseVector |
zeros(int n)
Create a dense vector with all elements zero.
|
public DenseVector()
public DenseVector(int n)
n
- Size of the vector.public DenseVector(double[] data)
data
- The vector data.public double[] getData()
public void setData(double[] data)
public static DenseVector ones(int n)
n
- Size of the vector.public static DenseVector zeros(int n)
n
- Size of the vector.public static DenseVector rand(int n)
n
- Size of the vector.public DenseVector clone()
public int size()
Vector
public double get(int i)
Vector
public void set(int i, double d)
Vector
public void add(int i, double d)
Vector
public double normL1()
Vector
public double normL2()
Vector
public double normL2Square()
Vector
normL2Square
in class Vector
public double normInf()
Vector
public DenseVector slice(int[] indices)
Vector
public DenseVector prefix(double d)
Vector
public DenseVector append(double d)
Vector
public void scaleEqual(double d)
Vector
scaleEqual
in class Vector
public DenseVector plus(Vector other)
Vector
public DenseVector minus(Vector other)
Vector
public DenseVector scale(double d)
Vector
public double dot(Vector vec)
Vector
public void standardizeEqual(double mean, double stdvar)
Vector
standardizeEqual
in class Vector
public void normalizeEqual(double p)
Vector
normalizeEqual
in class Vector
public void setEqual(DenseVector other)
public void plusEqual(Vector other)
public void minusEqual(Vector other)
public void plusScaleEqual(Vector other, double alpha)
public DenseMatrix outer()
Vector
public DenseMatrix outer(DenseVector other)
public VectorIterator iterator()
Vector
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.