public class VecWithNorm extends Vec
pNorm(double)
. The original vector
can be obtained by calling getBase()
. The exact values returned for
the norm may differ slightly due to numerical issues.Constructor and Description |
---|
VecWithNorm(Vec base)
Creates a wrapper around the base vector that will update the norm of the
vector
|
VecWithNorm(Vec base,
double norm)
Creates a wrapper around the base vector that will update the norm of the
vector
|
Modifier and Type | Method and Description |
---|---|
VecWithNorm |
clone() |
double |
get(int index)
Gets the value stored at a specific index in the vector
|
Vec |
getBase()
Return the base vector that is having its norm tracked
|
Iterator<IndexValue> |
getNonZeroIterator()
Returns an iterator that will go over the non zero values in the given
vector.
|
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.
|
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.
|
int |
length()
Returns the length of 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 |
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 |
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, dot, equals, equals, hashCode, increment, iterator, kurtosis, max, mean, median, min, multiply, multiply, multiply, multiply, mutableAdd, mutableSubtract, mutableSubtract, mutableSubtract, normalize, normalized, pairwiseDivide, pairwiseMultiply, pNormDist, random, random, skewness, sortedCopy, standardDeviation, subtract, subtract, sum, toString, variance, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public VecWithNorm(Vec base, double norm)
base
- the vector to use as the base valuenorm
- the initial value of the normpublic VecWithNorm(Vec base)
base
- the vector to use as the base valuepublic Vec getBase()
public double pNorm(double p)
Vec
public int length()
Vec
public double get(int index)
Vec
public void set(int index, double val)
Vec
public boolean isSparse()
Vec
public VecWithNorm clone()
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 void zeroOut()
Vec
public int nnz()
Vec
public Iterator<IndexValue> getNonZeroIterator()
Vec
Iterator.remove()
method.getNonZeroIterator
in class 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.