nus-yam/ex-repair huggingface dataset:
Program: 3416
Project: 3416
Buggy source:
/** 
 * Broadcasts this ndarray to be the specified shape
 * @param shape the new shape of this ndarray
 * @return the broadcasted ndarray
 */
@Override public IComplexNDArray broadcast(int[] shape){
  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()) {
    IComplexNDArray ret=Nd4j.createComplex(Nd4j.valueArrayOf(shape,getDouble(0)));
    return ret;
  }
 else   if (isColumnVector() && Shape.isMatrix(shape)) {
    IComplexNDArray ret=Nd4j.createComplex(shape);
    for (int i=0; i < ret.columns(); i++)     ret.putColumn(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(shape[i],1);
 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];
    }
  }
  IComplexNDArray ret=Nd4j.createComplex(retShape);
  IComplexNDArray linear=ret.linearView();
  IComplexNDArray thisLinear=linearView();
  int bufferIdx=0;
  for (int i=0; i < ret.length(); i++) {
    linear.putScalar(i,thisLinear.getComplex(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 IComplexNDArray broadcast(int[] shape){
  return (IComplexNDArray)super.broadcast(shape);
}
Program: 3417
Project: 3417
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 IComplexNDArray get(NDArrayIndex... indexes){
  ensureNotCleanedUp();
  int[] offsets=Indices.offsets(indexes);
  if (offsets.length != indexes.length)   throw new IllegalStateException("String_Node_Str");
  int[] shape=Indices.shape(shape(),indexes);
  if (shape.length < offsets.length) {
    int[] copy=new int[offsets.length];
    Arrays.fill(copy,1);
    int delta=Math.abs(shape.length - copy.length);
    for (int i=copy.length - 1; i > 0; i--) {
      copy[i]=shape[i - delta];
    }
    shape=copy;
  }
  if (!Indices.isContiguous(indexes)) {
    IComplexNDArray ret=Nd4j.createComplex(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()) {
      for (int i=0; i < ret.slices(); i++) {
        INDArray putSlice=slice(i).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()) {
    IComplexNDArray ret=Nd4j.createComplex(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,getComplex(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;
  }
  int[] strides=ArrayUtil.copy(stride());
  return subArray(offsets,shape,strides);
}

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 IComplexNDArray get(NDArrayIndex... indexes){
  return (IComplexNDArray)super.get(indexes);
}
Program: 3418
Project: 3418
Buggy source:
/** 
 * Get the vector along a particular dimension
 * @param index     the index of the vector to getScalar
 * @param dimension the dimension to getScalar the vector from
 * @return the vector along a particular dimension
 */
@Override public IComplexNDArray vectorAlongDimension(int index,int dimension){
  int vectorsAlongDimension=vectorsAlongDimension(dimension);
  if (index >= vectorsAlongDimension)   throw new IllegalArgumentException("String_Node_Str" + dimension);
  if (isMatrix()) {
    if (dimension == 0) {
      return Nd4j.createComplex(data,new int[]{1,shape[dimension]},new int[]{stride[dimension],1},offset + index * stride[stride.length - 1]);
    }
 else     if (dimension == 1) {
      return Nd4j.createComplex(data,new int[]{1,shape[dimension]},new int[]{stride[dimension],1},offset + index * stride[0]);
    }
  }
  return Nd4j.createComplex(data,new int[]{1,shape[dimension]},stride[dimension] != 1 ? new int[]{stride[dimension],1} : new int[]{1,stride[dimension]},offset + index * stride[0]);
}

Fixed version (ground truth):
/** 
 * Get the vector along a particular dimension
 * @param index     the index of the vector to getScalar
 * @param dimension the dimension to getScalar the vector from
 * @return the vector along a particular dimension
 */
@Override public IComplexNDArray vectorAlongDimension(int index,int dimension){
  return (IComplexNDArray)super.vectorAlongDimension(index,dimension);
}
Program: 3419
Project: 3419
Buggy source:
/** 
 * Insert a row in to this array Will throw an exception if this ndarray is not a matrix
 * @param row   the row insert into
 * @param toPut the row to insert
 * @return this
 */
@Override public IComplexNDArray putRow(int row,INDArray toPut){
}

Fixed version (ground truth):
/** 
 * Insert a row in to this array Will throw an exception if this ndarray is not a matrix
 * @param row   the row insert into
 * @param toPut the row to insert
 * @return this
 */
@Override public IComplexNDArray putRow(int row,INDArray toPut){
  return (IComplexNDArray)super.putRow(row,toPut);
}
Program: 3420
Project: 3420
Buggy source:
@Override public IComplexNDArray subArray(int[] offsets,int[] shape,int[] stride){
  ensureNotCleanedUp();
  int n=shape.length;
  if (shape.length < 1)   return Nd4j.createComplex(shape);
  if (offsets.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(offsets));
  if (shape.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape));
  if (Arrays.equals(shape,this.shape)) {
    if (ArrayUtil.isZero(offsets)) {
      return this;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  int offset=(this.offset + ArrayUtil.dotProduct(offsets,this.stride));
  IComplexNDArray ret=Nd4j.createComplex(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
  return ret;
}

Fixed version (ground truth):
@Override public IComplexNDArray subArray(int[] offsets,int[] shape,int[] stride){
  return (IComplexNDArray)super.subArray(offsets,shape,stride);
}
Program: 3421
Project: 3421
Buggy source:
/** 
 * Mainly here for people coming from numpy. This is equivalent to a call to permute
 * @param dimension the dimension to swap
 * @param with      the one to swap it with
 * @return the swapped axes view
 */
public IComplexNDArray swapAxes(int dimension,int with){
  if (isVector()) {
    return transpose();
  }
  int[] shape=ArrayUtil.range(0,shape().length);
  shape[dimension]=with;
  shape[with]=dimension;
  return permute(shape);
}

Fixed version (ground truth):
/** 
 * Mainly here for people coming from numpy. This is equivalent to a call to permute
 * @param dimension the dimension to swap
 * @param with      the one to swap it with
 * @return the swapped axes view
 */
public IComplexNDArray swapAxes(int dimension,int with){
  return (IComplexNDArray)super.swapAxes(dimension,with);
}
Program: 3422
Project: 3422
Buggy source:
/** 
 * Get whole columns from the passed indices.
 * @param cindices
 */
@Override public IComplexNDArray getColumns(int[] cindices){
  IComplexNDArray rows=Nd4j.createComplex(rows(),cindices.length);
  for (int i=0; i < cindices.length; i++) {
    rows.putColumn(i,getColumn(cindices[i]));
  }
  return rows;
}

Fixed version (ground truth):
/** 
 * Get whole columns from the passed indices.
 * @param cindices
 */
@Override public IComplexNDArray getColumns(int[] cindices){
  return (IComplexNDArray)super.getColumns(cindices);
}
Program: 3423
Project: 3423
Buggy source:
/** 
 * Replicate and tile array to fill out to the given shape
 * @param shape the new shape of this ndarray
 * @return the shape to fill out to
 */
@Override public IComplexNDArray repmat(int[] shape){
}

Fixed version (ground truth):
/** 
 * Replicate and tile array to fill out to the given shape
 * @param shape the new shape of this ndarray
 * @return the shape to fill out to
 */
@Override public IComplexNDArray repmat(int[] shape){
  return (IComplexNDArray)super.repmat(shape);
}
Program: 3424
Project: 3424
Buggy source:
/** 
 * Returns the slice of this from the specified dimension
 * @param slice     the dimension to return from
 * @param dimension the dimension of the slice to return
 * @return the slice of this matrix from the specified dimensionand dimension
 */
@Override public INDArray slice(int slice,int dimension){
  if (shape.length == 2) {
    if (dimension == 1)     return getRow(slice);
 else     if (dimension == 0)     return getColumn(slice);
 else     throw new IllegalAccessError("String_Node_Str");
  }
  if (slice == shape.length - 1)   return slice(dimension);
  INDArray slice2=Nd4j.create(data,ArrayUtil.removeIndex(shape,dimension),ArrayUtil.removeIndex(stride,dimension),offset + slice * stride[dimension],ordering);
  return slice2;
}

Fixed version (ground truth):
/** 
 * Returns the slice of this from the specified dimension
 * @param slice     the dimension to return from
 * @param dimension the dimension of the slice to return
 * @return the slice of this matrix from the specified dimensionand dimension
 */
@Override public INDArray slice(int slice,int dimension){
  if (shape.length == 2) {
    if (dimension == 1)     return getRow(slice);
 else     if (dimension == 0)     return getColumn(slice);
 else     throw new IllegalAccessError("String_Node_Str");
  }
  if (slice == shape.length - 1)   return slice(dimension);
  INDArray slice2=create(data,ArrayUtil.removeIndex(shape,dimension),ArrayUtil.removeIndex(stride,dimension),offset + slice * stride[dimension],ordering);
  return slice2;
}
Program: 3425
Project: 3425
Buggy source:
@Override public IComplexNDArray muli(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return Nd4j.createComplex(this).muli(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray muli(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return create(this).muli(n,result);
}
Program: 3426
Project: 3426
Buggy source:
@Override public IComplexNDArray rdivi(IComplexNumber n,IComplexNDArray result){
  return Nd4j.createComplex(this).rdivi(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray rdivi(IComplexNumber n,IComplexNDArray result){
  return create(this).rdivi(n,result);
}
Program: 3427
Project: 3427
Buggy source:
@Override public IComplexNDArray subi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return Nd4j.createComplex(this).subi(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray subi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return create(this).subi(n,result);
}
Program: 3428
Project: 3428
Buggy source:
protected void init(int[] shape){
  ensureNotCleanedUp();
  this.shape=shape;
  if (this.shape.length == 1) {
    rows=1;
    columns=this.shape[0];
  }
 else   if (this.shape().length == 2) {
    rows=shape[0];
    columns=shape[1];
  }
  if (this.shape.length == 1) {
    init(new int[]{1,this.shape[0]});
  }
  if (this.ordering == '\u0000')   this.ordering=Nd4j.order();
  this.length=ArrayUtil.prod(this.shape);
  if (this.stride == null) {
    this.stride=Nd4j.getStrides(shape,ordering);
  }
  if (this.stride.length != this.shape.length) {
    if (ordering == NDArrayFactory.FORTRAN)     this.stride=ArrayUtil.calcStridesFortran(this.shape);
 else     this.stride=ArrayUtil.calcStrides(this.shape);
  }
}

Fixed version (ground truth):
protected void init(int[] shape){
  ensureNotCleanedUp();
  this.shape=shape;
  if (this.shape.length == 1) {
    rows=1;
    columns=this.shape[0];
  }
 else   if (this.shape().length == 2) {
    rows=shape[0];
    columns=shape[1];
  }
  if (this.shape.length == 1) {
    init(new int[]{1,this.shape[0]});
  }
  if (this.ordering == '\u0000')   this.ordering=Nd4j.order();
  this.length=ArrayUtil.prod(this.shape);
  if (this.stride == null) {
    this.stride=Nd4j.getStrides(shape,ordering);
  }
  if (this.stride.length != this.shape.length) {
    this.stride=getStrides(shape,ordering());
  }
}
Program: 3430
Project: 3430
Buggy source:
/** 
 * See: http://www.mathworks.com/help/matlab/ref/permute.htsliceml
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public INDArray permute(int[] rearrange){
  ensureNotCleanedUp();
  if (rearrange.length != shape.length)   return dup();
  checkArrangeArray(rearrange);
  int[] newShape=doPermuteSwap(shape,rearrange);
  if (isVector() || isMatrix()) {
    if (Arrays.equals(rearrange,ArrayUtil.reverseCopy(ArrayUtil.range(0,2))))     return transpose();
    return this;
  }
  int[] newStride=doPermuteSwap(stride,rearrange);
  INDArray value=Nd4j.create(data(),newShape,newStride,offset,ordering);
  return value;
}

Fixed version (ground truth):
/** 
 * See: http://www.mathworks.com/help/matlab/ref/permute.htsliceml
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public INDArray permute(int[] rearrange){
  ensureNotCleanedUp();
  if (rearrange.length != shape.length)   return dup();
  checkArrangeArray(rearrange);
  int[] newShape=doPermuteSwap(shape,rearrange);
  if (isVector() || isMatrix()) {
    if (Arrays.equals(rearrange,ArrayUtil.reverseCopy(ArrayUtil.range(0,2))))     return transpose();
    return this;
  }
  int[] newStride=doPermuteSwap(stride,rearrange);
  INDArray value=create(data(),newShape,newStride,offset,ordering);
  return value;
}
Program: 3434
Project: 3434
Buggy source:
@Override public INDArray linearViewColumnOrder(){
  ensureNotCleanedUp();
  return Nd4j.create(data,new int[]{length,1},offset());
}

Fixed version (ground truth):
@Override public INDArray linearViewColumnOrder(){
  ensureNotCleanedUp();
  return create(data,new int[]{length,1},offset());
}
Program: 3435
Project: 3435
Buggy source:
/** 
 * Flattens the array for linear indexing
 * @return the flattened version of this array
 */
@Override public INDArray ravel(){
  ensureNotCleanedUp();
  INDArray ret=Nd4j.create(length,ordering);
  int dimension=shape.length == 2 ? 1 : shape.length - 1;
  int count=0;
  for (int i=0; i < vectorsAlongDimension(dimension); i++) {
    INDArray vec=vectorAlongDimension(i,dimension);
    for (int j=0; j < vec.length(); j++) {
      ret.putScalar(count++,vec.getDouble(j));
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Flattens the array for linear indexing
 * @return the flattened version of this array
 */
@Override public INDArray ravel(){
  ensureNotCleanedUp();
  INDArray ret=create(new int[]{1,length},ordering);
  int dimension=shape.length == 2 ? 1 : shape.length - 1;
  int count=0;
  for (int i=0; i < vectorsAlongDimension(dimension); i++) {
    INDArray vec=vectorAlongDimension(i,dimension);
    for (int j=0; j < vec.length(); j++) {
      ret.putScalar(count++,vec.getDouble(j));
    }
  }
  return ret;
}
Program: 3436
Project: 3436
Buggy source:
protected INDArray newShape(int[] newShape,char ordering){
  ensureNotCleanedUp();
  if (Arrays.equals(newShape,this.shape()))   return this;
 else   if (Shape.isVector(newShape) && isVector()) {
    if (isRowVector() && Shape.isColumnVectorShape(newShape)) {
      return Nd4j.create(data,newShape,stride,offset);
    }
 else     if (isRowVector() && newShape.length == 1 || isRowVector() && newShape.length == 2) {
      this.shape=newShape;
    }
 else     if (isColumnVector() && Shape.isRowVectorShape(newShape)) {
      return Nd4j.create(data,newShape,new int[]{stride[0],1},offset);
    }
  }
  INDArray newCopy=this;
  int[] newStrides=null;
  if (newStrides == null) {
    newStrides=this instanceof IComplexNDArray ? Nd4j.getComplexStrides(newShape,ordering()) : Nd4j.getStrides(newShape,ordering());
  }
  if (shape().length > 1 || this.ordering != ordering || newShape.length != shape().length) {
    if (this instanceof IComplexNDArray)     return Nd4j.create(data,newShape,newStrides,offset,ordering);
    newCopy=Nd4j.create(data,newShape,newStrides,offset,ordering);
    return newCopy;
  }
  if (this instanceof IComplexNDArray)   return Nd4j.createComplex(newCopy.data(),newShape,newStrides,offset);
  return Nd4j.create(newCopy.data(),newShape,newStrides,offset);
}

Fixed version (ground truth):
protected INDArray newShape(int[] newShape,char ordering){
  ensureNotCleanedUp();
  if (Arrays.equals(newShape,this.shape()))   return this;
 else   if (Shape.isVector(newShape) && isVector()) {
    if (isRowVector() && Shape.isColumnVectorShape(newShape)) {
      return create(data,newShape,stride,offset);
    }
 else     if (isRowVector() && newShape.length == 1 || isRowVector() && newShape.length == 2) {
      this.shape=newShape;
    }
 else     if (isColumnVector() && Shape.isRowVectorShape(newShape)) {
      return create(data,newShape,new int[]{stride[0],1},offset);
    }
  }
  INDArray newCopy=this;
  int[] newStrides=null;
  if (newStrides == null) {
    newStrides=this instanceof IComplexNDArray ? Nd4j.getComplexStrides(newShape,ordering()) : Nd4j.getStrides(newShape,ordering());
  }
  if (shape().length > 1 || this.ordering != ordering || newShape.length != shape().length) {
    if (this instanceof IComplexNDArray)     return create(data,newShape,newStrides,offset,ordering);
    newCopy=create(data,newShape,newStrides,offset,ordering);
    return newCopy;
  }
  return create(newCopy.data(),newShape,newStrides,offset);
}
Program: 3437
Project: 3437
Buggy source:
@Override public INDArray subArray(int[] offsets,int[] shape,int[] stride){
  ensureNotCleanedUp();
  int n=shape.length;
  if (shape.length < 1)   return Nd4j.create(Nd4j.createBuffer(shape));
  if (offsets.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(offsets));
  if (shape.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape));
  if (Arrays.equals(shape,this.shape)) {
    if (ArrayUtil.isZero(offsets)) {
      return this;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  int offset=this.offset + ArrayUtil.dotProduct(offsets,this.stride);
  if (ordering() == NDArrayFactory.C && shape[0] == 1)   return Nd4j.create(data,Arrays.copyOf(shape,shape.length),ArrayUtil.reverseCopy(stride),offset,ordering);
  return Nd4j.create(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
}

Fixed version (ground truth):
@Override public INDArray subArray(int[] offsets,int[] shape,int[] stride){
  ensureNotCleanedUp();
  int n=shape.length;
  if (shape.length < 1)   return create(Nd4j.createBuffer(shape));
  if (offsets.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(offsets));
  if (shape.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape));
  if (Arrays.equals(shape,this.shape)) {
    if (ArrayUtil.isZero(offsets)) {
      return this;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  int offset=this.offset + ArrayUtil.dotProduct(offsets,this.stride);
  if (ordering() == NDArrayFactory.C && shape[0] == 1)   return create(data,Arrays.copyOf(shape,shape.length),ArrayUtil.reverseCopy(stride),offset,ordering);
  return create(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
}
Program: 3438
Project: 3438
Buggy source:
@Override public IComplexNDArray addi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return Nd4j.createComplex(this).addi(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray addi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return create(this).addi(n,result);
}
Program: 3439
Project: 3439
Buggy source:
/** 
 * Return transposed version of this matrix.
 */
@Override public INDArray transposei(){
  if (isRowVector())   return Nd4j.create(data,shape.length == 1 ? new int[]{shape[0],1} : ArrayUtil.reverseCopy(shape()),offset);
 else   if (isColumnVector())   return Nd4j.create(data,new int[]{1,shape[0]},offset);
  if (isMatrix()) {
    if (this instanceof IComplexNDArray) {
      IComplexNDArray arr=Nd4j.createComplex(columns(),rows());
      IComplexNDArray arrThis=(IComplexNDArray)this;
      for (int i=0; i < arr.rows(); i++) {
        for (int j=0; j < arr.columns(); j++)         arr.put(i,j,arrThis.getComplex(j,i));
      }
      return arr;
    }
 else {
      INDArray arr=Nd4j.create(columns(),rows());
      for (int i=0; i < arr.rows(); i++) {
        for (int j=0; j < arr.columns(); j++)         arr.put(i,j,getDouble(j,i));
      }
      return arr;
    }
  }
  INDArray arr=Nd4j.create(ArrayUtil.reverseCopy(shape()));
  for (int i=0; i < arr.slices(); i++) {
    arr.putSlice(i,arr.slice(i).transpose());
  }
  return arr;
}

Fixed version (ground truth):
/** 
 * Return transposed version of this matrix.
 */
@Override public INDArray transposei(){
  if (isRowVector())   return create(data,shape.length == 1 ? new int[]{shape[0],1} : ArrayUtil.reverseCopy(shape()),offset);
 else   if (isColumnVector())   return create(data,new int[]{1,shape[0]},offset);
  if (isMatrix()) {
    if (this instanceof IComplexNDArray) {
      INDArray arr=create(new int[]{columns(),rows()});
      INDArray arrThis=this;
      for (int i=0; i < arr.rows(); i++) {
        for (int j=0; j < arr.columns(); j++)         arr.put(i,j,arrThis.getDouble(j,i));
      }
      return arr;
    }
 else {
      INDArray arr=create(columns(),rows());
      for (int i=0; i < arr.rows(); i++) {
        for (int j=0; j < arr.columns(); j++)         arr.put(i,j,getDouble(j,i));
      }
      return arr;
    }
  }
  INDArray arr=create(ArrayUtil.reverseCopy(shape()));
  for (int i=0; i < arr.slices(); i++) {
    arr.putSlice(i,arr.slice(i).transpose());
  }
  return arr;
}
Program: 3440
Project: 3440
Buggy source:
/** 
 * Get whole rows from the passed indices.
 * @param rindices
 */
@Override public INDArray getRows(int[] rindices){
  ensureNotCleanedUp();
  INDArray rows=Nd4j.create(rindices.length,columns());
  for (int i=0; i < rindices.length; i++) {
    rows.putRow(i,getRow(rindices[i]));
  }
  return rows;
}

Fixed version (ground truth):
/** 
 * Get whole rows from the passed indices.
 * @param rindices
 */
@Override public INDArray getRows(int[] rindices){
  ensureNotCleanedUp();
  INDArray rows=create(new int[]{rindices.length,columns()});
  for (int i=0; i < rindices.length; i++) {
    rows.putRow(i,getRow(rindices[i]));
  }
  return rows;
}
Program: 3441
Project: 3441
Buggy source:
/** 
 * Get whole columns from the passed indices.
 * @param cindices
 */
@Override public INDArray getColumns(int[] cindices){
  ensureNotCleanedUp();
  INDArray rows=Nd4j.create(rows(),cindices.length);
  for (int i=0; i < cindices.length; i++) {
    rows.putColumn(i,getColumn(cindices[i]));
  }
  return rows;
}

Fixed version (ground truth):
/** 
 * Get whole columns from the passed indices.
 * @param cindices
 */
@Override public INDArray getColumns(int[] cindices){
  ensureNotCleanedUp();
  INDArray rows=create(rows(),cindices.length);
  for (int i=0; i < cindices.length; i++) {
    rows.putColumn(i,getColumn(cindices[i]));
  }
  return rows;
}
Program: 3442
Project: 3442
Buggy source:
@Override public IComplexNDArray divi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return Nd4j.createComplex(this).divi(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray divi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return create(this).divi(n,result);
}
Program: 3443
Project: 3443
Buggy source:
@Override public IComplexNDArray rsubi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return Nd4j.createComplex(this).rsubi(n,result);
}

Fixed version (ground truth):
@Override public IComplexNDArray rsubi(IComplexNumber n,IComplexNDArray result){
  ensureNotCleanedUp();
  return create(this).rsubi(n,result);
}
Program: 3444
Project: 3444
Buggy source:
@Override public INDArray dup(){
  ensureNotCleanedUp();
  INDArray ret=Nd4j.create(data.dup(),shape(),stride(),offset());
  return ret;
}

Fixed version (ground truth):
@Override public INDArray dup(){
  ensureNotCleanedUp();
  INDArray ret=create(data.dup(),shape(),stride(),offset());
  return ret;
}
Program: 3445
Project: 3445
Buggy source:
INDArray create(double[] data,int[] ints,int[] ints1,char order,int offset);

Fixed version (ground truth):
INDArray create(int[] shape,int[] stride,int offset,char ordering);
Program: 3446
Project: 3446
Buggy source:
IComplexNDArray createComplex(int[] ints,int[] ints1,int[] stride,int offset);

Fixed version (ground truth):
IComplexNDArray createComplex(int[] shape,int[] complexStrides,int offset,char ordering);
Program: 3447
Project: 3447
Buggy source:
public static INDArray create(DataBuffer buffer){
  INDArray ret=INSTANCE.create(buffer);
  logCreationIfNecessary(ret);
  return ret;
}

Fixed version (ground truth):
/** 
 * @param buffer
 * @return
 */
public static INDArray create(DataBuffer buffer){
  INDArray ret=INSTANCE.create(buffer);
  logCreationIfNecessary(ret);
  return ret;
}
Program: 3448
Project: 3448
Buggy source:
/** 
 * Returns the length of the indices
 * @return the length of the range
 */
public int length(){
  if (indices.length < 1)   return 0;
  return indices[indices.length - 1] - indices[0];
}

Fixed version (ground truth):
/** 
 * Returns the length of the indices
 * @return the length of the range
 */
public int length(){
  return indices.length;
}
Program: 3449
Project: 3449
Buggy source:
@Test public void testInterval(){
  int[] interval=NDArrayIndex.interval(0,2).indices();
  assertTrue(Arrays.equals(interval,new int[]{0,1}));
  int[] interval2=NDArrayIndex.interval(1,3).indices();
  assertEquals(2,interval2.length);
  int[] nextInterval=NDArrayIndex.interval(0,5).indices();
  assertEquals(5,nextInterval.length);
  nextInterval=NDArrayIndex.interval(0,5,true).indices();
  assertEquals(6,nextInterval.length);
}

Fixed version (ground truth):
@Test public void testInterval(){
  int[] interval=NDArrayIndex.interval(0,2).indices();
  assertTrue(Arrays.equals(interval,new int[]{0,1}));
  int[] interval2=NDArrayIndex.interval(1,3).indices();
  assertEquals(2,interval2.length);
  int[] nextInterval=NDArrayIndex.interval(0,5).indices();
  assertEquals(5,nextInterval.length);
  nextInterval=NDArrayIndex.interval(0,5,true).indices();
  assertEquals(6,nextInterval.length);
  assertEquals(nextInterval.length,NDArrayIndex.interval(0,5,true).length());
}
Program: 3450
Project: 3450
Buggy source:
@Test public void testRMseXent(){
  INDArray in=Nd4j.create(new double[][]{{1,2},{3,4}});
  INDArray out=Nd4j.create(new double[][]{{5,6},{7,8}});
  double diff=LossFunctions.score(in,LossFunctions.LossFunction.RMSE_XENT,out,0,false);
  assertEquals(4,diff,1e-1);
}

Fixed version (ground truth):
@Test public void testRMseXent(){
  INDArray in=Nd4j.create(new double[][]{{1,2},{3,4}});
  INDArray out=Nd4j.create(new double[][]{{5,6},{7,8}});
  double diff=LossFunctions.score(in,LossFunctions.LossFunction.RMSE_XENT,out,0,false);
  assertEquals(8,diff,1e-1);
}
Program: 3452
Project: 3452
Buggy source:
/** 
 * Upsampling a signal (specifically the first 2 dimensions)
 * @param d the data to upsample
 * @param scale the amount to scale by
 * @return the upsampled ndarray
 */
public static INDArray upSample(INDArray d,INDArray scale){
  List<INDArray> idx=new ArrayList<>();
  for (int i=0; i < d.shape().length; i++) {
    INDArray tmp=Nd4j.zeros(d.size(i) * (int)scale.getDouble(i),1);
    int[] indices=ArrayUtil.range(0,(int)scale.getDouble(i) * d.size(i),(int)scale.getDouble(i));
    NDArrayIndex index=new NDArrayIndex(indices);
    tmp.put(new NDArrayIndex[]{index},1);
    INDArray put=tmp.cumsum(0);
    idx.add(put.sub(1));
  }
  INDArray ret=Nd4j.create(ArrayUtil.toInts(ArrayUtil.toNDArray(d.shape()).muli(scale)));
  INDArray retLinear=ret.linearView();
  for (int i=0; i < retLinear.length(); i++) {
    for (int j=0; j < idx.get(0).length(); j++) {
      int slice=idx.get(0).getInt(j);
      for (int k=1; k < idx.size(); k++) {
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Upsampling a signal (specifically the first 2 dimensions)
 * @param d the data to upsample
 * @param scale the amount to scale by
 * @return the upsampled ndarray
 */
public static INDArray upSample(INDArray d,INDArray scale){
  List<INDArray> idx=new ArrayList<>();
  for (int i=0; i < d.shape().length; i++) {
    INDArray tmp=Nd4j.zeros(d.size(i) * (int)scale.getDouble(i),1);
    int[] indices=ArrayUtil.range(0,(int)scale.getDouble(i) * d.size(i),(int)scale.getDouble(i));
    NDArrayIndex index=new NDArrayIndex(indices);
    tmp.put(new NDArrayIndex[]{index},1);
    INDArray put=tmp.cumsum(0);
    idx.add(put.sub(1));
  }
  NDArrayIndex[] ret=new NDArrayIndex[idx.size()];
  for (int i=0; i < ret.length; i++)   ret[i]=NDArrayIndex.create(idx.get(i))[0];
  return d.get(ret);
}
Program: 3453
Project: 3453
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 IComplexNDArray get(NDArrayIndex... indexes){
  ensureNotCleanedUp();
  indexes=Indices.adjustIndices(shape(),indexes);
  int[] offsets=Indices.offsets(indexes);
  int[] shape=Indices.shape(shape(),indexes);
  if (!Indices.isContiguous(indexes)) {
    IComplexNDArray ret=Nd4j.createComplex(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()) {
      for (int i=0; i < ret.slices(); i++) {
        INDArray putSlice=slice(i).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())   return this;
  int[] strides;
  strides=ArrayUtil.copy(stride());
  if (offsets.length != shape.length)   offsets=Arrays.copyOfRange(offsets,0,shape.length);
  if (strides.length != shape.length)   strides=Arrays.copyOfRange(strides,0,shape.length);
  return subArray(offsets,shape,strides);
}

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 IComplexNDArray get(NDArrayIndex... indexes){
  ensureNotCleanedUp();
  int[] offsets=Indices.offsets(indexes);
  if (offsets.length != indexes.length)   throw new IllegalStateException("String_Node_Str");
  int[] shape=Indices.shape(shape(),indexes);
  if (shape.length < offsets.length) {
    int[] copy=new int[offsets.length];
    Arrays.fill(copy,1);
    int delta=Math.abs(shape.length - copy.length);
    for (int i=copy.length - 1; i > 0; i--) {
      copy[i]=shape[i - delta];
    }
    shape=copy;
  }
  if (!Indices.isContiguous(indexes)) {
    IComplexNDArray ret=Nd4j.createComplex(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()) {
      for (int i=0; i < ret.slices(); i++) {
        INDArray putSlice=slice(i).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())   return this;
  int[] strides=ArrayUtil.copy(stride());
  return subArray(offsets,shape,strides);
}
Program: 3454
Project: 3454
Buggy source:
@Override public IComplexNDArray subArray(int[] offsets,int[] shape,int[] stride){
  ensureNotCleanedUp();
  int n=shape.length;
  if (shape.length < 1)   return Nd4j.createComplex(shape);
  if (offsets.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(offsets));
  if (shape.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape));
  if (Arrays.equals(shape,this.shape)) {
    if (ArrayUtil.isZero(offsets)) {
      return this;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  for (int i=0; i < offsets.length; i++)   offsets[i]/=2;
  int offset=(this.offset + ArrayUtil.dotProduct(offsets,this.stride));
  IComplexNDArray ret=Nd4j.createComplex(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
  return ret;
}

Fixed version (ground truth):
@Override public IComplexNDArray subArray(int[] offsets,int[] shape,int[] stride){
  ensureNotCleanedUp();
  int n=shape.length;
  if (shape.length < 1)   return Nd4j.createComplex(shape);
  if (offsets.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(offsets));
  if (shape.length != n)   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(shape));
  if (Arrays.equals(shape,this.shape)) {
    if (ArrayUtil.isZero(offsets)) {
      return this;
    }
 else {
      throw new IllegalArgumentException("String_Node_Str");
    }
  }
  int offset=(this.offset + ArrayUtil.dotProduct(offsets,this.stride));
  IComplexNDArray ret=Nd4j.createComplex(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
  return ret;
}
Program: 3455
Project: 3455
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=Nd4j.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()) {
      for (int i=0; i < ret.slices(); i++) {
        INDArray putSlice=slice(i).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())   return this;
  int[] strides=null;
  strides=ArrayUtil.copy(stride());
  if (offsets.length != shape.length)   offsets=Arrays.copyOfRange(offsets,0,shape.length);
  if (strides.length != shape.length)   strides=Arrays.copyOfRange(strides,0,shape.length);
  return subArray(offsets,shape,strides);
}

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=Nd4j.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 {
        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())   return this;
  int[] strides=ArrayUtil.copy(stride());
  return subArray(offsets,shape,strides);
}
Program: 3456
Project: 3456
Buggy source:
/** 
 * Compare two matrices. Returns true if and only if other is also a DoubleMatrix which has the same size and the maximal absolute difference in matrix elements is smaller than 1e-6.
 * @param o
 */
@Override public boolean equals(Object o){
  ensureNotCleanedUp();
  INDArray n=null;
  if (!(o instanceof INDArray))   return false;
  if (n == null)   n=(INDArray)o;
  if (isScalar() && n.isScalar()) {
    if (data.dataType() == DataBuffer.FLOAT) {
      double val=getDouble(0);
      double val2=n.getDouble(0);
      return Math.abs(val - val2) < 1e-6;
    }
 else {
      double val=getDouble(0);
      double val2=n.getDouble(0);
      return Math.abs(val - val2) < 1e-6;
    }
  }
 else   if (isVector() && n.isVector()) {
    for (int i=0; i < length; i++) {
      if (data.dataType() == DataBuffer.FLOAT) {
        double curr=getDouble(i);
        double comp=n.getDouble(i);
        if (Math.abs(curr - comp) > 1e-3)         return false;
      }
 else {
        double curr=getDouble(i);
        double comp=n.getDouble(i);
        if (Math.abs(curr - comp) > 1e-3)         return false;
      }
    }
    return true;
  }
  if (!Shape.shapeEquals(shape(),n.shape()))   return false;
  if (slices() != n.slices())   return false;
  for (int i=0; i < slices(); i++) {
    INDArray slice=slice(i);
    INDArray nSlice=n.slice(i);
    if (!slice.equals(nSlice))     return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Compare two matrices. Returns true if and only if other is also a DoubleMatrix which has the same size and the maximal absolute difference in matrix elements is smaller than 1e-6.
 * @param o
 */
@Override public boolean equals(Object o){
  ensureNotCleanedUp();
  INDArray n=null;
  if (!(o instanceof INDArray))   return false;
  if (n == null)   n=(INDArray)o;
  if (isScalar() && n.isScalar()) {
    if (data.dataType() == DataBuffer.FLOAT) {
      double val=getDouble(0);
      double val2=n.getDouble(0);
      return Math.abs(val - val2) < Nd4j.EPS_THRESHOLD;
    }
 else {
      double val=getDouble(0);
      double val2=n.getDouble(0);
      return Math.abs(val - val2) < Nd4j.EPS_THRESHOLD;
    }
  }
 else   if (isVector() && n.isVector()) {
    for (int i=0; i < length; i++) {
      if (data.dataType() == DataBuffer.FLOAT) {
        double curr=getDouble(i);
        double comp=n.getDouble(i);
        if (Math.abs(curr - comp) > Nd4j.EPS_THRESHOLD)         return false;
      }
 else {
        double curr=getDouble(i);
        double comp=n.getDouble(i);
        if (Math.abs(curr - comp) > Nd4j.EPS_THRESHOLD)         return false;
      }
    }
    return true;
  }
  if (!Shape.shapeEquals(shape(),n.shape()))   return false;
  if (slices() != n.slices())   return false;
  for (int i=0; i < slices(); i++) {
    INDArray slice=slice(i);
    INDArray nSlice=n.slice(i);
    if (!slice.equals(nSlice))     return false;
  }
  return true;
}
Program: 3459
Project: 3459
Buggy source:
/** 
 * Calculate the shape for the given set of indices. <p/> The shape is defined as (for each dimension) the difference between the end index + 1 and the begin index <p/> If specified, this will check for whether any of the indices are >= to end - 1 and if so, prune it down
 * @param shape   the original shape
 * @param indices the indices to calculate the shape for
 * @return the shape for the given indices
 */
public static int[] shape(int[] shape,NDArrayIndex... indices){
  if (indices.length > shape.length)   return shape;
  int[] ret=new int[indices.length];
  for (int i=0; i < ret.length; i++) {
    if (indices[i] instanceof NDArrayIndex.NDArrayIndexAll) {
      ret[i]=shape[i];
    }
 else {
      int[] currIndices=indices[i].indices();
      if (currIndices.length < 1)       continue;
      int end=currIndices[currIndices.length - 1];
      if (end > shape[i])       end=shape[i] - 1;
      int begin=currIndices[0];
      ret[i]=indices[i].isInterval() ? Math.abs(end - begin) + 1 : indices[i].indices().length;
    }
  }
  List<Integer> nonZeros=new ArrayList<>();
  for (int i=0; i < ret.length; i++) {
    if (ret[i] > 0)     nonZeros.add(ret[i]);
  }
  return ArrayUtil.toArray(nonZeros);
}

Fixed version (ground truth):
/** 
 * Calculate the shape for the given set of indices. <p/> The shape is defined as (for each dimension) the difference between the end index + 1 and the begin index <p/> If specified, this will check for whether any of the indices are >= to end - 1 and if so, prune it down
 * @param shape   the original shape
 * @param indices the indices to calculate the shape for
 * @return the shape for the given indices
 */
public static int[] shape(int[] shape,NDArrayIndex... indices){
  return shape(shape,new int[shape.length],indices);
}
Program: 3460
Project: 3460
Buggy source:
/** 
 * Flattens the array for linear indexing
 * @return the flattened version of this array
 */
@Override public IComplexNDArray ravel(){
  final IComplexNDArray ret=Nd4j.createComplex(length,ordering);
  final AtomicInteger counter=new AtomicInteger(0);
  SliceOp op=new SliceOp(){
    @Override public void operate(    INDArray nd){
      IComplexNDArray nd1=(IComplexNDArray)nd;
      for (int i=0; i < nd.length(); i++) {
        int element=counter.getAndIncrement();
        ret.putScalar(element,nd1.getComplex(i));
      }
    }
  }
;
  if (ordering == NDArrayFactory.C) {
    iterateOverAllRows(op);
  }
 else   if (ordering == NDArrayFactory.FORTRAN) {
    iterateOverAllColumns(op);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Flattens the array for linear indexing
 * @return the flattened version of this array
 */
@Override public IComplexNDArray ravel(){
  ensureNotCleanedUp();
  IComplexNDArray ret=Nd4j.createComplex(length,ordering);
  int dimension=shape.length == 2 ? 1 : shape.length;
  int count=0;
  for (int i=0; i < vectorsAlongDimension(dimension); i++) {
    IComplexNDArray vec=vectorAlongDimension(i,dimension);
    for (int j=0; j < vec.length(); j++) {
      ret.putScalar(count++,vec.getComplex(j));
    }
  }
  return ret;
}
Program: 3461
Project: 3461
Buggy source:
@Override public IComplexNDArray gemv(IComplexFloat alpha,IComplexNDArray a,IComplexNDArray x,IComplexFloat beta,IComplexNDArray y){
  DataTypeValidation.assertDouble(a,x,y);
  NativeBlas.cgemv('N',a.rows(),a.columns(),(ComplexFloat)alpha,a.data().asFloat(),a.blasOffset(),a.rows(),x.data().asFloat(),x.offset(),x.secondaryStride(),(ComplexFloat)beta,y.data().asFloat(),y.blasOffset(),y.secondaryStride());
  return y;
}

Fixed version (ground truth):
@Override public IComplexNDArray gemv(IComplexFloat alpha,IComplexNDArray a,IComplexNDArray x,IComplexFloat beta,IComplexNDArray y){
  DataTypeValidation.assertFloat(a,x,y);
  NativeBlas.cgemv('N',a.rows(),a.columns(),(ComplexFloat)alpha,a.data().asFloat(),a.blasOffset(),a.rows(),x.data().asFloat(),x.offset(),x.secondaryStride(),(ComplexFloat)beta,y.data().asFloat(),y.blasOffset(),y.secondaryStride());
  return y;
}
Program: 3462
Project: 3462
Buggy source:
/** 
 * Or over the whole ndarray given some condition
 * @param n
 * @param cond
 * @return
 */
public static boolean or(INDArray n,Condition cond){
  boolean ret=true;
  INDArray linear=n.linearView();
  for (int i=0; i < linear.length(); i++) {
    ret=ret || cond.apply(linear.getFloat(i));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Or over the whole ndarray given some condition
 * @param n
 * @param cond
 * @return
 */
public static boolean or(INDArray n,Condition cond){
  boolean ret=false;
  INDArray linear=n.linearView();
  for (int i=0; i < linear.length(); i++) {
    ret=ret || cond.apply(linear.getFloat(i));
  }
  return ret;
}
Program: 3463
Project: 3463
Buggy source:
@Override public float[] asFloat(){
  return new float[0];
}

Fixed version (ground truth):
@Override public float[] asFloat(){
  ensureNotFreed();
  return ArrayUtil.toFloats(asDouble());
}
Program: 3464
Project: 3464
Buggy source:
@Override public double[] asDouble(){
  ensureNotFreed();
  double[] ret=new double[length];
  Pointer p=Pointer.to(ret);
  JCublas.cublasGetVector(length,elementSize(),pointer(),1,p,1);
  return ret;
}

Fixed version (ground truth):
@Override public double[] asDouble(){
  ensureNotFreed();
  double[] ret=new double[length];
  JCuda.cudaMemcpy(Pointer.to(ret),pointer(),length * elementSize(),cudaMemcpyKind.cudaMemcpyDeviceToHost);
  return ret;
}
Program: 3465
Project: 3465
Buggy source:
@Override public float[] asFloat(){
  ensureNotFreed();
  float[] ret=new float[length];
  Pointer p=Pointer.to(ret);
  JCublas.cublasGetVector(length,elementSize(),pointer(),1,p,1);
  return ret;
}

Fixed version (ground truth):
@Override public float[] asFloat(){
  ensureNotFreed();
  float[] ret=new float[length];
  JCuda.cudaMemcpy(Pointer.to(ret),pointer(),length * elementSize(),cudaMemcpyKind.cudaMemcpyDeviceToHost);
  return ret;
}
Program: 3466
Project: 3466
Buggy source:
private void init(ReferenceQueue<INDArray> queue){
  this.queue=queue;
  setPriority(Thread.MAX_PRIORITY);
  setName("String_Node_Str");
  setDaemon(true);
}

Fixed version (ground truth):
private void init(ReferenceQueue<INDArray> queue){
  this.queue=queue;
  setPriority(Thread.MAX_PRIORITY);
  setName("String_Node_Str");
  setDaemon(true);
  ranFinals=new AtomicLong(-1);
}
Program: 3467
Project: 3467
Buggy source:
@Override public void run(){
  while (true) {
    Reference<INDArray> ref=(Reference<INDArray>)queue.poll();
    if (ref != null) {
      INDArray reffed=ref.get();
      reffed.data().removeReferencing(reffed.id());
      if (reffed.data().references().isEmpty()) {
        reffed.data().destroy();
        System.out.println("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    Reference<INDArray> ref=(Reference<INDArray>)queue.poll();
    runFinalize();
    if (ref != null) {
      INDArray reffed=ref.get();
      reffed.data().removeReferencing(reffed.id());
    }
  }
}