util
Class Hypercube

java.lang.Object
  extended by util.Hypercube

public class Hypercube
extends java.lang.Object

A class to specify an n-dimensional hypercube, by specifying its lower bound and upper bound.

Author:
dgorur

Constructor Summary
Hypercube()
          Default constructor.
Hypercube(double[] lowerBound, double[] upperBound)
          Constructs a Hypercube with the given lower bound and upper bound.
Hypercube(cern.colt.matrix.DoubleMatrix1D lowerBoundVec, cern.colt.matrix.DoubleMatrix1D upperBoundVec)
          Constructs a Hypercube with the given lower bound and upper bound.
Hypercube(int inputDimension)
          Constructs a Hypercube in the given number of dimensions.
 
Method Summary
 void assign(Hypercube other)
          Assign the properties of another Hypercube to this one.
 void centerOn(double[] x)
          Centers this Hypercube on the given point.
 void centerOn(cern.colt.matrix.DoubleMatrix1D x)
          Centers this Hypercube on the given point.
 boolean contains(double[] point)
          Checks if the given point is inside this Hypercube.
 boolean contains(cern.colt.matrix.DoubleMatrix1D point)
          Checks if the given point is inside this Hypercube.
 boolean equals(java.lang.Object obj)
           
 int getInputDimension()
          Returns the number of dimensions.
static Hypercube getInstance(int inputDimension)
          Returns an infinite Hypercube instance in the specified number of dimensions.
 double[] getLowerBound()
          Returns the lower bound.
 cern.colt.matrix.DoubleMatrix1D getLowerBoundVec()
          Returns the lower bound of this Hypercube.
 double[] getUpperBound()
          Returns the upper bound.
 cern.colt.matrix.DoubleMatrix1D getUpperBoundVec()
          Returns the upper bound of this Hypercube.
 void init()
          Initialization routine.
 void maskWith(Hypercube other)
          Uses the given Hypercube as a mask for this one: only points inside both will count.
 void scaleBy(double factor)
          Scales this Hypercube by the given factor.
 void scaleBy(double[] factors)
          Scales this Hypercube by the factors in the given array, each factor corresponding to one dimension.
 void scaleBy(cern.colt.matrix.DoubleMatrix1D factorVec)
          Scales this Hypercube by the given vector of factors, each factor corresponding to one dimension.
 void setInputDimension(int inputDimension)
          Sets the number of dimensions.
 void setLowerBound(double[] lowerBound)
          Sets the lower bound of this Hypercube.
 void setLowerBoundVec(cern.colt.matrix.DoubleMatrix1D lowerBoundVec)
          Sets the lower bound of this Hypercube.
 void setUpperBound(double[] upperBound)
          Sets the upper bound of this Hypercube.
 void setUpperBoundvec(cern.colt.matrix.DoubleMatrix1D upperBoundVec)
          Sets the upper bound of this Hypercube.
 java.lang.String toString()
           
 void translateBy(double[] amounts)
          Translates this Hypercube by the given amounts.
 void translateBy(cern.colt.matrix.DoubleMatrix1D amountVec)
          Translates this Hypercube by the given amounts.
 double volume()
          Returns the volume of this Hypercube.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Hypercube

public Hypercube()
Default constructor. Creates an empty Hypercube.


Hypercube

public Hypercube(double[] lowerBound,
                 double[] upperBound)
Constructs a Hypercube with the given lower bound and upper bound.

Parameters:
lowerBound - the given lower bound.
upperBound - the given upper bound.

Hypercube

public Hypercube(cern.colt.matrix.DoubleMatrix1D lowerBoundVec,
                 cern.colt.matrix.DoubleMatrix1D upperBoundVec)
Constructs a Hypercube with the given lower bound and upper bound.

Parameters:
lowerBoundVec - the given lower bound.
upperBoundVec - the given upper bound.

Hypercube

public Hypercube(int inputDimension)
Constructs a Hypercube in the given number of dimensions.

Parameters:
inputDimension - the given number of dimensions.
Method Detail

getInstance

