* coefficients, reflection coefficients, and prediction error power.
* @exception IllegalActionException If there is no director.
*/
public void fire() throws IllegalActionException {
super.fire();
ArrayToken autocorrelationValue = (ArrayToken) autocorrelation.get(0);
int autocorrelationValueLength = autocorrelationValue.length();
// If the length of the input is odd, then the order is
// (length + 1)/2. Otherwise, it is 1 + length/2.
// Both numbers are the result of integer division
// (length + 2)/2.
int order = autocorrelationValueLength / 2;
DoubleToken[] power = new DoubleToken[order + 1];
DoubleToken[] refl = new DoubleToken[order];
DoubleToken[] lp = new DoubleToken[order];
double[] a = new double[order + 1];
double[] aP = new double[order + 1];
double[] r = new double[order + 1];
a[0] = 1.0;
aP[0] = 1.0;
// For convenience, read the autocorrelation lags into a vector.
for (int i = 0; i <= order; i++) {
r[i] = ((DoubleToken) autocorrelationValue
.getElement((autocorrelationValueLength - order + i) - 1))
.doubleValue();
}
// Output the zeroth order prediction error power, which is
// simply the power of the input process.
double P = r[0];
power[0] = new DoubleToken(P);
double gamma;
// The order recurrence
for (int M = 0; M < order; M++) {
// Compute the new reflection coefficient.
double deltaM = 0.0;
for (int m = 0; m < (M + 1); m++) {
deltaM += (a[m] * r[(M + 1) - m]);
}
// Compute and output the reflection coefficient
// (which is also equal to the last AR parameter).
if (SignalProcessing.close(P, 0.0)) {
aP[M + 1] = gamma = 0.0;
} else {
aP[M + 1] = gamma = -deltaM / P;
}
refl[M] = new DoubleToken(-gamma);
for (int m = 1; m < (M + 1); m++) {
aP[m] = a[m] + (gamma * a[(M + 1) - m]);
}
// Update the prediction error power.
P = P * (1.0 - (gamma * gamma));
if ((P < 0.0) || SignalProcessing.close(P, 0.0)) {
P = 0.0;
}
power[M + 1] = new DoubleToken(P);
// Swap a and aP for next order recurrence.
double[] temp = a;
a = aP;
aP = temp;
}
// Generate the lp outputs.
for (int m = 1; m <= order; m++) {
lp[m - 1] = new DoubleToken(-a[m]);
}
linearPredictor.broadcast(new ArrayToken(BaseType.DOUBLE, lp));
reflectionCoefficients.broadcast(new ArrayToken(BaseType.DOUBLE, refl));
errorPower.broadcast(new ArrayToken(BaseType.DOUBLE, power));
}