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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.AbstractNumberVector<DoubleVector,Double>
      extended by de.lmu.ifi.dbs.elki.data.DoubleVector
All Implemented Interfaces:
FeatureVector<DoubleVector,Double>, NumberVector<DoubleVector,Double>, SpatialComparable, ByteBufferSerializer<DoubleVector>
Direct Known Subclasses:
ParameterizationFunction

public class DoubleVector
extends AbstractNumberVector<DoubleVector,Double>
implements ByteBufferSerializer<DoubleVector>

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


Field Summary
private  double[] values
          Keeps the values of the real vector
 
Fields inherited from class de.lmu.ifi.dbs.elki.data.AbstractNumberVector
ATTRIBUTE_SEPARATOR
 
Constructor Summary
  DoubleVector(double[] values)
          Provides a DoubleVector consisting of the given double values.
  DoubleVector(Double[] values)
          Provides a DoubleVector consisting of the given double values.
private DoubleVector(double[] values, boolean nocopy)
          Private constructor.
  DoubleVector(List<Double> values)
          Provides a feature vector consisting of double values according to the given Double values.
  DoubleVector(Vector columnMatrix)
          Expects a matrix of one column.
 
Method Summary
 double doubleValue(int dimension)
          Returns the value of the specified attribute.
 DoubleVector fromByteBuffer(ByteBuffer buffer)
          Deserialize an object from a byte buffer (e.g. disk)
 int getByteSize(DoubleVector vec)
          Get the size of the object in bytes.
 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.
 Matrix getRowVector()
          Returns a Matrix representing in one row and getDimensionality() columns the values of this NumberVector of V.
 Double getValue(int dimension)
          Returns the value of the specified attribute.
 double[] getValues()
          Get a copy of the raw double[] array.
 long longValue(int dimension)
          Returns the value of the specified attribute as long.
 DoubleVector minus(DoubleVector fv)
          Returns a new NumberVector of V that is the sum of this NumberVector of V and the negativeVector() of given NumberVector of V.
 DoubleVector multiplicate(double k)
          Returns a new NumberVector of V that is the result of a scalar multiplication with the given scalar.
 DoubleVector negativeVector()
          Returns the additive inverse to this NumberVector of V.
 DoubleVector newInstance(double[] values)
          Returns a new NumberVector of N for the given values.
 DoubleVector newInstance(Double[] values)
          Returns a new FeatureVector of V for the given values.
 DoubleVector newInstance(List<Double> values)
          Returns a new FeatureVector of V for the given values.
 DoubleVector newInstance(Vector values)
          Returns a new NumberVector of N for the given values.
 DoubleVector nullVector()
          Provides a null vector of the same Vector Space as this NumberVector of V (that is, of the same dimensionality).
 DoubleVector plus(DoubleVector fv)
          Returns a new NumberVector of V that is the sum of this NumberVector of V and the given NumberVector of V.
 Double scalarProduct(DoubleVector d)
          Provides the scalar product (inner product) of this and the given DoubleVector.
 void toByteBuffer(ByteBuffer buffer, DoubleVector vec)
          Serialize the object to a byte array (e.g. disk)
 String toString()
          Returns a String representation of the FeatureVector of V as a line that is suitable to be printed in a sequential file.
 
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
 

Field Detail

values

private double[] values
Keeps the values of the real vector

Constructor Detail

DoubleVector

private DoubleVector(double[] values,
                     boolean nocopy)
Private constructor. NOT for public use.


DoubleVector

public DoubleVector(List<Double> values)
Provides a feature vector consisting of double values according to the given Double values.

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

DoubleVector

public DoubleVector(double[] values)
Provides a DoubleVector consisting of the given double values.

Parameters:
values - the values to be set as values of the DoubleVector

DoubleVector

public DoubleVector(Double[] values)
Provides a DoubleVector consisting of the given double values.

Parameters:
values - the values to be set as values of the DoubleVector

DoubleVector

public DoubleVector(Vector columnMatrix)
Expects a matrix of one column.

Parameters:
columnMatrix - a matrix of one column
Method Detail

getDimensionality

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

Specified by:
getDimensionality in interface FeatureVector<DoubleVector,Double>
Specified by:
getDimensionality in interface SpatialComparable
Returns:
the number of dimensions of this FeatureVector of V

getValue

public Double getValue(int dimension)
Returns the value of the specified attribute.

Specified by:
getValue in interface FeatureVector<DoubleVector,Double>
Parameters:
dimension - the selected attribute. Attributes are counted starting with 1.
Returns:
the value in the specified dimension
Throws:
IllegalArgumentException - if the specified dimension is out of range of the possible attributes

doubleValue

public double doubleValue(int dimension)
Returns the value of the specified attribute.

Specified by:
doubleValue in interface NumberVector<DoubleVector,Double>
Parameters:
dimension - the selected attribute. Attributes are counted starting with 1.
Returns:
the value in the specified dimension
Throws:
IllegalArgumentException - if the specified dimension is out of range of the possible attributes

longValue

public long longValue(int dimension)
Returns the value of the specified attribute as long.

