Class MultiDimIntTable

java.lang.Object
edu.cmu.tetrad.util.MultiDimIntTable

public class MultiDimIntTable extends Object
Stores a table of cells with int values of arbitrary dimension. The dimensionality of the table is set in the constructor. The table is initialized with all cells set to zero.

Immutable.

Version:
$Id: $Id
Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiDimIntTable(int[] dims)
    Constructs a new multidimensional table of integer cells, with the given (fixed) dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getCellIndex(int[] coords)
    Returns the index in the table for the cell with the given coordinates.
    int[]
    getCoordinates(int cellIndex)
    Returns the array representing the combination of parent values for this row.
    int
    getDim(int varIndex)
    Returns the dimension of the given variable.
    int
    getDimension(int var)
    Returns the dimension of the given variable.
    int
    Returns the number of cells in the table.
    int
    Returns the number of dimensions in the table.
    int
    getValue(int[] coords)
    Returns the value of the cell at the given coordinates.
    int
    increment(int[] coords, int value)
    Increments the value at the given coordinates by the specified amount, returning the new value.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MultiDimIntTable

      public 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

    • getCellIndex

      public int getCellIndex(int[] coords)
      Returns the index in the table for the cell with the given coordinates.
      Parameters:
      coords - The coordinates of the cell. Each value must be less than the number of possible values for the corresponding dimension in the table. (Enforced.)
      Returns:
      the row in the table for the given node and combination of parent values.
    • getCoordinates

      public int[] getCoordinates(int cellIndex)
      Returns the array representing the combination of parent values for this row.
      Parameters:
      cellIndex - the index of the cell.
      Returns:
      the array representing the combination of parent values for this row.
    • increment

      public int 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.
    • getValue

      public int getValue(int[] coords)
      Returns the value of the cell at the given coordinates.
      Parameters:
      coords - The coordinates of the table cell to update.
      Returns:
      the new value at that table cell.
    • getNumCells

      public int getNumCells()
      Returns the number of cells in the table.
      Returns:
      this number.
    • getDimension

      public int getDimension(int var)
      Returns the dimension of the given variable.
      Parameters:
      var - The index of the variable.
      Returns:
      Its dimension.
    • getNumDimensions

      public int getNumDimensions()
      Returns the number of dimensions in the table.
      Returns:
      The number of dimensions.
    • getDim

      public int getDim(int varIndex)
      Returns the dimension of the given variable.
      Parameters:
      varIndex - the index of the variable.
      Returns:
      the dimension of the variable.