public class ScaledVector extends Vec
embedScale()
and then calling getBase()
.
zeroed out
and the constant reset to 1.Constructor and Description |
---|
ScaledVector(double scale,
Vec base)
Creates a new scaled vector
|
ScaledVector(Vec vec)
Creates a new scaled vector with a default scale of 1.
|
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() |
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 |
embedScale()
Embeds the current scale factor into the base vector, so that the current
scale factor can be set to 1.
|
double |
get(int index)
Gets the value stored at a specific index in the vector
|
Vec |
getBase()
Returns the base vector that is being scaled
|
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 |
getScale()
Returns the current scale in use
|
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 |
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. |
int |
nnz()
Computes the number of non zero values in this vector
|
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 |
setScale(double scale)
Explicitly sets the current scale to the given value
NOTE: If the scale is set to zero, the underlying base vector will be zeroed out, and the scale set to 1. |
double |
skewness()
Computes the skewness of this vector, which is the 3rd moment.
|
Vec |
sortedCopy()
Returns a copy of this array with the values moved around so that they are in sorted order
|
double |
standardDeviation()
Computes the standard deviation of the values in this vector
|
double |
sum()
Computes the sum of the values in this vector
|
void |
zeroOut()
Zeroes out all values in this vector
This method should be overloaded for a serious implementation. |
add, add, applyFunction, applyIndexFunction, canBeMutated, copyTo, copyToCol, copyToRow, countNaNs, divide, equals, equals, getNonZeroIterator, hashCode, increment, iterator, multiply, multiply, multiply, mutableAdd, mutableSubtract, mutableSubtract, mutableSubtract, normalize, normalized, pairwiseDivide, pairwiseMultiply, pNormDist, random, random, subtract, subtract, toString, variance, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ScaledVector(double scale, Vec base)
scale
- the initial scaling constantbase
- the vector to implicitly scalepublic ScaledVector(Vec vec)
vec
- the vector to implicitly scalepublic double getScale()
public void setScale(double scale)
scale
- the new multiplicative constant to set for the scalepublic Vec getBase()
public void embedScale()
public int length()
Vec
public double get(int index)
Vec
public void set(int index, double val)
Vec
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 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 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 mutableDivide(double c)
Vec
this /= c
mutableDivide
in class Vec
c
- the constant to divide bypublic Vec sortedCopy()
Vec
sortedCopy
in class Vec
public double min()
Vec
public double max()
Vec
public double sum()
Vec
public double mean()
Vec
public double standardDeviation()
Vec
standardDeviation
in class Vec
public double median()
Vec
public double skewness()
Vec
public double kurtosis()
Vec
public boolean isSparse()
Vec
public double pNorm(double p)
Vec
public double dot(Vec v)
Vec
public double[] arrayCopy()
Vec
public void zeroOut()
Vec
public int nnz()
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 fromCopyright © 2017. All rights reserved.