|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.data.AbstractDatabaseObject
de.lmu.ifi.dbs.elki.data.NumberVector<V,N>
de.lmu.ifi.dbs.elki.data.RealVector<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 Integer |
maximumIndex
The maximal occurring index of any dimension. |
private Map<Integer,Float> |
values
Mapping of indices and corresponding values. |
Fields inherited from class de.lmu.ifi.dbs.elki.data.NumberVector |
---|
ATTRIBUTE_SEPARATOR |
Constructor Summary | |
---|---|
SparseFloatVector(float[] values)
Provides a SparseFloatVector consisting of double values according to the specified mapping of indices and values. |
|
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 | |
---|---|
Vector |
getColumnVector()
Returns a Vector representing in one column and getDimensionality() rows the values of this FeatureVector of V. |
int |
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is an element. |
List<Integer> |
getIndicesOfNotNullValues()
Provides a list containing the indices (dimensions) with a value other than zero. |
Matrix |
getRowVector()
Returns a Matrix representing in one row and getDimensionality() columns the values of this FeatureVector 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. |
SparseFloatVector |
multiplicate(double k)
Provides a new SparseFloatVector as result of the multiplication of this SparseFloatVector by the scalar k . |
SparseFloatVector |
negativeVector()
Returns the additive inverse to this FeatureVector of V. |
SparseFloatVector |
newInstance(double[] values)
Returns a new RealVector 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 |
nullVector()
Provides a null vector of the same Feature Vector Space as this FeatureVector of V (that is, of the same dimensionality). |
SparseFloatVector |
plus(SparseFloatVector fv)
Returns a new FeatureVector of V that is the sum of this FeatureVector of V and the given FeatureVector of V. |
SparseFloatVector |
randomInstance(Float min,
Float max,
Random random)
Returns a FeatureVector of V with random values between min and max. |
SparseFloatVector |
randomInstance(Random random)
Returns a FeatureVector of V with uniformly distributed (0-1) random values. |
SparseFloatVector |
randomInstance(SparseFloatVector min,
SparseFloatVector max,
Random random)
Returns a FeatureVector of V with random values between min and max. |
void |
setDimensionality(int dimensionality)
Sets the dimensionality to the new value. |
String |
toCompleteString()
Provides a String representation of this SparseFloatVector as suitable for FloatVectorLabelParser . |
String |
toString()
Provides a String representation of this SparseFloatVector as suitable for SparseFloatVectorLabelParser . |
Methods inherited from class de.lmu.ifi.dbs.elki.data.NumberVector |
---|
equals, getMax, getMin, getRange |
Methods inherited from class de.lmu.ifi.dbs.elki.data.AbstractDatabaseObject |
---|
getID, setID |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface de.lmu.ifi.dbs.elki.data.DatabaseObject |
---|
getID, setID |
Methods inherited from interface de.lmu.ifi.dbs.elki.index.tree.spatial.SpatialObject |
---|
getID |
Field Detail |
---|
private Map<Integer,Float> values
private Integer maximumIndex
private int dimensionality
Constructor Detail |
---|
public 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 |
---|
public SparseFloatVector newInstance(double[] values)
RealVector
newInstance
in class RealVector<SparseFloatVector,Float>
values
- the values of the featureVector
RealVector.newInstance(double[])
public SparseFloatVector newInstance(List<Float> values)
FeatureVector
values
- the values of the featureVector
FeatureVector.newInstance(java.util.List)
public SparseFloatVector newInstance(Float[] values)
FeatureVector
values
- the values of the featureVector
FeatureVector.newInstance(Number[])
public SparseFloatVector randomInstance(Random random)
FeatureVector
random
- a Random instance
FeatureVector.randomInstance(java.util.Random)
public SparseFloatVector randomInstance(Float min, Float max, Random random)
FeatureVector
min
- minimum of random valuemax
- maximum of random valuerandom
- a random instance
FeatureVector.randomInstance(java.lang.Number, java.lang.Number, java.util.Random)
public SparseFloatVector randomInstance(SparseFloatVector min, SparseFloatVector max, Random random)
FeatureVector
min
- minimum of random value for each axismax
- maximum of random value for each axisrandom
- a random instance
FeatureVector.randomInstance(de.lmu.ifi.dbs.elki.data.FeatureVector,
de.lmu.ifi.dbs.elki.data.FeatureVector, java.util.Random)
public int getDimensionality()
FeatureVector
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
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
FeatureVector.getValue(int)
public Vector getColumnVector()
FeatureVector
getDimensionality()
rows the values of this FeatureVector of V.
getDimensionality()
rows the values of this
FeatureVector of VFeatureVector.getColumnVector()
public Matrix getRowVector()
FeatureVector
getDimensionality()
columns the values of this FeatureVector of V.
getDimensionality()
columns the values of this
FeatureVector of VFeatureVector.getRowVector()
public SparseFloatVector plus(SparseFloatVector fv)
FeatureVector
fv
- a FeatureVector of V to be added to this FeatureVector of V
FeatureVector.plus(de.lmu.ifi.dbs.elki.data.FeatureVector)
public SparseFloatVector nullVector()
FeatureVector
FeatureVector.nullVector()
public SparseFloatVector negativeVector()
FeatureVector
FeatureVector.negativeVector()
public SparseFloatVector multiplicate(double k)
k
.
k
- a scalar to multiply this SparseFloatVector
public String toCompleteString()
FloatVectorLabelParser
.
This includes zero valued attributes but no indices.
Example: a vector (0,1.2,1.3,0)T would result in the String
0 1.2 1.3 0
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
NumberVector.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 List<Integer> getIndicesOfNotNullValues()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |