org.encog.mathutil.dimension
Class MultiDimension

java.lang.Object
  extended by org.encog.mathutil.dimension.MultiDimension

public class MultiDimension
extends Object

Handle multi-dimensional integer-based dimensions. Depending on how the values are interpreted, this structure can be used to either represent a coordinate, velocity or a constraint.

Author:
jheaton

Constructor Summary
MultiDimension(int n)
          Allocate a MultiDimension.
MultiDimension(MultiDimension lower)
           
 
Method Summary
 double calculateLowerStep(DimensionConstraint constraint, int d)
           
 double calculateUpperStep(DimensionConstraint constraint, int d)
           
 int flatten(DimensionConstraint constraint)
          Flatten the multi-dimensional index into a single dimension index.
 boolean forward(DimensionConstraint constraint)
          Roll the dimension forward by one.
 int getDimension(int d)
          Get a dimension.
 int[] getDimensions()
           
 void setDimension(int d, int value)
          Set a single dimension.
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiDimension

public MultiDimension(int n)
Allocate a MultiDimension.

Parameters:
n - The number of dimensions.

MultiDimension

public MultiDimension(MultiDimension lower)
Method Detail

getDimension

public int getDimension(int d)
Get a dimension.

Parameters:
d - The dimension to get.
Returns:
The value of the specified dimension.

size

public int size()
Returns:
The number of dimensions.

getDimensions

public int[] getDimensions()
Returns:
The dimensions as an array.

forward

public boolean forward(DimensionConstraint constraint)
Roll the dimension forward by one. Start with the low dimension and tick forward. This can be used to iterate through every index position.

Parameters:
constraint - The dimension constraints.
Returns:
True if there are still more combinations, false if we are done.

flatten

public int flatten(DimensionConstraint constraint)
Flatten the multi-dimensional index into a single dimension index.

Parameters:
constraint - The dimension constraints.
Returns:
The flat 1d index.

setDimension

public void setDimension(int d,
                         int value)
Set a single dimension.

Parameters:
d - The dimension to set.
value - The new value.

toString

public String toString()
Overrides:
toString in class Object

calculateLowerStep

public double calculateLowerStep(DimensionConstraint constraint,
                                 int d)

calculateUpperStep

public double calculateUpperStep(DimensionConstraint constraint,
                                 int d)


Copyright © 2014. All Rights Reserved.