org.jscience.computing.kmeans
Class Coordinate

java.lang.Object
  extended by org.jscience.computing.kmeans.Coordinate

public class Coordinate
extends java.lang.Object

Represents a single sample of data.


Constructor Summary
Coordinate(double[] coordinates)
          Builds a new coordinate from a list of doubles.
Coordinate(int dimension)
          Constructs a coordinate initialized to origin in given dimension.
Coordinate(java.lang.String sample)
          Generates a single sample of data given a string description.
 
Method Summary
 Coordinate add(Coordinate other)
          Adds this coordinate to another one.
 int dimension()
          Returns the dimension this sample exists in.
 double distance(Coordinate other)
          Returns the squared euclidean distance between this point and another.
 boolean equals(java.lang.Object othercoordinate)
           
 double get(int index)
          For accessing the data in this sample.
 Coordinate scale(double scale)
          Scales the coordinate using scalar multiplication.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Coordinate

public Coordinate(java.lang.String sample)
Generates a single sample of data given a string description.

String should be a sequence of tokens, with one real coordinate per token.

Parameters:
sample - A string containing a sequence of tokens, with one real coordinate per token.

Coordinate

public Coordinate(double[] coordinates)
Builds a new coordinate from a list of doubles.

Parameters:
coordinates - A list of coordinates.

Coordinate

public Coordinate(int dimension)
Constructs a coordinate initialized to origin in given dimension.

Parameters:
dimension - The dimension of the coordinate to create.
Method Detail

equals

public boolean equals(java.lang.Object othercoordinate)
Overrides:
equals in class java.lang.Object
Parameters:
othercoordinate - The other coordinate to compare this one to.
Returns:
True if two coordinates are equal, false otherwise.

dimension

public int dimension()
Returns the dimension this sample exists in.

Returns:
The dimensionality of this sample.

get

public double get(int index)
For accessing the data in this sample.

Parameters:
index - The index to extract.
Returns:
The data in this sample in given dimension.

distance

public double distance(Coordinate other)
Returns the squared euclidean distance between this point and another.

Parameters:
other - The other point.
Returns:
The distance between this point and the other one.

add

public Coordinate add(Coordinate other)
Adds this coordinate to another one.

Parameters:
other - The other operand.
Returns:
A coordiante containing the sum.

scale

public Coordinate scale(double scale)
Scales the coordinate using scalar multiplication.

Parameters:
scale - The value to scale all dimensions by.
Returns:
The scaled value.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The string representation of this sample.