}
// 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));