Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.data
Class SparseDoubleVector

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.data.AbstractDatabaseObject
          extended by de.lmu.ifi.dbs.elki.data.NumberVector<V,N>
              extended by de.lmu.ifi.dbs.elki.data.RealVector<SparseDoubleVector,Double>
                  extended by de.lmu.ifi.dbs.elki.data.SparseDoubleVector
All Implemented Interfaces:
WekaObject<WekaNumericAttribute>, DatabaseObject, FeatureVector<SparseDoubleVector,Double>, SpatialComparable, SpatialObject, Loggable

public class SparseDoubleVector
extends RealVector<SparseDoubleVector,Double>

A SparseDoubleVector is to store real values approximately as double values.

Class for storing a DoubleVector as a sparse vector. A SparseDoubleVector only requires storage for those attribute values that are non-zero.

Author:
Elke Achtert

Field Summary
private  int dimensionality
          The dimensionality of this feature vector.
private  Map<Integer,Double> values
          Mapping of indices and corresponding values.
 
Fields inherited from class de.lmu.ifi.dbs.elki.data.NumberVector
ATTRIBUTE_SEPARATOR
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
SparseDoubleVector(double[] values)
          Provides a SparseDoubleVector consisting of double values according to the specified mapping of indices and values.
SparseDoubleVector(Map<Integer,Double> values, int dimensionality)
          Provides a SparseDoubleVector 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.
 int getDimensionality()
          The dimensionality of the vector space whereof this FeatureVector is an element.
 Matrix getRowVector()
          Returns a Matrix representing in one row and getDimensionality() columns the values of this FeatureVector.
 Double getValue(int dimension)
          Returns the value in the specified dimension.
private  double[] getValues()
          Returns an array consisting of the values of this feature vector.
 SparseDoubleVector multiplicate(double k)
          Returns a new FeatureVector that is the result of a scalar multiplication with the given scalar.
 SparseDoubleVector negativeVector()
          Returns the additive inverse to this FeatureVector.
 SparseDoubleVector newInstance(double[] values)
          Returns a new RealVector of N for the given values.
 SparseDoubleVector nullVector()
          Provides a null vector of the same Feature Vector Space as this FeatureVector (that is, of the same dimensionality).
 SparseDoubleVector plus(SparseDoubleVector fv)
          Returns a new FeatureVector that is the sum of this FeatureVector and the given FeatureVector.
 SparseDoubleVector randomInstance(Double min, Double max, Random random)
          Returns a FeatureVector of T with random values between min and max.
 SparseDoubleVector randomInstance(Random random)
          Returns a FeatureVector of T with uniformly distributed (0-1) random values.
 String toString()
          Returns a String representation of the FeatureVector as a line that is suitable to be printed in a sequential file.
 
Methods inherited from class de.lmu.ifi.dbs.elki.data.NumberVector
equals, getAttributes, getMax, getMin, newInstance
 
Methods inherited from class de.lmu.ifi.dbs.elki.data.AbstractDatabaseObject
getID, setID
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
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

values

private Map<Integer,Double> values
Mapping of indices and corresponding values. Only non-zero values will to be stored.


dimensionality

private final int dimensionality
The dimensionality of this feature vector.

Constructor Detail

SparseDoubleVector

public SparseDoubleVector(Map<Integer,Double> values,
                          int dimensionality)
Provides a SparseDoubleVector consisting of double values according to the specified mapping of indices and values.

Parameters:
values - the values to be set as values of the real vector
dimensionality - the dimensionality of this feature vector

SparseDoubleVector

public SparseDoubleVector(double[] values)
Provides a SparseDoubleVector consisting of double values according to the specified mapping of indices and values.

Parameters:
values - the values to be set as values of the real vector
Method Detail

newInstance

public SparseDoubleVector newInstance(double[] values)
Description copied from class: RealVector
Returns a new RealVector of N for the given values.

