Updated some weighted sum arrays

This commit is contained in:
Jeff Moser 2010-09-26 18:32:18 -04:00
parent 04c911742d
commit 467d508f00

@ -50,9 +50,10 @@ class GaussianWeightedSumFactor extends GaussianFactor
$variablesToSumLength = count($variablesToSum); $variablesToSumLength = count($variablesToSum);
// 0..n-1 // 0..n-1
$this->_variableIndexOrdersForWeights[0] = array();
for($i = 0; $i < ($variablesToSumLength + 1); $i++) for($i = 0; $i < ($variablesToSumLength + 1); $i++)
{ {
$this->_variableIndexOrdersForWeights[] = $i; $this->_variableIndexOrdersForWeights[0][] = $i;
} }
// The rest move the variables around and divide out the constant. // The rest move the variables around and divide out the constant.
@ -63,13 +64,14 @@ class GaussianWeightedSumFactor extends GaussianFactor
$weightsLength = $variableWeightsLength + 1; $weightsLength = $variableWeightsLength + 1;
for ($weightsIndex = 1; $weightsIndex < $weightsLength; $weightsIndex++) for ($weightsIndex = 1; $weightsIndex < $weightsLength; $weightsIndex++)
{ {
$this->_weights[$weightsIndex] = array(); $currentWeights = array();
$this->_weights[$weightsIndex] = &$currentWeights;
$variableIndices = array(); $variableIndices = array();
$variableIndices[] = $weightsIndex; $variableIndices[0] = $weightsIndex;
$currentWeightsSquared = array(); $currentWeightsSquared = array();
$this->_WeightsSquared[$weightsIndex] = &$currentWeightsSquared; $this->_weightsSquared[$weightsIndex] = &$currentWeightsSquared;
// keep a single variable to keep track of where we are in the array. // keep a single variable to keep track of where we are in the array.
// This is helpful since we skip over one of the spots // This is helpful since we skip over one of the spots
@ -111,7 +113,7 @@ class GaussianWeightedSumFactor extends GaussianFactor
} }
$currentWeights[$currentDestinationWeightIndex] = $finalWeight; $currentWeights[$currentDestinationWeightIndex] = $finalWeight;
$currentWeightsSquared[$currentDestinationWeightIndex] = square($finalWeight); $currentWeightsSquared[$currentDestinationWeightIndex] = square($finalWeight);
$variableIndices[count($variableIndices) - 1] = 0; $variableIndices[count($variableWeights)] = 0;
$this->_variableIndexOrdersForWeights[] = &$variableIndices; $this->_variableIndexOrdersForWeights[] = &$variableIndices;
} }