Program: 25976
Project: 25976
Buggy source:
/** 
 * Perform one iteration of training.
 */
public void iteration(){
  final int rowCount=this.trainingData.size();
  final int coeffCount=this.algorithm.getLongTermMemory().length;
  final double[][] working=new double[rowCount][coeffCount];
  final double[] errors=new double[rowCount];
  final double[] weights=new double[rowCount];
  final Matrix deltas;
  for (int i=0; i < rowCount; i++) {
    final BasicData element=this.trainingData.get(i);
    working[i][0]=1;
    for (int j=0; j < element.getInput().length; j++)     working[i][j + 1]=element.getInput()[j];
  }
  for (int i=0; i < rowCount; i++) {
    final BasicData element=this.trainingData.get(i);
    final double y=this.algorithm.computeRegression(element.getInput())[0];
    errors[i]=y - element.getIdeal()[0];
    weights[i]=y * (1.0 - y);
  }
  for (int i=0; i < gradient.getColumnDimension(); i++) {
    gradient.set(0,i,0);
    for (int j=0; j < gradient.getColumnDimension(); j++)     hessian[i][j]=0;
  }
  for (int j=0; j < working.length; j++) {
    for (int i=0; i < gradient.getColumnDimension(); i++) {
      gradient.set(i,0,gradient.get(i,0) + working[j][i] * errors[j]);
    }
  }
  for (int k=0; k < weights.length; k++) {
    final double[] r=working[k];
    for (int j=0; j < r.length; j++) {
      for (int i=0; i < r.length; i++) {
        hessian[j][i]+=r[i] * r[j] * weights[k];
      }
    }
  }
  final LUDecomposition lu=new LUDecomposition(new Matrix(hessian));
  if (lu.isNonsingular()) {
    deltas=lu.solve(gradient);
  }
 else {
    throw new AIFHError("String_Node_Str");
  }
  final double[] prev=this.algorithm.getLongTermMemory().clone();
  for (int i=0; i < this.algorithm.getLongTermMemory().length; i++)   this.algorithm.getLongTermMemory()[i]-=deltas.get(i,0);
  double max=0;
  for (int i=0; i < deltas.getColumnDimension(); i++)   max=Math.max(Math.abs(deltas.get(i,0)) / Math.abs(prev[i]),max);
  this.error=max;
}

Fixed version (ground truth):
/** 
 * Perform one iteration of training.
 */
public void iteration(){
  final int rowCount=this.trainingData.size();
  final int coeffCount=this.algorithm.getLongTermMemory().length;
  final double[][] working=new double[rowCount][coeffCount];
  final double[] errors=new double[rowCount];
  final double[] weights=new double[rowCount];
  final Matrix deltas;
  for (int i=0; i < rowCount; i++) {
    final BasicData element=this.trainingData.get(i);
    working[i][0]=1;
    for (int j=0; j < element.getInput().length; j++)     working[i][j + 1]=element.getInput()[j];
  }
  for (int i=0; i < rowCount; i++) {
    final BasicData element=this.trainingData.get(i);
    final double y=this.algorithm.computeRegression(element.getInput())[0];
    errors[i]=y - element.getIdeal()[0];
    weights[i]=y * (1.0 - y);
  }
  for (int i=0; i < gradient.getColumnDimension(); i++) {
    gradient.set(0,i,0);
    for (int j=0; j < gradient.getColumnDimension(); j++)     hessian[i][j]=0;
  }
  for (int j=0; j < working.length; j++) {
    for (int i=0; i < gradient.getRowDimension(); i++) {
      gradient.set(i,0,gradient.get(i,0) + working[j][i] * errors[j]);
    }
  }
  for (int k=0; k < weights.length; k++) {
    final double[] r=working[k];
    for (int j=0; j < r.length; j++) {
      for (int i=0; i < r.length; i++) {
        hessian[j][i]+=r[i] * r[j] * weights[k];
      }
    }
  }
  final LUDecomposition lu=new LUDecomposition(new Matrix(hessian));
  if (lu.isNonsingular()) {
    deltas=lu.solve(gradient);
  }
 else {
    throw new AIFHError("String_Node_Str");
  }
  final double[] prev=this.algorithm.getLongTermMemory().clone();
  for (int i=0; i < this.algorithm.getLongTermMemory().length; i++)   this.algorithm.getLongTermMemory()[i]-=deltas.get(i,0);
  double max=0;
  for (int i=0; i < deltas.getColumnDimension(); i++)   max=Math.max(Math.abs(deltas.get(i,0)) / Math.abs(prev[i]),max);
  this.error=max;
}