public class NDArray<T>
extends java.lang.Object
implements java.lang.Iterable<int[]>
Holds and provides access to an N-dimensional array.
Yes, generics will lead to unfortunate boxing and unboxing in the TableFactor case, we'll handle that if it becomes a problem.
Constructor and Description |
---|
NDArray(int[] dimensions)
Constructor takes a list of neighbor variables to use for this factor.
|
Modifier and Type | Method and Description |
---|---|
NDArray<T> |
cloneArray()
Clones the table, but keeps the values by reference.
|
int |
combinatorialNeighborStatesCount() |
java.util.Iterator<int[]> |
fastPassByReferenceIterator()
This is its own function because people will inevitably attempt this optimization of not cloning the array we
hand to the iterator, to save on GC, and it should not be default behavior.
|
T |
getAssignmentValue(int[] assignment)
Retrieve a single value for an assignment.
|
int[] |
getDimensions() |
java.util.Iterator<int[]> |
iterator()
WARNING: This is pass by reference to avoid massive GC overload during heavy iterations, and because the standard
use case is to use the assignments array as an accessor.
|
void |
setAssignmentValue(int[] assignment,
T value)
Set a single value in the factor table.
|
public NDArray(int[] dimensions)
dimensions
- list of neighbor variables assignment range sizespublic void setAssignmentValue(int[] assignment, T value)
assignment
- a list of variable settings, in the same order as the neighbors array of the factorvalue
- the value to put into the factor tablepublic T getAssignmentValue(int[] assignment)
assignment
- a list of variable settings, in the same order as the neighbors array of the factorpublic int[] getDimensions()
public java.util.Iterator<int[]> iterator()
iterator
in interface java.lang.Iterable<int[]>
public java.util.Iterator<int[]> fastPassByReferenceIterator()
public int combinatorialNeighborStatesCount()