|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.lmu.ifi.dbs.elki.data.AbstractNumberVector<SparseFloatVector,Float> de.lmu.ifi.dbs.elki.data.SparseFloatVector
public class SparseFloatVector
A SparseFloatVector is to store real values approximately as float values.
A SparseFloatVector only requires storage for those attribute values that are non-zero.
Field Summary | |
---|---|
private int |
dimensionality
The dimensionality of this feature vector. |
private int[] |
indexes
Indexes of values |
private float[] |
values
Stored values |
Fields inherited from class de.lmu.ifi.dbs.elki.data.AbstractNumberVector |
---|
ATTRIBUTE_SEPARATOR |
Constructor Summary | |
---|---|
SparseFloatVector(float[] values)
Provides a SparseFloatVector consisting of double values according to the specified mapping of indices and values. |
|
SparseFloatVector(int[] indexes,
float[] values,
int dimensionality)
Direct constructor. |
|
SparseFloatVector(Map<Integer,Float> values,
int dimensionality)
Provides a SparseFloatVector consisting of double values according to the specified mapping of indices and values. |
Method Summary | |
---|---|
double |
doubleValue(int dimension)
Returns the value in the specified dimension as double. |
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. |
BitSet |
getNotNullMask()
Bit set of non-null features |
Matrix |
getRowVector()
Returns a Matrix representing in one row and getDimensionality() columns the values of this NumberVector of
V. |
Float |
getValue(int dimension)
Returns the value in the specified dimension. |
private double[] |
getValues()
Returns an array consisting of the values of this feature vector. |
long |
longValue(int dimension)
Returns the value in the specified dimension as long. |
SparseFloatVector |
minus(SparseFloatVector fv)
Returns a new NumberVector of V that is the sum of this NumberVector of V and the negativeVector() of given NumberVector of V. |
SparseFloatVector |
multiplicate(double k)
Returns a new NumberVector of V that is the result of a scalar multiplication with the given scalar. |
SparseFloatVector |
negativeVector()
Returns the additive inverse to this NumberVector of V. |
SparseFloatVector |
newInstance(double[] values)
Returns a new NumberVector of N for the given values. |
SparseFloatVector |
newInstance(Float[] values)
Returns a new FeatureVector of V for the given values. |
SparseFloatVector |
newInstance(List<Float> values)
Returns a new FeatureVector of V for the given values. |
SparseFloatVector |
newInstance(Vector values)
Returns a new NumberVector of N for the given values. |
SparseFloatVector |
nullVector()
Provides a null vector of the same Vector Space as this NumberVector of V (that is, of the same dimensionality). |
SparseFloatVector |
plus(SparseFloatVector fv)
Returns a new NumberVector of V that is the sum of this NumberVector of V and the given NumberVector of V. |
Float |
scalarProduct(SparseFloatVector fv)
Provides the scalar product (inner product) of this and the given SparseFloatVector. |
void |
setDimensionality(int dimensionality)
Sets the dimensionality to the new value. |
String |
toString()
Provides a String representation of this SparseFloatVector as suitable for SparseFloatVectorLabelParser . |
Methods inherited from class de.lmu.ifi.dbs.elki.data.AbstractNumberVector |
---|
byteValue, equals, floatValue, getMax, getMin, hashCode, intValue, shortValue |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.data.NumberVector |
---|
byteValue, floatValue, intValue, shortValue |
Methods inherited from interface de.lmu.ifi.dbs.elki.data.spatial.SpatialComparable |
---|
getMax, getMin |
Field Detail |
---|
private int[] indexes
private float[] values
private int dimensionality
Constructor Detail |
---|
public SparseFloatVector(int[] indexes, float[] values, int dimensionality)
indexes
- Indexes Must be sorted!values
- Associated value.dimensionality
- "true" dimensionalitypublic SparseFloatVector(Map<Integer,Float> values, int dimensionality) throws IllegalArgumentException
values
- the values to be set as values of the real vectordimensionality
- the dimensionality of this feature vector
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 SparseFloatVector(float[] values) throws IllegalArgumentException
values
- the values to be set as values of the real vector
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)Method Detail |
---|
private int getMaxDim()
public int getDimensionality()
FeatureVector
getDimensionality
in interface FeatureVector<SparseFloatVector,Float>
getDimensionality
in interface SpatialComparable
public void setDimensionality(int dimensionality) throws IllegalArgumentException
dimensionality
- the new dimensionality
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 Float getValue(int dimension)
FeatureVector
getValue
in interface FeatureVector<SparseFloatVector,Float>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
public double doubleValue(int dimension)
NumberVector
getValue(dim).doubleValue()
, but usually this is much more
efficient due to boxing/unboxing cost.
doubleValue
in interface NumberVector<SparseFloatVector,Float>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
public long longValue(int dimension)
NumberVector
getValue(dim).longValue()
, but usually this is much more efficient
due to boxing/unboxing cost.
longValue
in interface NumberVector<SparseFloatVector,Float>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
public Vector getColumnVector()
NumberVector
getDimensionality()
rows the values of this NumberVector of V.
getColumnVector
in interface NumberVector<SparseFloatVector,Float>
getDimensionality()
rows the values of this
NumberVector of Vpublic Matrix getRowVector()
NumberVector
getDimensionality()
columns the values of this NumberVector of
V.
getRowVector
in interface NumberVector<SparseFloatVector,Float>
getDimensionality()
columns the values of this
NumberVector of Vpublic SparseFloatVector plus(SparseFloatVector fv)
NumberVector
plus
in interface NumberVector<SparseFloatVector,Float>
fv
- a NumberVector of V to be added to this NumberVector of V
public SparseFloatVector minus(SparseFloatVector fv)
NumberVector
minus
in interface NumberVector<SparseFloatVector,Float>
fv
- a NumberVector of V to be subtracted to this NumberVector of V
public SparseFloatVector nullVector()
NumberVector
nullVector
in interface NumberVector<SparseFloatVector,Float>
public SparseFloatVector negativeVector()
NumberVector
negativeVector
in interface NumberVector<SparseFloatVector,Float>
public SparseFloatVector multiplicate(double k)
NumberVector
multiplicate
in interface NumberVector<SparseFloatVector,Float>
k
- a scalar to multiply this NumberVector of V with
public String toString()
Provides a String representation of this SparseFloatVector as suitable for
SparseFloatVectorLabelParser
.
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 Integer
and Float where the Integer gives the index of the dimensionality and the
Float 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<SparseFloatVector,Float>
toString
in class Object
private double[] getValues()
public Float scalarProduct(SparseFloatVector fv)
scalarProduct
in interface NumberVector<SparseFloatVector,Float>
fv
- the SparseFloatVector to compute the scalar product for
public SparseFloatVector newInstance(Vector values)
NumberVector
newInstance
in interface NumberVector<SparseFloatVector,Float>
values
- the values of the NumberVector
public SparseFloatVector newInstance(double[] values)
NumberVector
newInstance
in interface NumberVector<SparseFloatVector,Float>
values
- the values of the NumberVector
public SparseFloatVector newInstance(List<Float> values)
FeatureVector
newInstance
in interface FeatureVector<SparseFloatVector,Float>
values
- the values of the featureVector
public SparseFloatVector newInstance(Float[] values)
FeatureVector
newInstance
in interface FeatureVector<SparseFloatVector,Float>
values
- the values of the featureVector
public BitSet getNotNullMask()
SparseFeatureVector
getNotNullMask
in interface SparseFeatureVector<SparseFloatVector,Float>
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |