public class SparseShortVector extends java.lang.Object implements SparseNumberVector
short[] for storing the values, and
int[] for storing the indexes, approximately 6 bytes per non-zero
value.| Modifier and Type | Class and Description |
|---|---|
static class |
SparseShortVector.Factory
Factory class.
|
static class |
SparseShortVector.VariableSerializer
Serialization class using VarInt encodings.
|
| Modifier and Type | Field and Description |
|---|---|
private int |
dimensionality
The dimensionality of this feature vector.
|
static SparseShortVector.Factory |
FACTORY
Static instance.
|
private int[] |
indexes
Indexes of values.
|
private static short |
SHORT0
Constant value, for use in (inefficient)
getValue(int) API. |
private short[] |
values
Stored values.
|
static ByteBufferSerializer<SparseShortVector> |
VARIABLE_SERIALIZER
Serializer using varint encoding.
|
FIELD, VARIABLE_LENGTHATTRIBUTE_SEPARATOR, FIELD_1D, FIELD_2DTYPE| Constructor and Description |
|---|
SparseShortVector(int[] indexes,
short[] values,
int dimensionality)
Direct constructor.
|
SparseShortVector(it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap values,
int dimensionality)
Create a SparseShortVector consisting of double values according to the
specified mapping of indices and values.
|
SparseShortVector(short[] values)
Create a SparseShortVector consisting of double values according to the
specified mapping of indices and values.
|
| Modifier and Type | Method and Description |
|---|---|
double |
doubleValue(int dimension)
Deprecated.
|
int |
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is
an element.
|
private int |
getMaxDim()
Get the maximum dimensionality.
|
java.lang.Short |
getValue(int dimension)
Deprecated.
|
int |
iterDim(int iter)
Get the dimension an iterator points to.
|
double |
iterDoubleValue(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.
|
short |
shortValue(int dimension)
Deprecated.
|
double[] |
toArray()
Returns a double array copy of this vector.
|
java.lang.String |
toString()
Create a String representation of this SparseShortVector as suitable for
SparseNumberVectorLabelParser
. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbyteValue, floatValue, intValue, iter, iterByteValue, iterFloatValue, iterIntValuegetMax, getMiniterAdvance, iterRetractpublic static final SparseShortVector.Factory FACTORY
public static final ByteBufferSerializer<SparseShortVector> VARIABLE_SERIALIZER
private static final short SHORT0
getValue(int) API.private final int[] indexes
private final short[] values
private int dimensionality
public SparseShortVector(int[] indexes,
short[] values,
int dimensionality)
indexes - Indexes Must be sorted!values - Associated value.dimensionality - "true" dimensionalitypublic SparseShortVector(it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap values,
int dimensionality)
throws java.lang.IllegalArgumentException
values - the values to be set as values of the real vectordimensionality - the dimensionality of this feature vectorjava.lang.IllegalArgumentException - 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 SparseShortVector(short[] values)
throws java.lang.IllegalArgumentException
values - the values to be set as values of the real vectorjava.lang.IllegalArgumentException - 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<java.lang.Number>getDimensionality in interface SpatialComparablepublic void setDimensionality(int dimensionality)
throws java.lang.IllegalArgumentException
setDimensionality in interface SparseNumberVectordimensionality - the new dimensionalityjava.lang.IllegalArgumentException - 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 java.lang.Short getValue(int dimension)
FeatureVectorgetValue in interface FeatureVector<java.lang.Number>getValue in interface NumberVectordimension - 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 NumberVectordoubleValue in interface SparseNumberVectordimension - 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 NumberVectorlongValue in interface SparseNumberVectordimension - the desired dimension, where 0 ≤ dimension <
this.getDimensionality()@Deprecated public short shortValue(int dimension)
NumberVectorgetValue(dim).shortValue(), but usually this is much more efficient
due to boxing/unboxing cost.shortValue in interface NumberVectorshortValue in interface SparseNumberVectordimension - the desired dimension, where 0 ≤ dimension <
this.getDimensionality()public double[] toArray()
NumberVectortoArray in interface NumberVectordouble[]public java.lang.String toString()
SparseNumberVectorLabelParser
.
The returned String is a single line with entries separated by
NumberVector.ATTRIBUTE_SEPARATOR. The first entry gives the
number of values actually not zero. Following entries are pairs of Short
and Short where the Short gives the index of the dimensionality and the
Short gives the corresponding value.
Example: a vector (0,1.2,1.3,0)T would result in the String2 2 1.2 3 1.3toString in interface FeatureVector<java.lang.Number>toString in class java.lang.Objectpublic int iterDim(int iter)
SparseFeatureVectoriterDim in interface SparseFeatureVector<java.lang.Number>iter - Iterator positionpublic boolean iterValid(int iter)
SparseFeatureVectoriterValid in interface SparseFeatureVector<java.lang.Number>iter - Iterator positiontrue when it refers to a valid position.public double iterDoubleValue(int iter)
SparseNumberVectoriterDoubleValue in interface SparseNumberVectoriter - Iteratorpublic short iterShortValue(int iter)
SparseNumberVectoriterShortValue in interface SparseNumberVectoriter - Iteratorpublic long iterLongValue(int iter)
SparseNumberVectoriterLongValue in interface SparseNumberVectoriter - IteratorCopyright © 2019 ELKI Development Team. License information.