Interface SparseNumberVector
-
- All Superinterfaces:
FeatureVector<java.lang.Number>
,NumberVector
,SparseFeatureVector<java.lang.Number>
,SpatialComparable
- All Known Implementing Classes:
BitVector
,SparseByteVector
,SparseDoubleVector
,SparseFloatVector
,SparseIntegerVector
,SparseShortVector
public interface SparseNumberVector extends NumberVector, SparseFeatureVector<java.lang.Number>
Combines the SparseFeatureVector and NumberVector.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SparseNumberVector.Factory<V extends SparseNumberVector>
Factory for sparse number vectors: make from a dim-value map.
-
Field Summary
Fields Modifier and Type Field Description static VectorFieldTypeInformation<SparseNumberVector>
FIELD
Input data type: Sparse vector field.static VectorTypeInformation<SparseNumberVector>
VARIABLE_LENGTH
Input data type: Sparse vectors with variable length.-
Fields inherited from interface elki.data.FeatureVector
TYPE
-
Fields inherited from interface elki.data.NumberVector
ATTRIBUTE_SEPARATOR, FIELD_1D, FIELD_2D
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default byte
byteValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterByteValue(int)
.double
doubleValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterDoubleValue(int)
.default float
floatValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterFloatValue(int)
.default int
intValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterIntValue(int)
.default int
iter()
Iterator over non-zero features only, ascendingly.default byte
iterByteValue(int iter)
Get the value of the iterators' current dimension.double
iterDoubleValue(int iter)
Get the value of the iterators' current dimension.default float
iterFloatValue(int iter)
Get the value of the iterators' current dimension.default int
iterIntValue(int iter)
Get the value of the iterators' current dimension.long
iterLongValue(int iter)
Get the value of the iterators' current dimension.default short
iterShortValue(int iter)
Get the value of the iterators' current dimension.long
longValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterLongValue(int)
.void
setDimensionality(int maxdim)
Update the vector space dimensionality.default short
shortValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterShortValue(int)
.-
Methods inherited from interface elki.data.FeatureVector
getDimensionality, toString
-
Methods inherited from interface elki.data.NumberVector
getMax, getMin, getValue, toArray
-
Methods inherited from interface elki.data.SparseFeatureVector
iterAdvance, iterDim, iterRetract, iterValid
-
Methods inherited from interface elki.data.spatial.SpatialComparable
getDimensionality
-
-
-
-
Field Detail
-
VARIABLE_LENGTH
static final VectorTypeInformation<SparseNumberVector> VARIABLE_LENGTH
Input data type: Sparse vectors with variable length.
-
FIELD
static final VectorFieldTypeInformation<SparseNumberVector> FIELD
Input data type: Sparse vector field.
-
-
Method Detail
-
iter
default int iter()
Iterator over non-zero features only, ascendingly.Note: depending on the underlying implementation, this may or may not be the dimension. Use
SparseFeatureVector.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. }
- Specified by:
iter
in interfaceSparseFeatureVector<java.lang.Number>
- Returns:
- Identifier for the first non-zero dimension, not necessarily the dimension!
-
setDimensionality
void setDimensionality(int maxdim)
Update the vector space dimensionality.- Parameters:
maxdim
- New dimensionality
-
iterDoubleValue
double iterDoubleValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
iterFloatValue
default float iterFloatValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
iterIntValue
default int iterIntValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
iterShortValue
default short iterShortValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
iterLongValue
long iterLongValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
iterByteValue
default byte iterByteValue(int iter)
Get the value of the iterators' current dimension.- Parameters:
iter
- Iterator- Returns:
- Value at the current position
-
doubleValue
@Deprecated double doubleValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterDoubleValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as double.Note: this might seem redundant with respect to
getValue(dim).doubleValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
doubleValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
floatValue
@Deprecated default float floatValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterFloatValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as float.Note: this might seem redundant with respect to
getValue(dim).floatValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
floatValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
intValue
@Deprecated default int intValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterIntValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as int.Note: this might seem redundant with respect to
getValue(dim).intValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
intValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
longValue
@Deprecated long longValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterLongValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as long.Note: this might seem redundant with respect to
getValue(dim).longValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
longValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
shortValue
@Deprecated default short shortValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterShortValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as short.Note: this might seem redundant with respect to
getValue(dim).shortValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
shortValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
byteValue
@Deprecated default byte byteValue(int dimension)
Deprecated.As the vectors are sparse, try to iterate over the sparse dimensions only, seeiterByteValue(int)
.Description copied from interface:NumberVector
Returns the value in the specified dimension as byte.Note: this might seem redundant with respect to
getValue(dim).byteValue()
, but usually this is much more efficient due to boxing/unboxing cost.- Specified by:
byteValue
in interfaceNumberVector
- Parameters:
dimension
- the desired dimension, where 0 ≤ dimension <this.getDimensionality()
- Returns:
- the value in the specified dimension
-
-