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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.AbstractNumberVector<FloatVector,Float>
      extended by de.lmu.ifi.dbs.elki.data.FloatVector
All Implemented Interfaces:
FeatureVector<FloatVector,Float>, NumberVector<FloatVector,Float>, SpatialComparable, ByteBufferSerializer<FloatVector>

public class FloatVector
extends AbstractNumberVector<FloatVector,Float>
implements ByteBufferSerializer<FloatVector>

A FloatVector is to store real values approximately as float values.


Field Summary
private  float[] values
          Keeps the values of the float vector
 
Fields inherited from class de.lmu.ifi.dbs.elki.data.AbstractNumberVector
ATTRIBUTE_SEPARATOR
 
Constructor Summary
  FloatVector(float[] values)
          Provides a FloatVector consisting of the given float values.
  FloatVector(Float[] values)
          Provides a FloatVector consisting of the given float values.
private FloatVector(float[] values, boolean nocopy)
          Private constructor.
  FloatVector(List<Float> values)
          Provides a FloatVector consisting of float values according to the given Float values.
  FloatVector(Vector columnMatrix)
          Expects a matrix of one column.
 
Method Summary
 double doubleValue(int dimension)
          Returns the value in the specified dimension as double.
 FloatVector fromByteBuffer(ByteBuffer buffer)
          Deserialize an object from a byte buffer (e.g. disk)
 int getByteSize(FloatVector 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.
 Float getValue(int dimension)
          Returns the value in the specified dimension.
 long longValue(int dimension)
          Returns the value in the specified dimension as long.
 FloatVector minus(FloatVector fv)
          Returns a new NumberVector of V that is the sum of this NumberVector of V and the negativeVector() of given NumberVector of V.
 FloatVector multiplicate(double k)
          Returns a new NumberVector of V that is the result of a scalar multiplication with the given scalar.
 FloatVector negativeVector()
          Returns the additive inverse to this NumberVector of V.
 FloatVector newInstance(double[] values)
          Returns a new NumberVector of N for the given values.
 FloatVector newInstance(Float[] values)
          Returns a new FeatureVector of V for the given values.
 FloatVector newInstance(List<Float> values)
          Returns a new FeatureVector of V for the given values.
 FloatVector newInstance(Vector values)
          Returns a new NumberVector of N for the given values.
 FloatVector nullVector()
          Provides a null vector of the same Vector Space as this NumberVector of V (that is, of the same dimensionality).
 FloatVector plus(FloatVector fv)
          Returns a new NumberVector of V that is the sum of this NumberVector of V and the given NumberVector of V.
 Float scalarProduct(FloatVector f)
          Provides the scalar product (inner product) of this and the given FloatVector.
 void toByteBuffer(ByteBuffer buffer, FloatVector 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 float[] values
Keeps the values of the float vector

Constructor Detail

FloatVector

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


FloatVector

public FloatVector(List<Float> values)
Provides a FloatVector consisting of float values according to the given Float values.

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

FloatVector

public FloatVector(float[] values)
Provides a FloatVector consisting of the given float values.

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

FloatVector

public FloatVector(Float[] values)
Provides a FloatVector consisting of the given float values.

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

FloatVector

public FloatVector(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<FloatVector,Float>
Specified by:
getDimensionality in interface SpatialComparable
Returns:
the number of dimensions of this FeatureVector of V

getValue

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

Specified by:
getValue in interface FeatureVector<FloatVector,Float>
Parameters:
dimension - the desired dimension, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the value in the specified dimension

doubleValue

public double doubleValue(int dimension)
Description copied from interface: NumberVector
Returns the value in the specified dimension as double. Note: this might seem redundant with respect to getValue(dim).doubleValue(), but usually this is much more efficient due to boxing/unboxing cost.

Specified by:
doubleValue in interface NumberVector<FloatVector,Float>
Parameters:
dimension - the desired dimension, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the value in the specified dimension

longValue

public long longValue(int dimension)
Description copied from interface: NumberVector
Returns the value in the specified dimension as long. Note: this might seem redundant with respect to getValue(dim).longValue(), but usually this is much more efficient due to boxing/unboxing cost.

Specified by:
longValue in interface NumberVector<FloatVector,Float>
Parameters:
dimension - the desired dimension, where 1 ≤ dimension ≤ this.getDimensionality()
Returns:
the value in the specified dimension

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<FloatVector,Float>
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<FloatVector,Float>
Returns:
a Matrix representing in one row and getDimensionality() columns the values of this NumberVector of V

plus

public FloatVector plus(FloatVector 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<FloatVector,Float>
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 FloatVector minus(FloatVector 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<FloatVector,Float>
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

scalarProduct

public Float scalarProduct(FloatVector f)
Provides the scalar product (inner product) of this and the given FloatVector.

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

nullVector

public FloatVector 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<FloatVector,Float>
Returns:
a null vector of the same Vector Space as this NumberVector of V (that is, of the same dimensionality)

negativeVector

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

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

multiplicate

public FloatVector 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<FloatVector,Float>
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

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<FloatVector,Float>
Overrides:
toString in class Object
Returns:
a String representation of the FeatureVector of V

newInstance

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

Specified by:
newInstance in interface NumberVector<FloatVector,Float>
Parameters:
values - the values of the NumberVector
Returns:
a new FloatVector with the specified values

newInstance

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

Specified by:
newInstance in interface NumberVector<FloatVector,Float>
Parameters:
values - the values of the NumberVector
Returns:
a new FloatVector with the specified values

newInstance

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

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

newInstance

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

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

fromByteBuffer

public FloatVector 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<FloatVector>
Parameters:
buffer - Data array to process
Returns:
Deserialized object
Throws:
IOException

toByteBuffer

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

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

getByteSize

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

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

Release 0.4.0 (2011-09-20_1324)