public class DenseVector
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
data |
protected int |
size |
| Constructor and Description |
|---|
DenseVector(DenseVector vec)
Construct a dense vector by deeply copying data from a given vector
|
DenseVector(double[] array)
Construct a dense vector by deeply copying data from a given array
|
DenseVector(double[] array,
boolean deep)
Construct a dense vector by copying data from a given array
|
DenseVector(int size)
Construct a dense vector with a specific size
|
| Modifier and Type | Method and Description |
|---|---|
DenseVector |
add(DenseVector vec)
Do vector operation:
a + b |
DenseVector |
add(double val)
Return a new dense vector by adding a value to all entries of current vector
a[i] = b[i] + c |
void |
add(int idx,
double val)
Add a value to entry [index]
|
DenseVector |
addEqual(DenseVector vec)
Do vector operation:
a + b |
DenseVector |
addEqual(double val)
Return this dense vector by adding a value to all entries of current vector
b[i] = b[i] + c |
DenseVector |
clone()
Make a deep copy of current vector
|
double |
get(int idx)
Get a value at entry [index]
|
double[] |
getData() |
void |
init()
Initialize a dense vector with uniform values in (0, 1)
|
void |
init(double range)
Initialize a dense vector with uniform values in (0, range)
|
void |
init(double mean,
double sigma)
Initialize a dense vector with Gaussian values
|
double |
inner(DenseVector vec)
Do vector operation:
a^t * b |
double |
inner(SparseVector vec)
Do vector operation:
a^t * b |
static DenseVector |
kroneckerProduct(DenseVector M,
DenseVector N)
Return the Kronecker product of two vectors
|
double |
mean() |
DenseVector |
minus(DenseVector vec)
Do vector operation:
a - b |
DenseVector |
minus(double val)
Return a new dense vector by substructing a value from all entries of current vector
a[i] = b[i] - c |
void |
minus(int idx,
double val)
Substract a value from entry [index]
|
DenseVector |
minusEqual(DenseVector vec)
Do vector operation:
a - b |
DenseVector |
minusEqual(double val)
Return this dense vector by substructing a value from all entries of current vector
b[i] = b[i] - c |
DenseMatrix |
outer(DenseVector vec)
Do vector operation:
a * b^t |
DenseVector |
scale(double val)
Return a new dense vector by scaling a value to all entries of current vector
a = b.scale(c) |
DenseVector |
scaleEqual(double val)
Return this dense vector by scaling a value to all entries of current vector
b = b.scale(c). |
void |
set(int idx,
double val)
Set a value to entry [index]
|
void |
setAll(double val)
Set a value to all entries
|
void |
setData(double[] data) |
double |
sum() |
java.lang.String |
toString() |
public DenseVector(int size)
size - the size of vectorpublic DenseVector(double[] array)
array - a given arraypublic DenseVector(double[] array,
boolean deep)
array - a given data arraydeep - whether to deep copy array datapublic DenseVector(DenseVector vec)
vec - a given vectorpublic DenseVector clone()
clone in class java.lang.Objectpublic void init(double mean,
double sigma)
mean - mean of the gaussiansigma - sigma of the gaussianpublic void init()
public void init(double range)
range - max of the rangepublic double get(int idx)
idx - index of the datapublic double[] getData()
public double mean()
public double sum()
public void set(int idx,
double val)
idx - index to setval - value to setpublic void setAll(double val)
val - value to setpublic void add(int idx,
double val)
idx - index to addval - value to addpublic void minus(int idx,
double val)
idx - index to minusval - value to minuspublic DenseVector add(double val)
a[i] = b[i] + cval - value to adda[i] = b[i] + cpublic DenseVector addEqual(double val)
b[i] = b[i] + cval - value to addb[i] = b[i] + cpublic DenseVector add(DenseVector vec)
a + bvec - vector to addc = a + bpublic DenseVector addEqual(DenseVector vec)
a + bvec - vector to adda = a + bpublic DenseVector minus(double val)
a[i] = b[i] - cval - value to minusa[i] = b[i] - cpublic DenseVector minusEqual(double val)
b[i] = b[i] - cval - value tob[i] = b[i] - cpublic DenseVector minus(DenseVector vec)
a - bvec - a given vectorc = a - bpublic DenseVector minusEqual(DenseVector vec)
a - bvec - a given vectora = a - bpublic DenseVector scale(double val)
a = b.scale(c)val - a given value for scalinga = b.scale(c)public DenseVector scaleEqual(double val)
b = b.scale(c).val - a given value for scalingb = b.scale(c)public double inner(DenseVector vec)
a^t * bvec - a given vectorpublic double inner(SparseVector vec)
a^t * bvec - a given vectorpublic DenseMatrix outer(DenseVector vec)
a * b^tvec - a given vectorpublic static DenseVector kroneckerProduct(DenseVector M, DenseVector N)
M - a dense matrixN - another dense matrixpublic java.lang.String toString()
toString in class java.lang.Objectpublic void setData(double[] data)
data - the data to setCopyright © 2017. All Rights Reserved.