jsat.linear
Class RandomVector
- java.lang.Object
-
- jsat.linear.Vec
-
- jsat.linear.RandomVector
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IndexValue>
public abstract class RandomVector extends Vec
Stores a Vector full of random values in constant O(1) space by re-computing all matrix values on the fly as need. This allows memory reduction and use when it is necessary to use the matrix with a large sparse data set, where some matrix values may never even be used - or used very infrequently.
Because the values of the random vector are computed on the fly, the Random Vector can not be altered. If attempted, an exception will be thrown.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description RandomVector(int length)Creates a new Random Vector objectRandomVector(int length, long seedMult)Creates a new Random Vector object
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description booleancanBeMutated()Indicates whether or not this vector can be mutated.abstract Vecclone()doubledot(Vec v)Computes the dot product between two vectors, which is equivalent to
Σ thisi*vi
This method should be overloaded for a serious implementation.doubleget(int index)Gets the value stored at a specific index in the vectorbooleanisSparse()Indicates whether or not this vector is optimized for sparce computation, meaning that most values in the vector are zero - and considered implicit.intlength()Returns the length of this vectordoublemax()Returns the maximum value stored in this vectordoublemin()Returns the minimum value stored in this vectorvoidmultiply(double c, Matrix A, Vec b)If this is vector a, this this computes b = b + c aT*AvoidmutableAdd(double c)Alters this vector such that this = this + c
This method should be overloaded for a serious implementation.voidmutableAdd(double c, Vec b)Alters this vector such that this = this + c * b
This method should be overloaded for a serious implementation.voidmutableDivide(double c)Mutatesthis /= c
This method should be overloaded for a serious implementation.voidmutableMultiply(double c)Mutatesthis *= c
This method should be overloaded for a serious implementation.voidmutablePairwiseDivide(Vec b)Mutatesthisby dividing each value by the value inbthat has the same index
This method should be overloaded for a serious implementation.voidmutablePairwiseMultiply(Vec b)Mutatesthisby multiplying each value by the value inbthat has the same index.voidset(int index, double val)Sets the value stored at a specified index in the vectorVecsortedCopy()Returns a copy of this array with the values moved around so that they are in sorted order-
Methods inherited from class jsat.linear.Vec
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
-
-
-
-
Constructor Detail
-
RandomVector
public RandomVector(int length)
Creates a new Random Vector object- Parameters:
length- the length of the vector
-
RandomVector
public RandomVector(int length, long seedMult)Creates a new Random Vector object- Parameters:
length- the length of the vectorseedMult- a value to multiply with the seed used for each individual index. It should be a large value
-
-
Method Detail
-
get
public double get(int index)
Description copied from class:VecGets the value stored at a specific index in the vector
-
set
public void set(int index, double val)Description copied from class:VecSets the value stored at a specified index in the vector
-
length
public int length()
Description copied from class:VecReturns the length of this vector
-
multiply
public void multiply(double c, Matrix A, Vec b)Description copied from class:VecIf this is vector a, this this computes b = b + c aT*A
-
mutableAdd
public void mutableAdd(double c)
Description copied from class:VecAlters this vector such that this = this + c
This method should be overloaded for a serious implementation.- Overrides:
mutableAddin classVec- Parameters:
c- a scalar constant to add to each value in this vector
-
mutableAdd
public void mutableAdd(double c, Vec b)Description copied from class:VecAlters this vector such that this = this + c * b
This method should be overloaded for a serious implementation.- Overrides:
mutableAddin classVec- Parameters:
c- a scalar constantb- the vector to add to this
-
mutablePairwiseMultiply
public void mutablePairwiseMultiply(Vec b)
Description copied from class:VecMutatesthisby multiplying each value by the value inbthat has the same index.
This method should be overloaded for a serious implementation.- Overrides:
mutablePairwiseMultiplyin classVec- Parameters:
b- the vector to pairwise multiply by
-
mutableMultiply
public void mutableMultiply(double c)
Description copied from class:VecMutatesthis *= c
This method should be overloaded for a serious implementation.- Overrides:
mutableMultiplyin classVec- Parameters:
c- the constant to multiply by
-
mutablePairwiseDivide
public void mutablePairwiseDivide(Vec b)
Description copied from class:VecMutatesthisby dividing each value by the value inbthat has the same index
This method should be overloaded for a serious implementation.- Overrides:
mutablePairwiseDividein classVec- Parameters:
b- the vector to pairwise divide by
-
mutableDivide
public void mutableDivide(double c)
Description copied from class:VecMutatesthis /= c
This method should be overloaded for a serious implementation.- Overrides:
mutableDividein classVec- Parameters:
c- the constant to divide by
-
sortedCopy
public Vec sortedCopy()
Description copied from class:VecReturns a copy of this array with the values moved around so that they are in sorted order- Overrides:
sortedCopyin classVec- Returns:
- a new array in sorted order
-
min
public double min()
Description copied from class:VecReturns the minimum value stored in this vector
-
max
public double max()
Description copied from class:VecReturns the maximum value stored in this vector
-
isSparse
public boolean isSparse()
Description copied from class:VecIndicates whether or not this vector is optimized for sparce computation, meaning that most values in the vector are zero - and considered implicit. Only non-zero values are stored.
-
dot
public double dot(Vec v)
Description copied from class:VecComputes the dot product between two vectors, which is equivalent to
Σ thisi*vi
This method should be overloaded for a serious implementation.
-
canBeMutated
public boolean canBeMutated()
Description copied from class:VecIndicates whether or not this vector can be mutated. Iffalse, any method that contains "mutate" will not work.
By default, this returnstrue- Overrides:
canBeMutatedin classVec- Returns:
trueif the vector supports being altered,falseother wise.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG