be.hogent.tarsos.lsh
Class Vector

java.lang.Object
  extended by be.hogent.tarsos.lsh.Vector

public class Vector
extends java.lang.Object

An Vector contains a vector of 'dimension' values. It serves as the main data structure that is stored and retrieved. It also has an identifier (key).

Author:
Joren Six

Constructor Summary
Vector(int dimensions)
          Creates a new vector with the requested number of dimensions.
Vector(Vector other)
          Copy constructor.
 
Method Summary
 double dot(Vector other)
          Calculates the dot product, or scalar product, of this vector with the other vector.
 double get(int dimension)
          Returns the value at the requested dimension.
 int getDimensions()
           
 java.lang.String getKey()
           
 void moveSlightly(double radius)
          Moves the vector slightly, adds a value selected from -radius to +radius to each element.
 void set(int dimension, double value)
          Set a value at a certain dimension d.
 void setKey(java.lang.String key)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector

public Vector(int dimensions)
Creates a new vector with the requested number of dimensions.

Parameters:
dimensions - The number of dimensions.

Vector

public Vector(Vector other)
Copy constructor.

Parameters:
other - The other vector.
Method Detail

moveSlightly

public void moveSlightly(double radius)
Moves the vector slightly, adds a value selected from -radius to +radius to each element.

Parameters:
radius - The radius determines the amount to change the vector.

set

public void set(int dimension,
                double value)
Set a value at a certain dimension d.

Parameters:
dimension - The dimension, index for the value.
value - The value to set.

get

public double get(int dimension)
Returns the value at the requested dimension.

Parameters:
dimension - The dimension, index for the value.
Returns:
Returns the value at the requested dimension.

getDimensions

public int getDimensions()
Returns:
The number of dimensions this vector has.

dot

public double dot(Vector other)
Calculates the dot product, or scalar product, of this vector with the other vector.

Parameters:
other - The other vector, should have the same number of dimensions.
Returns:
The dot product of this vector with the other vector.

setKey

public void setKey(java.lang.String key)

getKey

public java.lang.String getKey()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object