public static Hypercube getInstance(int inputDimension)
Returns an infinite Hypercube instance in the specified number of dimensions. To be precise, the lower DEFAULT_BOUNDS are all set to Double.NEGATIVE_INFINITY and the upper DEFAULT_BOUNDS to Double.POSITIVE_INFINITY.

Parameters:
inputDimension - the given number of dimensions
Returns:
an infinite Hypercube instance.

assign

public void assign(Hypercube other)
Assign the properties of another Hypercube to this one.

Parameters:
other - the given Hypercube.

centerOn

public void centerOn(double[] x)
Centers this Hypercube on the given point.

Parameters:
x - the given center.

centerOn

public void centerOn(cern.colt.matrix.DoubleMatrix1D x)
Centers this Hypercube on the given point.

Parameters:
x - the given center.

contains

public boolean contains(double[] point)
Checks if the given point is inside this Hypercube. Note: we consider closed sets, so if a point is on the boundary it's considered contained.

Parameters:
point - the given point.
Returns:
true if the point is contained in this Hypercube.

contains

public boolean contains(cern.colt.matrix.DoubleMatrix1D point)
Checks if the given point is inside this Hypercube.

See Also:
contains(double[])

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getInputDimension

public int getInputDimension()
Returns the number of dimensions.

Returns:
the number of dimensions.

getLowerBound

public double[] getLowerBound()
Returns the lower bound.

Returns:
the lower bound.

getLowerBoundVec

public cern.colt.matrix.DoubleMatrix1D getLowerBoundVec()
Returns the lower bound of this Hypercube.

Returns:
the lower bound of this Hypercube.

getUpperBound

public double[] getUpperBound()
Returns the upper bound.

Returns:
the upper bound.

getUpperBoundVec

public cern.colt.matrix.DoubleMatrix1D getUpperBoundVec()
Returns the upper bound of this Hypercube.

Returns:
the upper bound of this Hypercube.

init

public void init()
Initialization routine.


maskWith

public void maskWith(Hypercube other)
Uses the given Hypercube as a mask for this one: only points inside both will count. In other words, converts this Hypercube into the one defined by the intersection of this Hypercube and the given one.

Parameters:
other - the given Hypercube to use as a mask.

scaleBy

public void scaleBy(double factor)
Scales this Hypercube by the given factor.

Parameters:
factor - the factor to scale by.

scaleBy

public void scaleBy(double[] factors)
Scales this Hypercube by the factors in the given array, each factor corresponding to one dimension.

Parameters:
factors - the given array of scaling factors.

scaleBy

public void scaleBy(cern.colt.matrix.DoubleMatrix1D factorVec)
Scales this Hypercube by the given vector of factors, each factor corresponding to one dimension.

Parameters:
factorVec - the vector of scaling factors

setInputDimension

public void setInputDimension(int inputDimension)
Sets the number of dimensions.

Parameters:
inputDimension - the given number of dimensions.

setLowerBound

public void setLowerBound(double[] lowerBound)
Sets the lower bound of this Hypercube.

Parameters:
lowerBound - the given lower bound.

setLowerBoundVec

public void setLowerBoundVec(cern.colt.matrix.DoubleMatrix1D lowerBoundVec)
Sets the lower bound of this Hypercube.

Parameters:
lowerBoundVec - the given lower bound.

setUpperBound

public void setUpperBound(double[] upperBound)
Sets the upper bound of this Hypercube.

Parameters:
upperBound - the given upper bound.

setUpperBoundvec

public void setUpperBoundvec(cern.colt.matrix.DoubleMatrix1D upperBoundVec)
Sets the upper bound of this Hypercube.

Parameters:
upperBoundVec - the given upper bound.

toString

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

translateBy

public void translateBy(double[] amounts)
Translates this Hypercube by the given amounts.

Parameters:
amounts - the amounts to translate by.

translateBy

public void translateBy(cern.colt.matrix.DoubleMatrix1D amountVec)
Translates this Hypercube by the given amounts.

Parameters:
amountVec - the amounts to translate by.

volume

public double volume()
Returns the volume of this Hypercube.

Returns:
volume of this Hypercube.