jsat.linear
Class Poly2Vec
- java.lang.Object
-
- jsat.linear.Vec
-
- jsat.linear.Poly2Vec
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<IndexValue>
public class Poly2Vec extends Vec
This class is used to create an implicit representation of the degree 2 polynomial of an input vector, with an implicit bias term added so that the original vector values are present in the implicit vector. This means no extra memory will be allocated, and all values accessed will be re-computed as needed. This works with sparse vectors, and work bet with algorithms that iterate over the nonzero values once.
Any change in the base vector will change the values in this vector. Because changing one value in the base effects multiple values in this one, altering this vector directly is not allowed.
If the base vector hasNnon zero values, then this vec will have O(N2) non zero values. (N+2)(N+1)/2 non zero values to be exact.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Vecclone()doubleget(int index)Gets the value stored at a specific index in the vectorjava.util.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.booleanisSparse()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 vectorintnnz()Computes the number of non zero values in this vectorvoidset(int index, double val)Sets the value stored at a specified index in the vectorvoidsetBase(Vec base)Creates a new vector that implicitly represents the degree 2 polynomial of the base vector.-
Methods inherited from class jsat.linear.Vec
add, add, applyFunction, applyIndexFunction, arrayCopy, canBeMutated, copyTo, copyToCol, copyToRow, countNaNs, divide, dot, equals, equals, getNonZeroIterator, hashCode, increment, iterator, kurtosis, max, mean, median, min, multiply, multiply, multiply, multiply, mutableAdd, mutableAdd, mutableAdd, mutableDivide, mutableMultiply, mutablePairwiseDivide, mutablePairwiseMultiply, mutableSubtract, mutableSubtract, mutableSubtract, normalize, normalized, pairwiseDivide, pairwiseMultiply, pNorm, pNormDist, random, random, skewness, sortedCopy, standardDeviation, subtract, subtract, sum, toString, variance, zeroOut, zeros
-
-
-
-
Constructor Detail
-
Poly2Vec
public Poly2Vec(Vec base)
-
-
Method Detail
-
setBase
public void setBase(Vec base)
Creates a new vector that implicitly represents the degree 2 polynomial of the base vector.- Parameters:
base- the base vector
-
length
public int length()
Description copied from class:VecReturns the length of this vector
-
nnz
public int nnz()
Description copied from class:VecComputes the number of non zero values in this vector
-
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
-
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.
-
getNonZeroIterator
public java.util.Iterator<IndexValue> getNonZeroIterator(int start)
Description copied from class:VecReturns an iterator that will go over the non zero values starting from the specified index in the given vector. The iterator does not support theIterator.remove()method.
This method should be overloaded for a serious implementation.- Overrides:
getNonZeroIteratorin classVec- Parameters:
start- the first index (inclusive) to start returning non-zero values from- Returns:
- an iterator for the non zero index value pairs
-
-
DataMelt 3.0 © DataMelt by jWork.ORG