Specified by:
newInstance in class RealVector<SparseDoubleVector,Double>
Parameters:
values - the values of the featureVector
Returns:
a new FeatureVector of T for the given values
See Also:
RealVector.newInstance(double[])

randomInstance

public SparseDoubleVector randomInstance(Random random)
Description copied from interface: FeatureVector
Returns a FeatureVector of T with uniformly distributed (0-1) random values.

Parameters:
random - a Random instance
Returns:
a FeatureVector of T with random values
See Also:
FeatureVector.randomInstance(java.util.Random)

randomInstance

public SparseDoubleVector randomInstance(Double min,
                                         Double max,
                                         Random random)
Description copied from interface: FeatureVector
Returns a FeatureVector of T with random values between min and max.

Parameters:
min - minimum of random value
max - maximu of random value
random - a random instance
Returns:
a FeatureVector of T with random values between min and max
See Also:
FeatureVector.randomInstance(Number, Number, java.util.Random)

getDimensionality

public int getDimensionality()
Description copied from interface: FeatureVector
The dimensionality of the vector space whereof this FeatureVector is an element.

Returns:
the number of dimensions of this FeatureVector
See Also:
FeatureVector.getDimensionality()

getValue

public Double getValue(int dimension)
Description copied from interface: FeatureVector
Returns the value in the specified dimension.

Parameters:
dimension - the desired dimension, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the value in the specified dimension
See Also:
FeatureVector.getValue(int)

getColumnVector

public Vector getColumnVector()
Description copied from interface: FeatureVector
Returns a Vector representing in one column and getDimensionality() rows the values of this FeatureVector.

Returns:
a Matrix representing in one column and getDimensionality() rows the values of this FeatureVector
See Also:
FeatureVector.getColumnVector()

getRowVector

public Matrix getRowVector()
Description copied from interface: FeatureVector
Returns a Matrix representing in one row and getDimensionality() columns the values of this FeatureVector.

Returns:
a Matrix representing in one row and getDimensionality() columns the values of this FeatureVector
See Also:
FeatureVector.getRowVector()

plus

public SparseDoubleVector plus(SparseDoubleVector fv)
Description copied from interface: FeatureVector
Returns a new FeatureVector that is the sum of this FeatureVector and the given FeatureVector.

Parameters:
fv - a FeatureVector to be added to this Featurevector
Returns:
a new FeatureVector that is the sum of this FeatureVector and the given FeatureVector
See Also:
FeatureVector.plus(FeatureVector)

nullVector

public SparseDoubleVector nullVector()
Description copied from interface: FeatureVector
Provides a null vector of the same Feature Vector Space as this FeatureVector (that is, of the same dimensionality).

Returns:
a null vector of the same Feature Vector Space as this FeatureVector (that is, of the same dimensionality)
See Also:
FeatureVector.nullVector()

negativeVector

public SparseDoubleVector negativeVector()
Description copied from interface: FeatureVector
Returns the additive inverse to this FeatureVector.

Returns:
the additive inverse to this FeatureVector
See Also:
FeatureVector.negativeVector()

multiplicate

public SparseDoubleVector multiplicate(double k)
Description copied from interface: FeatureVector
Returns a new FeatureVector that is the result of a scalar multiplication with the given scalar.

Parameters:
k - a scalar to multiply this FeatureVector with
Returns:
a new FeatureVector that is the result of a scalar multiplication with the given scalar
See Also:
FeatureVector.multiplicate(double)

toString

public String toString()
Description copied from interface: FeatureVector
Returns a String representation of the FeatureVector as a line that is suitable to be printed in a sequential file.

Specified by:
toString in interface FeatureVector<SparseDoubleVector,Double>
Overrides:
toString in class Object
Returns:
a String representation of the FeatureVector
See Also:
FeatureVector.toString()

getValues

private double[] getValues()
Returns an array consisting of the values of this feature vector.

Returns:
an array consisting of the values of this feature vector

Release 0.1 (2008-07-10_1838)