Program: 3406
Project: 3406
Buggy source:
/** 
 * Returns a subset of this array based on the specified indexes
 * @param indexes the indexes in to the array
 * @return a view of the array with the specified indices
 */
@Override public INDArray get(NDArrayIndex... indexes){
  ensureNotCleanedUp();
  indexes=Indices.adjustIndices(shape(),indexes);
  int[] offsets=Indices.offsets(indexes);
  int[] shape=Indices.shape(shape(),indexes);
  if (!Indices.isContiguous(indexes)) {
    INDArray ret=create(shape);
    if (ret.isVector() && isVector()) {
      int[] indices=indexes[0].indices();
      for (int i=0; i < ret.length(); i++) {
        ret.putScalar(i,getDouble(indices[i]));
      }
      return ret;
    }
    if (!ret.isVector()) {
      if (slices() == 1) {
        INDArray newSlice=slice(0);
        NDArrayIndex[] putIndices=Arrays.copyOfRange(indexes,1,indexes.length);
        return newSlice.get(putIndices);
      }
 else       if (indexes.length == 2 && isMatrix()) {
        for (int i=0; i < ret.slices(); i++) {
          int sliceToGetFrom=indexes[0].indices()[i];
          if (sliceToGetFrom >= slices())           break;
          INDArray slice=slice(sliceToGetFrom);
          INDArray retSlice=ret.slice(i);
          int[] finalIndices=indexes[1].indices();
          for (int j=0; j < retSlice.length(); j++) {
            if (j >= retSlice.length() || finalIndices[j] >= slice.length())             break;
            retSlice.putScalar(j,slice.getDouble(finalIndices[j]));
          }
        }
      }
 else {
        for (int i=0; i < ret.slices(); i++) {
          INDArray slice=slice(i);
          INDArray putSlice=slice.get(Arrays.copyOfRange(indexes,1,indexes.length));
          ret.putSlice(i,putSlice);
        }
      }
    }
 else {
      INDArray putSlice=slice(0).get(Arrays.copyOfRange(indexes,1,indexes.length));
      ret.putSlice(0,putSlice);
    }
    return ret;
  }
  if (ArrayUtil.prod(shape) > length()) {
    INDArray ret=create(shape);
    NDArrayIndex slices=indexes[0];
    int[] indices=slices.indices();
    if (indexes.length == 1) {
      NDArrayIndex subRange=indexes[0];
      int count=0;
      for (int i=0; i < indices.length; i++) {
        if (count >= ret.length())         count=0;
        int get=subRange.indices()[count];
        ret.putScalar(count,getDouble(get));
        count++;
      }
    }
 else {
      NDArrayIndex[] subRange=Arrays.copyOfRange(indexes,1,indexes.length);
      NDArrayIndex[] putRange=NDArrayIndex.rangeOfLength(subRange);
      for (int i=0; i < indices.length; i++) {
        INDArray sliceI=ret.slice(i);
        INDArray thisSlice=slice(indices[i]);
        sliceI.put(putRange,thisSlice.get(subRange));
      }
    }
    return ret;
  }
  return subArray(offsets,shape,ArrayUtil.copy(stride()));
}

Fixed version (ground truth):
/** 
 * Returns a subset of this array based on the specified indexes
 * @param indexes the indexes in to the array
 * @return a view of the array with the specified indices
 */
@Override public INDArray get(NDArrayIndex... indexes){
  ensureNotCleanedUp();
  indexes=Indices.adjustIndices(shape(),indexes);
  int[] offsets=Indices.offsets(indexes);
  int[] shape=Indices.shape(shape(),indexes);
  if (!Indices.isContiguous(indexes)) {
    INDArray ret=create(shape);
    if (ret.isVector() && isVector()) {
      int[] indices=indexes[0].indices();
      for (int i=0; i < ret.length(); i++) {
        ret.putScalar(i,getDouble(indices[i]));
      }
      return ret;
    }
    if (!ret.isVector()) {
      if (slices() == 1) {
        INDArray newSlice=slice(0);
        NDArrayIndex[] putIndices=Arrays.copyOfRange(indexes,1,indexes.length);
        return newSlice.get(putIndices);
      }
 else       if (indexes.length == 2 && isMatrix()) {
        for (int i=0; i < ret.slices(); i++) {
          int sliceToGetFrom=indexes[0].indices()[i];
          if (sliceToGetFrom >= slices())           break;
          INDArray slice=slice(sliceToGetFrom);
          INDArray retSlice=ret.slice(i);
          int[] finalIndices=indexes[1].indices();
          for (int j=0; j < retSlice.length(); j++) {
            if (j >= retSlice.length() || finalIndices[j] >= slice.length())             break;
            retSlice.putScalar(j,slice.getDouble(finalIndices[j]));
          }
        }
      }
 else {
        for (int i=0; i < ret.slices(); i++) {
          INDArray slice=slice(i);
          INDArray putSlice=slice.get(Arrays.copyOfRange(indexes,1,indexes.length));
          ret.putSlice(i,putSlice);
        }
      }
    }
 else {
      INDArray putSlice=slice(0).get(Arrays.copyOfRange(indexes,1,indexes.length));
      ret.putSlice(0,putSlice);
    }
    return ret;
  }
  if (ArrayUtil.prod(shape) > length()) {
    INDArray ret=create(shape);
    NDArrayIndex slices=indexes[0];
    int[] indices=slices.indices();
    if (indexes.length == 1) {
      NDArrayIndex subRange=indexes[0];
      int count=0;
      for (int i=0; i < indices.length; i++) {
        if (count >= ret.length())         count=0;
        int get=subRange.indices()[count];
        ret.putScalar(count,getDouble(get));
        count++;
      }
    }
 else     if (isVector()) {
      NDArrayIndex[] subRange=Arrays.copyOfRange(indexes,1,indexes.length);
    }
 else {
      NDArrayIndex[] subRange=Arrays.copyOfRange(indexes,1,indexes.length);
      NDArrayIndex[] putRange=NDArrayIndex.rangeOfLength(subRange);
      for (int i=0; i < indices.length; i++) {
        INDArray sliceI=ret.slice(i);
        INDArray thisSlice=slice(indices[i]);
        sliceI.put(putRange,thisSlice.get(subRange));
      }
    }
    return ret;
  }
  return subArray(offsets,shape,ArrayUtil.copy(stride()));
}