
public class SparseByteVector extends AbstractNumberVector<Byte> implements SparseNumberVector<Byte>
A SparseByteVector is to store real values as double values.
A SparseByteVector only requires storage for those attribute values that are non-zero.| Modifier and Type | Class and Description | 
|---|---|
| static class  | SparseByteVector.FactoryFactory class. | 
| static class  | SparseByteVector.VariableSerializerSerialization class using VarInt encodings. | 
| Modifier and Type | Field and Description | 
|---|---|
| private int | dimensionalityThe dimensionality of this feature vector. | 
| static SparseByteVector.Factory | FACTORYStatic instance. | 
| private int[] | indexesIndexes of values. | 
| private byte[] | valuesStored values. | 
| static ByteBufferSerializer<SparseByteVector> | VARIABLE_SERIALIZERSerializer using varint encoding. | 
ATTRIBUTE_SEPARATOR| Constructor and Description | 
|---|
| SparseByteVector(byte[] values)Provides a SparseByteVector consisting of double values according to the
 specified mapping of indices and values. | 
| SparseByteVector(int[] indexes,
                byte[] values,
                int dimensionality)Direct constructor. | 
| SparseByteVector(gnu.trove.map.TIntDoubleMap values,
                int dimensionality)Provides a SparseByteVector consisting of double values according to the
 specified mapping of indices and values. | 
| Modifier and Type | Method and Description | 
|---|---|
| byte | byteValue(int dimension)Returns the value in the specified dimension as byte. | 
| double | doubleValue(int dimension)Deprecated.  | 
| Vector | getColumnVector()Returns a Vector representing in one column and
  getDimensionality()rows the values of this NumberVector of V. | 
| int | getDimensionality()The dimensionality of the vector space where of this FeatureVector of V is
 an element. | 
| private int | getMaxDim()Get the maximum dimensionality. | 
| Byte | getValue(int dimension)Deprecated.  | 
| private double[] | getValues()Returns an array consisting of the values of this feature vector. | 
| int | iter()Iterator over non-zero features only, ascendingly. | 
| int | iterAdvance(int iter)Advance the iterator to the next position. | 
| byte | iterByteValue(int iter)Get the value of the iterators' current dimension. | 
| int | iterDim(int iter)Get the dimension an iterator points to. | 
| double | iterDoubleValue(int iter)Get the value of the iterators' current dimension. | 
| float | iterFloatValue(int iter)Get the value of the iterators' current dimension. | 
| int | iterIntValue(int iter)Get the value of the iterators' current dimension. | 
| long | iterLongValue(int iter)Get the value of the iterators' current dimension. | 
| short | iterShortValue(int iter)Get the value of the iterators' current dimension. | 
| boolean | iterValid(int iter)Test the iterator position for validity. | 
| long | longValue(int dimension)Deprecated.  | 
| void | setDimensionality(int dimensionality)Sets the dimensionality to the new value. | 
| String | toString()
 Provides a String representation of this SparseByteVector as suitable
 for
  SparseNumberVectorLabelParser. | 
floatValue, getMax, getMin, intValue, shortValueclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfloatValue, intValue, shortValuegetMax, getMinpublic static final SparseByteVector.Factory FACTORY
public static final ByteBufferSerializer<SparseByteVector> VARIABLE_SERIALIZER
private final int[] indexes
private final byte[] values
private int dimensionality
public SparseByteVector(int[] indexes,
                byte[] values,
                int dimensionality)
indexes - Indexes Must be sorted!values - Associated value.dimensionality - "true" dimensionalitypublic SparseByteVector(gnu.trove.map.TIntDoubleMap values,
                int dimensionality)
                 throws IllegalArgumentException
values - the values to be set as values of the real vectordimensionality - the dimensionality of this feature vectorIllegalArgumentException - if the given dimensionality is too small
         to cover the given values (i.e., the maximum index of any value not
         zero is bigger than the given dimensionality)public SparseByteVector(byte[] values)
                 throws IllegalArgumentException
values - the values to be set as values of the real vectorIllegalArgumentException - if the given dimensionality is too small
         to cover the given values (i.e., the maximum index of any value not
         zero is bigger than the given dimensionality)private int getMaxDim()
public int getDimensionality()
FeatureVectorgetDimensionality in interface FeatureVector<Byte>getDimensionality in interface SpatialComparablepublic void setDimensionality(int dimensionality)
                       throws IllegalArgumentException
