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

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

public class IntegerVector
extends AbstractNumberVector<IntegerVector,Integer>
implements ByteBufferSerializer<IntegerVector>

An IntegerVector is to store integer values.


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

Constructor Detail

IntegerVector

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


IntegerVector

public IntegerVector(List<Integer> values)
Provides a feature vector consisting of int values according to the given Integer values.

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

IntegerVector

public IntegerVector(int[] values)
Provides an IntegerVector consisting of the given integer values.

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

IntegerVector

public IntegerVector(Integer[] values)
Provides an IntegerVector consisting of the given integer values.

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

IntegerVector

public IntegerVector(double[] values)
Provides an IntegerVector consisting of the given double values.

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

IntegerVector

public IntegerVector(Vector values)
Provides an IntegerVector consisting of the given double vectors values.

Parameters:
values - the values to be set as values of the IntegerVector
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<IntegerVector,Integer>
Specified by:
getDimensionality in interface SpatialComparable
Returns:
the number of dimensions of this FeatureVector of V

getValue

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

Specified by:
getValue in interface FeatureVector<IntegerVector,Integer>
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<IntegerVector,Integer>
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<IntegerVector,Integer>
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 int[] getValues()
Get a copy of the raw int[] 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<IntegerVector,Integer>
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<IntegerVector,Integer>
Returns:
a Matrix representing in one row and getDimensionality() columns the values of this NumberVector of V

plus

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

negativeVector

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

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

multiplicate

public IntegerVector 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<IntegerVector,Integer>
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 Integer scalarProduct(IntegerVector d)
Provides the scalar product (inner product) of this and the given IntegerVector.

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

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

newInstance

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

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

newInstance

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

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

newInstance

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

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

newInstance

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

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

fromByteBuffer

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

toByteBuffer

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

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

getByteSize

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

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

Release 0.4.0 (2011-09-20_1324)