public abstract class RandomVector extends Vec
Modifier | Constructor and Description |
---|---|
|
RandomVector(int length)
Creates a new Random Vector object
|
|
RandomVector(int length,
long seedMult)
Creates a new Random Vector object
|
protected |
RandomVector(RandomVector toCopy)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBeMutated()
Indicates whether or not this vector can be mutated.
|
abstract 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. |
double |
get(int index)
Gets the value stored at a specific index in the vector
|
protected abstract double |
getVal(Random rand)
Computes the value of an index given the already initialized
Random object. |
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
|
double |
max()
Returns the maximum value stored 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 |
set(int index,
double val)
Sets the value stored at a specified index in the vector
|
Vec |
sortedCopy()
Returns a copy of this array with the values moved around so that they are in sorted order
|
add, add, applyFunction, applyIndexFunction, arrayCopy, copyTo, copyToCol, copyToRow, countNaNs, divide, equals, equals, getNonZeroIterator, getNonZeroIterator, hashCode, increment, iterator, kurtosis, mean, median, multiply, multiply, multiply, mutableAdd, mutableSubtract, mutableSubtract, mutableSubtract, nnz, normalize, normalized, pairwiseDivide, pairwiseMultiply, pNorm, pNormDist, random, random, skewness, standardDeviation, subtract, subtract, sum, toString, variance, zeroOut, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public RandomVector(int length)
length
- the length of the vectorpublic RandomVector(int length, long seedMult)
length
- the length of the vectorseedMult
- a value to multiply with the seed used for each
individual index. It should be a large valueprotected RandomVector(RandomVector toCopy)
toCopy
- the object to copyprotected abstract double getVal(Random rand)
Random
object. This is called by the get(int)
method, and will make sure that the correct seed is set before calling
this method.rand
- the PRNG to generate the index value frompublic double get(int index)
Vec
public void set(int index, double val)
Vec
public int length()
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 boolean isSparse()
Vec
public double dot(Vec v)
Vec
public boolean canBeMutated()
Vec
false
, any method that contains "mutate" will not work.
true
canBeMutated
in class Vec
true
if the vector supports being altered, false
other wise.Copyright © 2017. All rights reserved.