setDimensionality in interface SparseNumberVector<Byte>dimensionality - the new dimensionalityIllegalArgumentException - if the given dimensionality is too small
         to cover the given values (i.e., the maximum index of any value not
         zero is bigger than the given dimensionality)@Deprecated public Byte getValue(int dimension)
FeatureVectorgetValue in interface FeatureVector<Byte>getValue in interface NumberVector<Byte>dimension - the desired dimension, where 0 ≤ dimension ≤
        this.getDimensionality()-1@Deprecated public double doubleValue(int dimension)
NumberVectorgetValue(dim).doubleValue(), but usually this is much more
 efficient due to boxing/unboxing cost.doubleValue in interface NumberVector<Byte>doubleValue in interface SparseNumberVector<Byte>dimension - the desired dimension, where 0 ≤ dimension <
        this.getDimensionality()@Deprecated public long longValue(int dimension)
NumberVectorgetValue(dim).longValue(), but usually this is much more efficient
 due to boxing/unboxing cost.longValue in interface NumberVector<Byte>longValue in interface SparseNumberVector<Byte>dimension - the desired dimension, where 0 ≤ dimension <
        this.getDimensionality()public byte byteValue(int dimension)
NumberVectorgetValue(dim).byteValue(), but usually this is much more efficient
 due to boxing/unboxing cost.byteValue in interface NumberVector<Byte>byteValue in interface SparseNumberVector<Byte>byteValue in class AbstractNumberVector<Byte>dimension - the desired dimension, where 0 ≤ dimension <
        this.getDimensionality()public Vector getColumnVector()
NumberVectorgetDimensionality() rows the values of this NumberVector of V.getColumnVector in interface NumberVector<Byte>getDimensionality() rows the values of this
         NumberVector of Vpublic String toString()
 Provides a String representation of this SparseByteVector as suitable
 for
 SparseNumberVectorLabelParser
 .
 
 The returned String is a single line with entries separated by
 AbstractNumberVector.ATTRIBUTE_SEPARATOR. The first entry gives the
 number of values actually not zero. Following entries are pairs of Byte
 and Byte where the Byte gives the index of the dimensionality and the
 Byte gives the corresponding value.
 
 Example: a vector (0,1.2,1.3,0)T would result in the String
 2 2 1.2 3 1.3
 
toString in interface FeatureVector<Byte>toString in class Objectprivate double[] getValues()
public int iter()
SparseNumberVectorSparseFeatureVector.iterDim(int) to get the actual dimension. In fact,
 usually this will be the ith non-zero value, assuming an array
 representation.
 
 Think of this number as an iterator. For efficiency, it has a primitive
 type!
 
 Intended usage:
 
 
 for (int iter = v.iter(); v.iterValid(iter); iter = v.iterAdvance(iter)) {
   final int dim = v.iterDim(iter);
   final double val = v.iterDoubleValue(iter);
   // Do something.
 }
 
 iter in interface SparseFeatureVector<Byte>iter in interface SparseNumberVector<Byte>public int iterDim(int iter)
SparseFeatureVectoriterDim in interface SparseFeatureVector<Byte>iter - Iterator positionpublic int iterAdvance(int iter)
SparseFeatureVectoriterAdvance in interface SparseFeatureVector<Byte>iter - Previous iterator positionpublic boolean iterValid(int iter)
SparseFeatureVectoriterValid in interface SparseFeatureVector<Byte>iter - Iterator positiontrue when it refers to a valid position.public double iterDoubleValue(int iter)
SparseNumberVectoriterDoubleValue in interface SparseNumberVector<Byte>iter - Iteratorpublic float iterFloatValue(int iter)
SparseNumberVectoriterFloatValue in interface SparseNumberVector<Byte>iter - Iteratorpublic int iterIntValue(int iter)
SparseNumberVectoriterIntValue in interface SparseNumberVector<Byte>iter - Iteratorpublic short iterShortValue(int iter)
SparseNumberVectoriterShortValue in interface SparseNumberVector<Byte>iter - Iteratorpublic long iterLongValue(int iter)
SparseNumberVectoriterLongValue in interface SparseNumberVector<Byte>iter - Iteratorpublic byte iterByteValue(int iter)
SparseNumberVectoriterByteValue in interface SparseNumberVector<Byte>iter - Iterator