Program: 3339
Project: 3339
Buggy source:
/** 
 * Broadcasts this ndarray to be the specified shape
 * @param shape the new shape of this ndarray
 * @return the broadcasted ndarray
 */
@Override public INDArray broadcast(int[] shape){
  ensureNotCleanedUp();
  if (Shape.shapeEquals(shape,shape()))   return this;
  boolean compatible=true;
  int count=shape.length - 1;
  int thisCount=this.shape.length - 1;
  for (int i=shape.length - 1; i > 0; i--) {
    if (count < 0 || thisCount < 0)     break;
    if (shape[count] != shape()[thisCount] && shape[count] != 1 && shape()[thisCount] != 1) {
      compatible=false;
      break;
    }
    count--;
    thisCount--;
  }
  if (!compatible)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape()) + "String_Node_Str"+ Arrays.toString(shape));
  if (isScalar()) {
    INDArray ret=Nd4j.valueArrayOf(shape,getDouble(0));
    return ret;
  }
 else   if (isColumnVector() && Shape.isMatrix(shape)) {
    INDArray ret=create(shape);
    for (int i=0; i < ret.columns(); i++)     ret.putColumn(i,this.dup());
    return ret;
  }
 else   if (isRowVector()) {
    INDArray ret=create(shape);
    for (int i=0; i < ret.rows(); i++)     ret.putRow(i,this.dup());
    return ret;
  }
  int[] retShape=new int[shape.length];
  for (int i=0; i < retShape.length; i++) {
    if (shape().length == 1) {
      if (i == 0) {
        if (i < shape().length)         retShape[i]=Math.max(1,shape[i]);
 else         retShape[i]=shape[i];
      }
 else {
        if (i < shape().length)         retShape[i]=Math.max(shape[i],shape()[i]);
 else         retShape[i]=shape[i];
      }
    }
 else {
      if (i < shape().length)       retShape[i]=Math.max(shape[i],shape()[i]);
 else       retShape[i]=shape[i];
    }
  }
  INDArray ret=create(retShape);
  INDArray linear=ret.linearView();
  INDArray thisLinear=linearView();
  int bufferIdx=0;
  for (int i=0; i < ret.length(); i++) {
    linear.putScalar(i,thisLinear.getDouble(bufferIdx));
    bufferIdx++;
    if (bufferIdx >= length())     bufferIdx=0;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Broadcasts this ndarray to be the specified shape
 * @param shape the new shape of this ndarray
 * @return the broadcasted ndarray
 */
@Override public INDArray broadcast(int[] shape){
  ensureNotCleanedUp();
  if (Shape.shapeEquals(shape,shape()))   return this;
  boolean compatible=true;
  int count=shape.length - 1;
  int thisCount=this.shape.length - 1;
  for (int i=shape.length - 1; i > 0; i--) {
    if (count < 0 || thisCount < 0)     break;
    if (shape[count] != shape()[thisCount] && shape[count] != 1 && shape()[thisCount] != 1) {
      compatible=false;
      break;
    }
    count--;
    thisCount--;
  }
  if (!compatible)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape()) + "String_Node_Str"+ Arrays.toString(shape));
  int[] retShape=new int[shape.length];
  for (int i=0; i < retShape.length; i++) {
    if (shape().length == 1) {
      if (i == 0) {
        if (i < shape().length)         retShape[i]=Math.max(1,shape[i]);
 else         retShape[i]=shape[i];
      }
 else {
        if (i < shape().length)         retShape[i]=Math.max(shape[i],shape()[i]);
 else         retShape[i]=shape[i];
      }
    }
 else {
      if (i < shape().length)       retShape[i]=Math.max(shape[i],shape()[i]);
 else       retShape[i]=shape[i];
    }
  }
  INDArray ret=create(retShape);
  INDArray linear=ret.linearView();
  INDArray thisLinear=linearView();
  int bufferIdx=0;
  for (int i=0; i < ret.length(); i++) {
    linear.putScalar(i,thisLinear.getDouble(bufferIdx));
    bufferIdx++;
    if (bufferIdx >= length())     bufferIdx=0;
  }
  return ret;
}