public class DenseVector extends Vec
Modifier and Type | Field and Description |
---|---|
protected double[] |
array |
Constructor and Description |
---|
DenseVector(double[] array)
Creates a new Dense Vector that uses the given array as its values.
|
DenseVector(double[] array,
int start,
int end)
Creates a new Dense Vector that uses the given array as its values.
|
DenseVector(int length)
Creates a new Dense Vector of zeros
|
DenseVector(List<Double> list)
Creates a new vector of the length of the given list, and values copied
over in order.
|
DenseVector(Vec toCopy)
Creates a new Dense Vector that contains a copy of the values in the
given vector
|
Modifier and Type | Method and Description |
---|---|
double[] |
arrayCopy()
Creates a new array that contains all the values of this vector in the
appropriate indices
|
Vec |
clone() |
DenseVector |
deepCopy() |
double |
dot(Vec v)
Computes the dot product between two vectors, which is equivalent to
Σ thisi*vi This method should be overloaded for a serious implementation. |
boolean |
equals(Object obj) |
boolean |
equals(Object obj,
double range) |
double |
get(int index)
Gets the value stored at a specific index in the vector
|
boolean |
isSparse()
Indicates whether or not this vector is optimized for sparce computation,
meaning that most values in the vector are zero - and considered
implicit.
|
double |
kurtosis()
Computes the kurtosis of this vector, which is the 4th moment.
|
int |
length()
Returns the length of this vector
|
double |
max()
Returns the maximum value stored in this vector
|
double |
median()
Returns the median value in this vector
|
double |
min()
Returns the minimum value stored in this vector
|
void |
multiply(double c,
Matrix A,
Vec b)
If this is vector a, this this computes b = b + c aT*A
|
void |
mutableAdd(double c)
Alters this vector such that
this = this + c
This method should be overloaded for a serious implementation. |
void |
mutableAdd(double c,
Vec b)
Alters this vector such that
this = this + c * b
This method should be overloaded for a serious implementation. |
void |
mutableDivide(double c)
Mutates
this /= c
This method should be overloaded for a serious implementation. |
void |
mutableMultiply(double c)
Mutates
this *= c
This method should be overloaded for a serious implementation. |
void |
mutablePairwiseDivide(Vec b)
Mutates
this by dividing each value by the value in b
that has the same index
This method should be overloaded for a serious implementation. |
void |
mutablePairwiseMultiply(Vec b)
Mutates
this by multiplying each value by the value in b
that has the same index. |
void |
mutableSubtract(double c)
Alters this vector such that
this = this - c
|
void |
normalize()
Mutates this vector to be normalized by the L2 norm
|
double |
pNorm(double p)
Returns the p-norm of this vector.
|
double |
pNormDist(double p,
Vec y)
Returns the p-norm distance between this and another vector y.
|
void |
set(int index,
double val)
Sets the value stored at a specified index in the vector
|
double |
skewness()
Computes the skewness of this vector, which is the 3rd moment.
|
DenseVector |
sortedCopy()
Returns a copy of this array with the values moved around so that they are in sorted order
|
double |
sum()
Computes the sum of the values in this vector
|
static DenseVector |
toDenseVec(double... array)
Returns a new dense vector backed by the given array.
|
double |
variance()
Computes the variance of the values in this vector, which is
Vec.standardDeviation() 2 |
add, add, applyFunction, applyIndexFunction, canBeMutated, copyTo, copyToCol, copyToRow, countNaNs, divide, getNonZeroIterator, getNonZeroIterator, hashCode, increment, iterator, mean, multiply, multiply, multiply, mutableAdd, mutableSubtract, mutableSubtract, nnz, normalized, pairwiseDivide, pairwiseMultiply, random, random, standardDeviation, subtract, subtract, toString, zeroOut, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public DenseVector(int length)
length
- the length of the vectorpublic DenseVector(List<Double> list)
list
- the list of values to copy into a new vectorpublic DenseVector(double[] array)
array
- the backing array to use for a new vector of the same lengthpublic DenseVector(double[] array, int start, int end)
array
- the backing array to use for a new vectorstart
- the first index in the array, inclusive, to mark the start
of the vector.end
- the last index in the array, exclusive, to mark the end of the
vector.public DenseVector(Vec toCopy)
toCopy
- the vector to copypublic int length()
Vec
public double get(int index)
Vec
public void set(int index, double val)
Vec
public double min()
Vec
public double max()
Vec
public double sum()
Vec
public double median()
Vec
public double skewness()
Vec
public double kurtosis()
Vec
public DenseVector sortedCopy()
Vec
sortedCopy
in class Vec
public double variance()
Vec
Vec.standardDeviation()
2public double dot(Vec v)
Vec
public DenseVector deepCopy()
public void multiply(double c, Matrix A, Vec b)
Vec
public void mutableAdd(double c)
Vec
mutableAdd
in class Vec
c
- a scalar constant to add to each value in this vectorpublic void mutableAdd(double c, Vec b)
Vec
mutableAdd
in class Vec
c
- a scalar constantb
- the vector to add to thispublic void mutableSubtract(double c)
Vec
mutableSubtract
in class Vec
c
- the scalar constant to subtract from all values in this vectorpublic void mutableMultiply(double c)
Vec
this *= c
mutableMultiply
in class Vec
c
- the constant to multiply bypublic void mutableDivide(double c)
Vec
this /= c
mutableDivide
in class Vec
c
- the constant to divide bypublic double pNormDist(double p, Vec y)
Vec
public double pNorm(double p)
Vec
public void normalize()
Vec
public void mutablePairwiseMultiply(Vec b)
Vec
this
by multiplying each value by the value in b
that has the same index.
mutablePairwiseMultiply
in class Vec
b
- the vector to pairwise multiply bypublic void mutablePairwiseDivide(Vec b)
Vec
this
by dividing each value by the value in b
that has the same index
mutablePairwiseDivide
in class Vec
b
- the vector to pairwise divide bypublic static DenseVector toDenseVec(double... array)
array
- the array to use as the backing of a dense vectorpublic double[] arrayCopy()
Vec
public boolean isSparse()
Vec
Copyright © 2017. All rights reserved.