|
|
|||||||||||||||||||||
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.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 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.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(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. |
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 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)
Provides a new SparseFloatVector as result of the multiplication of this SparseFloatVector by the scalar k . |
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. |
SparseFloatVector |
randomInstance(Float min,
Float max,
Random random)
Returns a NumberVector of V with random values between min and max. |
SparseFloatVector |
randomInstance(Random random)
Returns a NumberVector of V with uniformly distributed (0-1) random values. |
SparseFloatVector |
randomInstance(SparseFloatVector min,
SparseFloatVector max,
Random random)
Returns a NumberVector of V with random values between min and max. |
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 |
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.AbstractNumberVector |
---|
byteValue, equals, floatValue, getMax, getMin, intValue, shortValue |
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(Vector values)
NumberVector
values
- the values of the NumberVector
NumberVector.newInstance(double[])
public SparseFloatVector newInstance(double[] values)
NumberVector
values
- the values of the NumberVector
NumberVector.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(D[])
public SparseFloatVector randomInstance(Random random)
NumberVector
random
- a Random instance
NumberVector.randomInstance(java.util.Random)
public SparseFloatVector randomInstance(Float min, Float max, Random random)
NumberVector
min
- minimum of random valuemax
- maximum of random valuerandom
- a random instance
NumberVector.randomInstance(java.lang.Number,
java.lang.Number, java.util.Random)
public SparseFloatVector randomInstance(SparseFloatVector min, SparseFloatVector max, Random random)
NumberVector
min
- minimum of random value for each axismax
- maximum of random value for each axisrandom
- a random instance
NumberVector.randomInstance(de.lmu.ifi.dbs.elki.data.NumberVector,
de.lmu.ifi.dbs.elki.data.NumberVector, 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 double doubleValue(int dimension)
NumberVector
getValue(dim).doubleValue()
, but
usually this is much more efficient due to boxing/unboxing cost.
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.doubleValue(int)
public long longValue(int dimension)
NumberVector
getValue(dim).longValue()
, but
usually this is much more efficient due to boxing/unboxing cost.
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.longValue(int)
public Vector getColumnVector()
NumberVector
getDimensionality()
rows the values of this NumberVector of V.
getDimensionality()
rows the values of this
NumberVector of VNumberVector.getColumnVector()
public Matrix getRowVector()
NumberVector
getDimensionality()
columns the values of this NumberVector of V.
getDimensionality()
columns the values of this
NumberVector of VNumberVector.getRowVector()
public SparseFloatVector plus(SparseFloatVector fv)
NumberVector
fv
- a NumberVector of V to be added to this NumberVector of V
NumberVector.plus(de.lmu.ifi.dbs.elki.data.NumberVector)
public SparseFloatVector minus(SparseFloatVector fv)
NumberVector
fv
- a NumberVector of V to be subtracted to this NumberVector of V
NumberVector.plus(de.lmu.ifi.dbs.elki.data.NumberVector)
public SparseFloatVector nullVector()
NumberVector
NumberVector.nullVector()
public SparseFloatVector negativeVector()
NumberVector
NumberVector.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
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 List<Integer> getIndicesOfNotNullValues()
public Float scalarProduct(SparseFloatVector fv)
fv
- the SparseFloatVector to compute the scalar product for
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |