public class ShiftedVec extends Vec
true
for
isSparse()
, even if shifting makes all values non-zero
Constructor and Description |
---|
ShiftedVec(Vec base,
double shift)
Creates a new vector represented as
base+shift |
Modifier and Type | Method and Description |
---|---|
ShiftedVec |
clone() |
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. |
void |
embedShift()
Embeds the current shift scalar into the base vector, modifying it and
then setting the new shit to zero.
|
double |
get(int index)
Gets the value stored at a specific index in the vector
|
Vec |
getBase() |
Iterator<IndexValue> |
getNonZeroIterator(int start)
Returns an iterator that will go over the non zero values starting from
the specified index in the given vector.
|
double |
getShift() |
void |
increment(int index,
double val)
Increments the value stored at a specified 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 |
mean()
Computes the mean value of all values stored in this vector
|
double |
median()
Returns the median value in this vector
|
double |
min()
Returns the minimum value stored in this vector
|
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 |
mutableAdd(Vec b)
Alters this vector such that
this = this + b
|
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. |
double |
pNorm(double p)
Returns the p-norm of this vector.
|
void |
set(int index,
double val)
Sets the value stored at a specified index in the vector
|
void |
setShift(double shift)
Directly alters the shift value used for this vector.
|
double |
standardDeviation()
Computes the standard deviation of the values in this vector
|
double |
variance()
Computes the variance of the values in this vector, which is
Vec.standardDeviation() 2 |
void |
zeroOut()
Zeroes out all values in this vector
This method should be overloaded for a serious implementation. |
add, add, applyFunction, applyIndexFunction, arrayCopy, canBeMutated, copyTo, copyToCol, copyToRow, countNaNs, divide, equals, equals, getNonZeroIterator, hashCode, iterator, multiply, multiply, multiply, multiply, mutableSubtract, mutableSubtract, mutableSubtract, nnz, normalize, normalized, pairwiseDivide, pairwiseMultiply, pNormDist, random, random, skewness, sortedCopy, subtract, subtract, sum, toString, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ShiftedVec(Vec base, double shift)
base+shift
base
- the base vector to representshift
- the scalar shift to add to the base vectorpublic Vec getBase()
public void setShift(double shift)
shift
- the new value to use for the additive scalarpublic double getShift()
base
valuepublic void embedShift()
public int length()
Vec
public double get(int index)
Vec
public void set(int index, double val)
Vec
public void increment(int index, double val)
Vec
public void mutableAdd(Vec b)
Vec
mutableAdd
in class Vec
b
- the vector to add to thispublic 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 mutableDivide(double c)
Vec
this /= c
mutableDivide
in class Vec
c
- the constant to divide bypublic void mutableMultiply(double c)
Vec
this *= c
mutableMultiply
in class Vec
c
- the constant to 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 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 double dot(Vec v)
Vec
public void zeroOut()
Vec
public double pNorm(double p)
Vec
public double mean()
Vec
public double variance()
Vec
Vec.standardDeviation()
2public double standardDeviation()
Vec
standardDeviation
in class Vec
public double kurtosis()
Vec
public double max()
Vec
public double min()
Vec
public double median()
Vec
public Iterator<IndexValue> getNonZeroIterator(int start)
Vec
Iterator.remove()
method.
getNonZeroIterator
in class Vec
start
- the first index (inclusive) to start returning non-zero
values frompublic boolean isSparse()
Vec
public ShiftedVec clone()
Copyright © 2017. All rights reserved.