public class NDArrayDoubles
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.
Modifier and Type | Field and Description |
---|---|
protected int[] |
dimensions |
protected double[] |
values |
Modifier | Constructor and Description |
---|---|
protected |
NDArrayDoubles()
This is to enable the partially observed constructor for TableFactor.
|
|
NDArrayDoubles(int[] dimensions)
Constructor takes a list of neighbor variables to use for this factor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
double |
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,
double value)
Set a single value in the factor table.
|
public NDArrayDoubles(int[] dimensions)
dimensions
- list of neighbor variables assignment range sizesprotected NDArrayDoubles()
public void setAssignmentValue(int[] assignment, double 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 double 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()