Specified by:
longValue in interface NumberVector<DoubleVector,Double>
Parameters:
dimension - the selected attribute. Attributes are counted starting with 1.
Returns:
the value in the specified dimension
Throws:
IllegalArgumentException - if the specified dimension is out of range of the possible attributes

getValues

public double[] getValues()
Get a copy of the raw double[] array.

Returns:
copy of values array.

getColumnVector

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

Specified by:
getColumnVector in interface NumberVector<DoubleVector,Double>
Returns:
a Matrix representing in one column and getDimensionality() rows the values of this NumberVector of V

getRowVector

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

Specified by:
getRowVector in interface NumberVector<DoubleVector,Double>
Returns:
a Matrix representing in one row and getDimensionality() columns the values of this NumberVector of V

plus

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

Specified by:
plus in interface NumberVector<DoubleVector,Double>
Parameters:
fv - a NumberVector of V to be added to this NumberVector of V
Returns:
a new NumberVector of V that is the sum of this NumberVector of V and the given NumberVector of V

minus

public DoubleVector minus(DoubleVector fv)
Description copied from interface: NumberVector
Returns a new NumberVector of V that is the sum of this NumberVector of V and the negativeVector() of given NumberVector of V.

Specified by:
minus in interface NumberVector<DoubleVector,Double>
Parameters:
fv - a NumberVector of V to be subtracted to this NumberVector of V
Returns:
a new NumberVector of V that is the sum of this NumberVector of V and the negative of given NumberVector of V

nullVector

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

Specified by:
nullVector in interface NumberVector<DoubleVector,Double>
Returns:
a null vector of the same Vector Space as this NumberVector of V (that is, of the same dimensionality)

negativeVector

public DoubleVector negativeVector()
Description copied from interface: NumberVector
Returns the additive inverse to this NumberVector of V.

Specified by:
negativeVector in interface NumberVector<DoubleVector,Double>
Returns:
the additive inverse to this NumberVector of V

multiplicate

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

Specified by:
multiplicate in interface NumberVector<DoubleVector,Double>
Parameters:
k - a scalar to multiply this NumberVector of V with
Returns:
a new NumberVector of V that is the result of a scalar multiplication with the given scalar

scalarProduct

public Double scalarProduct(DoubleVector d)
Provides the scalar product (inner product) of this and the given DoubleVector.

Specified by:
scalarProduct in interface NumberVector<DoubleVector,Double>
Parameters:
d - the DoubleVector to compute the scalar product for
Returns:
the scalar product (inner product) of this and the given DoubleVector

toString

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

Specified by:
toString in interface FeatureVector<DoubleVector,Double>
Overrides:
toString in class Object
Returns:
a String representation of the FeatureVector of V

newInstance

public DoubleVector newInstance(Vector values)
Description copied from interface: NumberVector
Returns a new NumberVector of N for the given values.

Specified by:
newInstance in interface NumberVector<DoubleVector,Double>
Parameters:
values - the values of the NumberVector
Returns:
a new NumberVector of N for the given values

newInstance

public DoubleVector newInstance(Double[] values)
Description copied from interface: FeatureVector
Returns a new FeatureVector of V for the given values.

Specified by:
newInstance in interface FeatureVector<DoubleVector,Double>
Parameters:
values - the values of the featureVector
Returns:
a new FeatureVector of V for the given values

newInstance

public DoubleVector newInstance(double[] values)
Description copied from interface: NumberVector
Returns a new NumberVector of N for the given values.

Specified by:
newInstance in interface NumberVector<DoubleVector,Double>
Parameters:
values - the values of the NumberVector
Returns:
a new NumberVector of N for the given values

newInstance

public DoubleVector newInstance(List<Double> values)
Description copied from interface: FeatureVector
Returns a new FeatureVector of V for the given values.

Specified by:
newInstance in interface FeatureVector<DoubleVector,Double>
Parameters:
values - the values of the featureVector
Returns:
a new FeatureVector of V for the given values

fromByteBuffer

public DoubleVector fromByteBuffer(ByteBuffer buffer)
                            throws IOException
Description copied from interface: ByteBufferSerializer
Deserialize an object from a byte buffer (e.g. disk)

Specified by:
fromByteBuffer in interface ByteBufferSerializer<DoubleVector>
Parameters:
buffer - Data array to process
Returns:
Deserialized object
Throws:
IOException

toByteBuffer

public void toByteBuffer(ByteBuffer buffer,
                         DoubleVector vec)
                  throws IOException
Description copied from interface: ByteBufferSerializer
Serialize the object to a byte array (e.g. disk)

Specified by:
toByteBuffer in interface ByteBufferSerializer<DoubleVector>
Parameters:
buffer - Buffer to serialize to
vec - Object to serialize
Throws:
IOException

getByteSize

public int getByteSize(DoubleVector vec)
Description copied from interface: ByteBufferSerializer
Get the size of the object in bytes.

Specified by:
getByteSize in interface ByteBufferSerializer<DoubleVector>
Parameters:
vec - Object to serialize
Returns:
maximum size in serialized form

Release 0.4.0 (2011-09-20_1324)