Package edu.cmu.tetrad.util
Class MultiDimIntTable
java.lang.Object
edu.cmu.tetrad.util.MultiDimIntTable
Stores a table of cells with int values of arbitrary dimension. The dimensionality of the table is set in the reset() method; if a dimensionality is set in the constructor, it will be passed to the reset() method. Every time the dimensionality is changed, the table is reset to zero throughout. If the dimensionality is set to null, the table cannot be used until a non-null dimensionality is set.> 0
- Author:
- Joseph Ramsey
- 
Constructor SummaryConstructorsConstructorDescriptionMultiDimIntTable(int[] dims) Constructs a new multidimensional table of integer cells, with the given (fixed) dimensions.
- 
Method SummaryModifier and TypeMethodDescriptionintgetCellIndex(int[] coords) int[]getCoordinates(int cellIndex) intgetDimension(int var) DescribegetDimensionmethod here.int[]intgetDims(int varIndex) intintlonggetValue(int[] coords) longincrement(int[] coords, int value) Increments the value at the given coordinates by the specified amount, returning the new value.final voidreset(int[] dims) Resets the table, allowing a different dimensionality.longsetValue(int[] coords, int value) Sets the value at the given coordinates to the given value, returning the new value.
- 
Constructor Details- 
MultiDimIntTablepublic MultiDimIntTable(int[] dims) Constructs a new multidimensional table of integer cells, with the given (fixed) dimensions. Each dimension must be an integer greater than zero.- Parameters:
- dims- An int[] array of length > 0, each element of which specifies the number of values of that dimension (> 0).
 
 
- 
- 
Method Details- 
getCellIndexpublic int getCellIndex(int[] coords) - Parameters:
- coords- The coordinates of the cell. Each value must be less than the number of possible value for the corresponding dimension in the table. (Enforced.)
- Returns:
- the row in the table for the given node and combination of parent values.
 
- 
getCoordinatespublic int[] getCoordinates(int cellIndex) - Parameters:
- cellIndex- an- intvalue
- Returns:
- the array representing the combination of parent values for this row.
 
- 
incrementpublic long increment(int[] coords, int value) Increments the value at the given coordinates by the specified amount, returning the new value.- Parameters:
- coords- The coordinates of the table cell to update.
- value- The amount by which the table cell at these coordinates should be incremented (an integer).
- Returns:
- the new value at that table cell.
 
- 
setValuepublic long setValue(int[] coords, int value) Sets the value at the given coordinates to the given value, returning the new value.- Parameters:
- coords- The coordinates of the table cell to update.
- value- The amount by which the table cell at these coordinates should be incremented (an integer).
- Returns:
- the new value at that table cell.
 
- 
getValuepublic long getValue(int[] coords) - Parameters:
- coords- The coordinates of the table cell to update.
- Returns:
- the new value at that table cell.
 
- 
getNumCellspublic int getNumCells()- Returns:
- this number.
 
- 
getDimensionspublic int[] getDimensions()- Returns:
- this number.
 
- 
getDimensionpublic int getDimension(int var) DescribegetDimensionmethod here.- Parameters:
- var- an- intvalue
- Returns:
- an intvalue
 
- 
getNumDimensionspublic int getNumDimensions()- Returns:
- an intvalue
 
- 
resetpublic final void reset(int[] dims) Resets the table, allowing a different dimensionality. All cells are reset to zero. The underlying data array is reused if possible.- Parameters:
- dims- an- int[]value
 
- 
getDimspublic int getDims(int varIndex) 
 
-