Algorithm
Development Kit 1.0

algs.model.nd
Class Hyperpoint

java.lang.Object
  extended by algs.model.nd.Hyperpoint
All Implemented Interfaces:
IMultiPoint

public class Hyperpoint
extends java.lang.Object
implements IMultiPoint

Standard d-dimensional implementation of IMultiPoint.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman
See Also:
IMultiPoint

Constructor Summary
Hyperpoint(double[] vals)
          Construct when given a raw array of double values
Hyperpoint(IMultiPoint pt)
          Construct when given an IMultiPoint.
Hyperpoint(java.lang.String s)
          Construct Hyperpoint when given a comma-separated string of doubles.
 
Method Summary
 int dimensionality()
          Return the dimensionality of this point.
 double distance(IMultiPoint imp)
          Return the Euclidean distance between the given IMultiPoint.
 boolean equals(java.lang.Object o)
          Supports the equals checking of IMultiPoint objects.
 double getCoordinate(int d)
          All coordinates are 1-based.
 int hashCode()
          Reasonable hash code.
 double[] raw()
          Return copy of points for safe implementation.
 java.lang.String toString()
          Reasonable toString() implementation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hyperpoint

public Hyperpoint(IMultiPoint pt)
Construct when given an IMultiPoint.

Parameters:
pt - multi-dimensional point from which values are taken.

Hyperpoint

public Hyperpoint(double[] vals)
Construct when given a raw array of double values

Parameters:
vals - array of size d containing double coordinates.

Hyperpoint

public Hyperpoint(java.lang.String s)
Construct Hyperpoint when given a comma-separated string of doubles.

The number of dimensions in the resulting Hyperpoint is based on the number of values in the string.

Parameters:
s - String formed from a comma-separated set of doubles.
Method Detail

equals

public boolean equals(java.lang.Object o)
Supports the equals checking of IMultiPoint objects. Optimized for two Hyperpoint objects.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to be compared against.

toString

public java.lang.String toString()
Reasonable toString() implementation.

Overrides:
toString in class java.lang.Object

dimensionality

public int dimensionality()
Description copied from interface: IMultiPoint
Return the dimensionality of this point.

Specified by:
dimensionality in interface IMultiPoint
See Also:
IMultiPoint.dimensionality()

getCoordinate

public double getCoordinate(int d)
All coordinates are 1-based.

Specified by:
getCoordinate in interface IMultiPoint
Parameters:
d - the dimension 1 ≤ dx ≤ dimensionality() for the desired coordinate.
See Also:
IMultiPoint.getCoordinate(int)

distance

public double distance(IMultiPoint imp)
Return the Euclidean distance between the given IMultiPoint.

Optimized for two Hyperpoint objects, but works with any IMultiPoint

Specified by:
distance in interface IMultiPoint
Parameters:
imp - compute n-dimensional distance to this point.

hashCode

public int hashCode()
Reasonable hash code.

Overrides:
hashCode in class java.lang.Object

raw

public double[] raw()
Return copy of points for safe implementation.

Specified by:
raw in interface IMultiPoint

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.