nus-yam/ex-repair huggingface dataset:
Program: 3350
Project: 3350
Buggy source:
/** 
 * Called at initialization in the static context. Registers cuda functions based on the cudafunctions.properties in the classpath
 * @throws IOException
 */
public static void register() throws Exception {
  ClassPathResource res=new ClassPathResource("String_Node_Str");
  if (!res.exists())   throw new IllegalStateException("String_Node_Str");
  Properties props=new Properties();
  props.load(res.getInputStream());
  KernelFunctionLoader.getInstance().load();
  String reduceFunctionsList=props.getProperty(REDUCE);
  for (  String function : reduceFunctionsList.split("String_Node_Str"))   reduceFunctions.add(function);
  SHARED_MEM=Integer.parseInt(props.getProperty(SHARED_MEM_KEY,"String_Node_Str"));
  THREADS=Integer.parseInt(props.getProperty(THREADS_KEY,"String_Node_Str"));
  BLOCKS=Integer.parseInt(props.getProperty(BLOCKS_KEY,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Called at initialization in the static context. Registers cuda functions based on the cudafunctions.properties in the classpath
 * @throws IOException
 */
public static void register() throws Exception {
  ClassPathResource res=new ClassPathResource("String_Node_Str",KernelFunctions.class.getClassLoader());
  if (!res.exists())   throw new IllegalStateException("String_Node_Str");
  Properties props=new Properties();
  props.load(res.getInputStream());
  KernelFunctionLoader.getInstance().load();
  String reduceFunctionsList=props.getProperty(REDUCE);
  for (  String function : reduceFunctionsList.split("String_Node_Str"))   reduceFunctions.add(function);
  SHARED_MEM=Integer.parseInt(props.getProperty(SHARED_MEM_KEY,"String_Node_Str"));
  THREADS=Integer.parseInt(props.getProperty(THREADS_KEY,"String_Node_Str"));
  BLOCKS=Integer.parseInt(props.getProperty(BLOCKS_KEY,"String_Node_Str"));
}
Program: 3351
Project: 3351
Buggy source:
@Override public Resource getConfigurationResource(){
  return new ClassPathResource(LINALG_PROPS);
}

Fixed version (ground truth):
@Override public Resource getConfigurationResource(){
  return new ClassPathResource(LINALG_PROPS,NetlibBlasBackend.class.getClassLoader());
}
Program: 3352
Project: 3352
Buggy source:
public static List<DataSet> loadIris(int from,int to) throws IOException {
  ClassPathResource resource=new ClassPathResource("String_Node_Str");
  @SuppressWarnings("String_Node_Str") List<String> lines=IOUtils.readLines(resource.getInputStream());
  List<DataSet> list=new ArrayList<>();
  INDArray ret=Nd4j.ones(Math.abs(to - from),4);
  double[][] outcomes=new double[lines.size()][3];
  int putCount=0;
  for (int i=from; i < to; i++) {
    String line=lines.get(i);
    String[] split=line.split("String_Node_Str");
    addRow(ret,putCount++,split);
    String outcome=split[split.length - 1];
    double[] rowOutcome=new double[3];
    rowOutcome[Integer.parseInt(outcome)]=1;
    outcomes[i]=rowOutcome;
  }
  for (int i=0; i < ret.rows(); i++)   list.add(new DataSet(ret.getRow(i),Nd4j.create(outcomes[from + i])));
  return list;
}

Fixed version (ground truth):
public static List<DataSet> loadIris(int from,int to) throws IOException {
  ClassPathResource resource=new ClassPathResource("String_Node_Str",IrisUtils.class.getClassLoader());
  @SuppressWarnings("String_Node_Str") List<String> lines=IOUtils.readLines(resource.getInputStream());
  List<DataSet> list=new ArrayList<>();
  INDArray ret=Nd4j.ones(Math.abs(to - from),4);
  double[][] outcomes=new double[lines.size()][3];
  int putCount=0;
  for (int i=from; i < to; i++) {
    String line=lines.get(i);
    String[] split=line.split("String_Node_Str");
    addRow(ret,putCount++,split);
    String outcome=split[split.length - 1];
    double[] rowOutcome=new double[3];
    rowOutcome[Integer.parseInt(outcome)]=1;
    outcomes[i]=rowOutcome;
  }
  for (int i=0; i < ret.rows(); i++)   list.add(new DataSet(ret.getRow(i),Nd4j.create(outcomes[from + i])));
  return list;
}
Program: 3353
Project: 3353
Buggy source:
@Override public Resource getConfigurationResource(){
  return new ClassPathResource(LINALG_PROPS);
}

Fixed version (ground truth):
@Override public Resource getConfigurationResource(){
  return new ClassPathResource(LINALG_PROPS,CpuBackend.class.getClassLoader());
}
Program: 3354
Project: 3354
Buggy source:
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  doReadObject(stream);
  copied=new HashMap<>();
  pointersToContexts=HashBasedTable.create();
  ref=new WeakReference<DataBuffer>(this,Nd4j.bufferRefQueue());
  freed=new AtomicBoolean(false);
}

Fixed version (ground truth):
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
  doReadObject(stream);
  copied=new HashMap<>();
  pointersToContexts=HashBasedTable.create();
  ref=new WeakReference<DataBuffer>(this,Nd4j.bufferRefQueue());
  freed=new AtomicBoolean(false);
}
Program: 3355
Project: 3355
Buggy source:
@Override protected int idamax(int N,INDArray X,int incX){
  return NativeBlas.idamax(N,getDoubleData(X),getBlasOffset(X),incX);
}

Fixed version (ground truth):
@Override protected int idamax(int N,INDArray X,int incX){
  return NativeBlas.idamax(N,getDoubleData(X),getBlasOffset(X),incX) - 1;
}
Program: 3356
Project: 3356
Buggy source:
@Override protected int icamax(int N,IComplexNDArray X,int incX){
  return NativeBlas.icamax(N,getFloatData(X),getBlasOffset(X),incX);
}

Fixed version (ground truth):
@Override protected int icamax(int N,IComplexNDArray X,int incX){
  return NativeBlas.icamax(N,getFloatData(X),getBlasOffset(X),incX) - 1;
}
Program: 3357
Project: 3357
Buggy source:
protected void doWriteObject(java.io.ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeUTF(allocationMode.name());
  out.writeLong(length());
  out.writeUTF(dataType().name());
  if (dataType() == Type.DOUBLE) {
    for (int i=0; i < length(); i++)     out.writeDouble(getDouble(i));
  }
 else {
    for (int i=0; i < length(); i++)     out.writeFloat(getFloat(i));
  }
  out.flush();
}

Fixed version (ground truth):
protected void doWriteObject(java.io.ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeUTF(allocationMode.name());
  out.writeInt(length());
  out.writeUTF(dataType().name());
  if (dataType() == Type.DOUBLE) {
    for (int i=0; i < length(); i++)     out.writeDouble(getDouble(i));
  }
 else {
    for (int i=0; i < length(); i++)     out.writeFloat(getFloat(i));
  }
  out.flush();
}
Program: 3358
Project: 3358
Buggy source:
/** 
 * Sync the device
 */
public static void sync(){
  JCuda.cudaDeviceSynchronize();
  ContextHolder.syncStream();
}

Fixed version (ground truth):
/** 
 * Sync the device
 */
public static void sync(){
  ContextHolder.syncStream();
}
Program: 3359
Project: 3359
Buggy source:
@Override protected void cdotc_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotc){
}

Fixed version (ground truth):
@Override protected void cdotc_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotc){
  throw new UnsupportedOperationException();
}
Program: 3360
Project: 3360
Buggy source:
@Override protected void zdotc_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotc){
}

Fixed version (ground truth):
@Override protected void zdotc_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotc){
  throw new UnsupportedOperationException();
}
Program: 3361
Project: 3361
Buggy source:
@Override protected void drotmg(double d1,double d2,double b1,double b2,INDArray P){
}

Fixed version (ground truth):
@Override protected void drotmg(double d1,double d2,double b1,double b2,INDArray P){
  throw new UnsupportedOperationException();
}
Program: 3362
Project: 3362
Buggy source:
@Override protected void drot(int N,INDArray X,int incX,INDArray Y,int incY,double c,double s){
}

Fixed version (ground truth):
@Override protected void drot(int N,INDArray X,int incX,INDArray Y,int incY,double c,double s){
  throw new UnsupportedOperationException();
}
Program: 3363
Project: 3363
Buggy source:
@Override protected void drotg(double a,double b,double c,double s){
}

Fixed version (ground truth):
@Override protected void drotg(double a,double b,double c,double s){
  throw new UnsupportedOperationException();
}
Program: 3364
Project: 3364
Buggy source:
@Override protected void srotm(int N,INDArray X,int incX,INDArray Y,int incY,INDArray P){
}

Fixed version (ground truth):
@Override protected void srotm(int N,INDArray X,int incX,INDArray Y,int incY,INDArray P){
  throw new UnsupportedOperationException();
}
Program: 3365
Project: 3365
Buggy source:
@Override protected void srotg(float a,float b,float c,float s){
}

Fixed version (ground truth):
@Override protected void srotg(float a,float b,float c,float s){
  throw new UnsupportedOperationException();
}
Program: 3366
Project: 3366
Buggy source:
@Override protected void srotmg(float d1,float d2,float b1,float b2,INDArray P){
}

Fixed version (ground truth):
@Override protected void srotmg(float d1,float d2,float b1,float b2,INDArray P){
  throw new UnsupportedOperationException();
}
Program: 3367
Project: 3367
Buggy source:
@Override protected double dsdot(int N,INDArray X,int incX,INDArray Y,int incY){
  return 0;
}

Fixed version (ground truth):
@Override protected double dsdot(int N,INDArray X,int incX,INDArray Y,int incY){
  throw new UnsupportedOperationException();
}
Program: 3368
Project: 3368
Buggy source:
@Override protected void drotm(int N,INDArray X,int incX,INDArray Y,int incY,INDArray P){
}

Fixed version (ground truth):
@Override protected void drotm(int N,INDArray X,int incX,INDArray Y,int incY,INDArray P){
  throw new UnsupportedOperationException();
}
Program: 3369
Project: 3369
Buggy source:
@Override protected void zdotu_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotu){
}

Fixed version (ground truth):
@Override protected void zdotu_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotu){
  throw new UnsupportedOperationException();
}
Program: 3370
Project: 3370
Buggy source:
@Override protected void srot(int N,INDArray X,int incX,INDArray Y,int incY,float c,float s){
}

Fixed version (ground truth):
@Override protected void srot(int N,INDArray X,int incX,INDArray Y,int incY,float c,float s){
  throw new UnsupportedOperationException();
}
Program: 3371
Project: 3371
Buggy source:
@Override protected float sdsdot(int N,float alpha,INDArray X,int incX,INDArray Y,int incY){
  return 0;
}

Fixed version (ground truth):
@Override protected float sdsdot(int N,float alpha,INDArray X,int incX,INDArray Y,int incY){
  throw new UnsupportedOperationException();
}
Program: 3372
Project: 3372
Buggy source:
@Override protected void cdotu_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotu){
}

Fixed version (ground truth):
@Override protected void cdotu_sub(int N,IComplexNDArray X,int incX,IComplexNDArray Y,int incY,IComplexNDArray dotu){
  throw new UnsupportedOperationException();
}
Program: 3373
Project: 3373
Buggy source:
/** 
 * Fetch a particular number on a multi dimensional scale.
 * @param indexes the indexes to get a number from
 * @return the number at the specified indices
 */
@Override public INDArray getScalar(int... indexes){
  int ix=offset;
  for (int i=0; i < indexes.length; i++) {
    ix+=indexes[i] * stride[i];
  }
  if (ix >= data.length())   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(indexes));
  return createScalar(data.getDouble(ix));
}

Fixed version (ground truth):
/** 
 * Fetch a particular number on a multi dimensional scale.
 * @param indexes the indexes to get a number from
 * @return the number at the specified indices
 */
@Override public INDArray getScalar(int... indexes){
  int ix=offset;
  for (int i=0; i < indexes.length; i++) {
    ix+=indexes[i] * stride[i];
  }
  if (ix >= data.length())   throw new IllegalArgumentException("String_Node_Str" + Arrays.toString(indexes));
  return createScalarForIndex(ix,false);
}
Program: 3374
Project: 3374
Buggy source:
/** 
 * Get the specified column
 * @param c
 */
@Override public INDArray getColumn(int c){
  ensureNotCleanedUp();
  if (shape.length == 2)   return vectorAlongDimension(c,0);
 else   if (isRowVector()) {
    return createScalar(getDouble(c));
  }
 else   if (isColumnVector() && c == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the specified column
 * @param c
 */
@Override public INDArray getColumn(int c){
  ensureNotCleanedUp();
  if (shape.length == 2)   return vectorAlongDimension(c,0);
 else   if (isRowVector()) {
    return createScalarForIndex(c,true);
  }
 else   if (isColumnVector() && c == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}
Program: 3375
Project: 3375
Buggy source:
/** 
 * Get a copy of a row.
 * @param r the row to get
 */
@Override public INDArray getRow(int r){
  ensureNotCleanedUp();
  if (shape.length == 2) {
    if (isColumnVector())     return createScalar(getDouble(r));
    return vectorAlongDimension(r,1);
  }
 else   if (size(0) == 1 && shape.length == 3) {
    return slice(0).vectorAlongDimension(r,1);
  }
 else   if (isRowVector() && r == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get a copy of a row.
 * @param r the row to get
 */
@Override public INDArray getRow(int r){
  ensureNotCleanedUp();
  if (shape.length == 2) {
    if (isColumnVector())     return createScalarForIndex(r,true);
    return vectorAlongDimension(r,1);
  }
 else   if (size(0) == 1 && shape.length == 3) {
    return slice(0).vectorAlongDimension(r,1);
  }
 else   if (isRowVector() && r == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}
Program: 3376
Project: 3376
Buggy source:
public int[] sliceStride(int slice){
  if (hasOneStride() && ordering() == NDArrayFactory.FORTRAN) {
    int[] ret=new int[stride.length - 1];
    Arrays.fill(ret,1);
    if (ordering() == NDArrayFactory.C) {
      int firstNon1=getFirstNonOneStrideIdx();
      int count=0;
      for (int i=firstNon1; i < stride.length; i++) {
        if (stride[i] > elementStride()) {
          ret[count++]=stride[i];
        }
      }
    }
 else {
      int firstNon1=getFirstNonOneStrideIdx();
      int count=0;
      for (int i=firstNon1; i < stride.length; i++) {
        if (stride[i] > elementStride()) {
          ret[count++]=stride[i];
        }
      }
    }
    return ret;
  }
  return Arrays.copyOfRange(stride,1,stride.length);
}

Fixed version (ground truth):
public int[] sliceStride(){
  if (hasOneStride() && ordering() == NDArrayFactory.FORTRAN) {
    int[] ret=new int[stride.length - 1];
    Arrays.fill(ret,1);
    if (ordering() == NDArrayFactory.C) {
      int firstNon1=getFirstNonOneStrideIdx();
      int count=0;
      for (int i=firstNon1; i < stride.length; i++) {
        if (stride[i] > elementStride()) {
          ret[count++]=stride[i];
        }
      }
    }
 else {
      int firstNon1=getFirstNonOneStrideIdx();
      int count=0;
      for (int i=firstNon1; i < stride.length; i++) {
        if (stride[i] > elementStride()) {
          ret[count++]=stride[i];
        }
      }
    }
    return ret;
  }
  return Arrays.copyOfRange(stride,1,stride.length);
}
Program: 3377
Project: 3377
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray diviRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place division of a row vector
 * @param rowVector the row vector used for division
 * @return the result of the division 
 */
INDArray diviRowVector(INDArray rowVector);
Program: 3378
Project: 3378
Buggy source:
/** 
 * In place reverse divison of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray rdiviColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * In place reverse divison of a column vector
 * @param columnVector the column vector used for division
 * @return the result of the division 
 */
INDArray rdiviColumnVector(INDArray columnVector);
Program: 3379
Project: 3379
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray rsubRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Reverse subtraction of a row vector (copy)
 * @param rowVector the row vector to subtract
 * @return the result of the subtraction
 */
INDArray rsubRowVector(INDArray rowVector);
Program: 3380
Project: 3380
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray muliColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * In place multiplication of a column vector
 * @param columnVector the column vector used for multiplication
 * @return the result of the multiplication
 */
INDArray muliColumnVector(INDArray columnVector);
Program: 3381
Project: 3381
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray rdiviRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place reverse division of a column vector
 * @param rowVector the row vector used for division
 * @return the result of the division 
 */
INDArray rdiviRowVector(INDArray rowVector);
Program: 3382
Project: 3382
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray divColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Division of a column vector (copy)
 * @param columnVector the column vector used for division
 * @return the result of the division 
 */
INDArray divColumnVector(INDArray columnVector);
Program: 3383
Project: 3383
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray addiRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place addition of a row vector
 * @param rowVector the row vector to add
 * @return the result of the addition
 */
INDArray addiRowVector(INDArray rowVector);
Program: 3384
Project: 3384
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray divRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Division of a row vector (copy)
 * @param rowVector the row vector used for division
 * @return the result of the division 
 */
INDArray divRowVector(INDArray rowVector);
Program: 3385
Project: 3385
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray rsubiColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * In place reverse subtraction of a column vector
 * @param columnVector the column vector to subtract
 * @return the result of the subtraction
 */
INDArray rsubiColumnVector(INDArray columnVector);
Program: 3386
Project: 3386
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray addColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Addition of a column vector (copy)
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray addColumnVector(INDArray columnVector);
Program: 3387
Project: 3387
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray mulColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Multiplication of a column vector (copy)
 * @param columnVector the column vector used for multiplication
 * @return the result of the multiplication
 */
INDArray mulColumnVector(INDArray columnVector);
Program: 3388
Project: 3388
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray subiRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place subtraction of a row vector
 * @param rowVector the row vector to subtract
 * @return the result of the subtraction
 */
INDArray subiRowVector(INDArray rowVector);
Program: 3389
Project: 3389
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray mulRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Multiplication of a row vector (copy)
 * @param rowVector the row vector used for multiplication
 * @return the result of the multiplication
 */
INDArray mulRowVector(INDArray rowVector);
Program: 3390
Project: 3390
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray addRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Addition of a row vector (copy)
 * @param rowVector the row vector to add
 * @return the result of the addition
 */
INDArray addRowVector(INDArray rowVector);
Program: 3391
Project: 3391
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray diviColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * In place division of a column vector
 * @param columnVector the column vector used for division
 * @return the result of the division 
 */
INDArray diviColumnVector(INDArray columnVector);
Program: 3392
Project: 3392
Buggy source:
/** 
 * In place reverse division of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray rdivColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Reverse division of a column vector (copy)
 * @param columnVector the column vector used for division
 * @return the result of the division 
 */
INDArray rdivColumnVector(INDArray columnVector);
Program: 3393
Project: 3393
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray rsubColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Reverse subtraction of a column vector (copy)
 * @param columnVector the column vector to subtract
 * @return the result of the subtraction
 */
INDArray rsubColumnVector(INDArray columnVector);
Program: 3394
Project: 3394
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray subiColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * In place subtraction of a column vector
 * @param columnVector the column vector to subtract
 * @return the result of the subtraction
 */
INDArray subiColumnVector(INDArray columnVector);
Program: 3395
Project: 3395
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray muliRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place multiplication of a row vector
 * @param rowVector the row vector used for multiplication
 * @return the result of the multiplication
 */
INDArray muliRowVector(INDArray rowVector);
Program: 3396
Project: 3396
Buggy source:
/** 
 * In place addition of a column vector
 * @param columnVector the column vector to add
 * @return the result of the addition
 */
INDArray subColumnVector(INDArray columnVector);

Fixed version (ground truth):
/** 
 * Subtraction of a column vector (copy)
 * @param columnVector the column vector to subtract
 * @return the result of the subtraction
 */
INDArray subColumnVector(INDArray columnVector);
Program: 3397
Project: 3397
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray subRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Subtraction of a row vector (copy)
 * @param rowVector the row vector to subtract
 * @return the result of the subtraction
 */
INDArray subRowVector(INDArray rowVector);
Program: 3398
Project: 3398
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray rdivRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * Reverse division of a column vector (copy)
 * @param rowVector the row vector used for division
 * @return the result of the division 
 */
INDArray rdivRowVector(INDArray rowVector);
Program: 3399
Project: 3399
Buggy source:
/** 
 * In place addition of a column vector
 * @param rowVector the column vector to add
 * @return the result of the addition
 */
INDArray rsubiRowVector(INDArray rowVector);

Fixed version (ground truth):
/** 
 * In place reverse subtraction of a row vector
 * @param rowVector the row vector to subtract
 * @return the result of the subtraction
 */
INDArray rsubiRowVector(INDArray rowVector);
Program: 3400
Project: 3400
Buggy source:
/** 
 * Compute the linear offset for an index in an ndarray. For c ordering this is just the index itself. For fortran ordering, the following algorithm is used. Assuming an ndarray is a list of vectors. The index of the vector relative to the given index is calculated. vectorAlongDimension is then used along the last dimension using the computed index. The offset + the computed column wrt the index: (index % the size of the last dimension) will render the given index in fortran ordering
 * @param index the index
 * @param arr the array
 * @return the linear offset
 */
public static int linearOffset(int index,INDArray arr){
  if (arr.ordering() == NDArrayFactory.C) {
    double otherTest=Double.valueOf(index) % Double.valueOf(arr.size(-1));
    int test=(int)Math.floor(otherTest);
    INDArray vec=arr.vectorAlongDimension(test,-1);
    int otherDim=arr.vectorAlongDimension(test,-1).offset() + index;
    return otherDim;
  }
 else {
    int majorStride=arr.stride(-2);
    int vectorsAlongDimension=arr.vectorsAlongDimension(-1);
    double rowCalc=(double)(index * majorStride) / (double)arr.length();
    int floor=(int)Math.floor(rowCalc);
    INDArray arrVector=arr.vectorAlongDimension(floor,-1);
    int columnIndex=index % arr.size(-1);
    int retOffset=arrVector.linearIndex(columnIndex);
    return retOffset;
  }
}

Fixed version (ground truth):
/** 
 * Compute the linear offset for an index in an ndarray. For c ordering this is just the index itself. For fortran ordering, the following algorithm is used. Assuming an ndarray is a list of vectors. The index of the vector relative to the given index is calculated. vectorAlongDimension is then used along the last dimension using the computed index. The offset + the computed column wrt the index: (index % the size of the last dimension) will render the given index in fortran ordering
 * @param index the index
 * @param arr the array
 * @return the linear offset
 */
public static int linearOffset(int index,INDArray arr){
  if (arr.ordering() == NDArrayFactory.C) {
    double otherTest=((double)index) % arr.size(-1);
    int test=(int)Math.floor(otherTest);
    INDArray vec=arr.vectorAlongDimension(test,-1);
    int otherDim=arr.vectorAlongDimension(test,-1).offset() + index;
    return otherDim;
  }
 else {
    int majorStride=arr.stride(-2);
    int vectorsAlongDimension=arr.vectorsAlongDimension(-1);
    double rowCalc=(double)(index * majorStride) / (double)arr.length();
    int floor=(int)Math.floor(rowCalc);
    INDArray arrVector=arr.vectorAlongDimension(floor,-1);
    int columnIndex=index % arr.size(-1);
    int retOffset=arrVector.linearIndex(columnIndex);
    return retOffset;
  }
}
Program: 3401
Project: 3401
Buggy source:
/** 
 * Compute the linear offset for an index in an ndarray. For c ordering this is just the index itself. For fortran ordering, the following algorithm is used. Assuming an ndarray is a list of vectors. The index of the vector relative to the given index is calculated. vectorAlongDimension is then used along the last dimension using the computed index. The offset + the computed column wrt the index: (index % the size of the last dimension) will render the given index in fortran ordering
 * @param index the index
 * @param arr the array
 * @return the linear offset
 */
public static int rowNumber(int index,INDArray arr){
  double otherTest=Double.valueOf(index) / Double.valueOf(arr.size(-1));
  int test=(int)Math.floor(otherTest);
  int vectors=arr.vectorsAlongDimension(-1);
  if (test >= vectors)   return vectors - 1;
  return test;
}

Fixed version (ground truth):
/** 
 * Compute the linear offset for an index in an ndarray. For c ordering this is just the index itself. For fortran ordering, the following algorithm is used. Assuming an ndarray is a list of vectors. The index of the vector relative to the given index is calculated. vectorAlongDimension is then used along the last dimension using the computed index. The offset + the computed column wrt the index: (index % the size of the last dimension) will render the given index in fortran ordering
 * @param index the index
 * @param arr the array
 * @return the linear offset
 */
public static int rowNumber(int index,INDArray arr){
  double otherTest=((double)index) / arr.size(-1);
  int test=(int)Math.floor(otherTest);
  int vectors=arr.vectorsAlongDimension(-1);
  if (test >= vectors)   return vectors - 1;
  return test;
}
Program: 3402
Project: 3402
Buggy source:
/** 
 * Compute A <- alpha * x * y^T + A (general rank-1 update)
 */
@Override public INDArray ger(float alpha,INDArray x,INDArray y,INDArray a){
  DataTypeValidation.assertFloat(x,y,a);
  NativeBlas.sger(a.rows(),a.columns(),alpha,x.data().asFloat(),x.offset(),x.majorStride(),y.data().asFloat(),y.offset(),y.majorStride(),a.data().asFloat(),a.offset(),a.rows());
  return a;
}

Fixed version (ground truth):
/** 
 * Compute A <- alpha * x * y^T + A (general rank-1 update)
 */
@Override public INDArray ger(float alpha,INDArray x,INDArray y,INDArray a){
  if (x.data().dataType() == DataBuffer.Type.DOUBLE) {
    return ger((double)alpha,x,y,a);
  }
  DataTypeValidation.assertFloat(x,y,a);
  NativeBlas.sger(a.rows(),a.columns(),alpha,x.data().asFloat(),x.offset(),x.majorStride(),y.data().asFloat(),y.offset(),y.majorStride(),a.data().asFloat(),a.offset(),a.rows());
  return a;
}
Program: 3403
Project: 3403
Buggy source:
@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");
    }
  }
  if (isRowVector()) {
    offsets[0]=0;
  }
  int offset=this.offset + ArrayUtil.dotProduct(offsets,this.stride);
  if (ordering() == NDArrayFactory.C) {
    return create(data,Arrays.copyOf(shape,shape.length),ArrayUtil.reverseCopy(stride),offset,ordering);
  }
 else   if (ordering() == NDArrayFactory.FORTRAN) {
    return create(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
  }
  throw new IllegalStateException("String_Node_Str");
}

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");
    }
  }
  boolean adjustOffsets=false;
  if (offsets.length > 1 && Shape.isRowVectorShape(shape) && offsets[0] > 0) {
    for (int i=1; i < offsets.length; i++) {
      if (offsets[i] == 0) {
        adjustOffsets=true;
        break;
      }
    }
    if (adjustOffsets) {
      for (int i=1; i < offsets.length; i++) {
        if (offsets[i] < 1)         offsets[i]=1;
      }
    }
  }
  int offset=this.offset + ArrayUtil.dotProduct(offsets,this.stride);
  if (adjustOffsets)   offset--;
  if (ordering() == NDArrayFactory.C) {
    return create(data,Arrays.copyOf(shape,shape.length),ArrayUtil.reverseCopy(stride),offset,ordering);
  }
 else   if (ordering() == NDArrayFactory.FORTRAN) {
    return create(data,Arrays.copyOf(shape,shape.length),stride,offset,ordering);
  }
  throw new IllegalStateException("String_Node_Str");
}
Program: 3405
Project: 3405
Buggy source:
@Override public IComplexNDArray gemm(IComplexNumber alpha,IComplexNDArray a,IComplexNDArray b,IComplexNumber beta,IComplexNDArray c){
  DataTypeValidation.assertSameDataType(a,b,c);
  if (a.data().dataType() == DataBuffer.Type.FLOAT)   NativeBlas.cgemm('N','N',c.rows(),c.columns(),a.columns(),new ComplexFloat(alpha.realComponent().floatValue(),alpha.imaginaryComponent().floatValue()),a.data().asFloat(),a.blasOffset(),a.size(0),b.data().asFloat(),b.blasOffset(),b.size(0),new ComplexFloat(beta.realComponent().floatValue(),beta.imaginaryComponent().floatValue()),c.data().asFloat(),c.blasOffset(),c.size(0));
 else   NativeBlas.zgemm('N','N',c.rows(),c.columns(),a.columns(),new ComplexDouble(alpha.realComponent().floatValue(),alpha.imaginaryComponent().floatValue()),a.data().asDouble(),a.blasOffset(),a.size(0),b.data().asDouble(),b.blasOffset(),b.size(0),new ComplexDouble(beta.realComponent().floatValue(),beta.imaginaryComponent().floatValue()),c.data().asDouble(),c.blasOffset(),c.size(0));
  return c;
}

Fixed version (ground truth):
@Override public IComplexNDArray gemm(IComplexNumber alpha,IComplexNDArray a,IComplexNDArray b,IComplexNumber beta,IComplexNDArray c){
  DataTypeValidation.assertSameDataType(a,b,c);
  if (a.data().dataType() == DataBuffer.Type.FLOAT)   NativeBlas.cgemm('N','N',c.rows(),c.columns(),a.columns(),new ComplexFloat(alpha.realComponent().floatValue(),alpha.imaginaryComponent().floatValue()),a.data().asFloat(),a.offset() / 2,a.size(0),b.data().asFloat(),b.offset() / 2,b.size(0),new ComplexFloat(beta.realComponent().floatValue(),beta.imaginaryComponent().floatValue()),c.data().asFloat(),c.offset() / 2,c.size(0));
 else   NativeBlas.zgemm('N','N',c.rows(),c.columns(),a.columns(),new ComplexDouble(alpha.realComponent().floatValue(),alpha.imaginaryComponent().floatValue()),a.data().asDouble(),a.offset() / 2,a.size(0),b.data().asDouble(),b.offset() / 2,b.size(0),new ComplexDouble(beta.realComponent().floatValue(),beta.imaginaryComponent().floatValue()),c.data().asDouble(),c.offset() / 2,c.size(0));
  return c;
}
Program: 3407
Project: 3407
Buggy source:
@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)   return create(data,Arrays.copyOf(shape,shape.length),ArrayUtil.reverseCopy(stride),offset,ordering);
  return 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");
    }
  }
  if (isRowVector()) {
    offsets[0]=0;
  }
  int offset=this.offset + ArrayUtil.dotProduct(offsets,this.stride);
  if (ordering() == NDArrayFactory.C)   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: 3408
Project: 3408
Buggy source:
/** 
 * The offsets (begin index) for each index
 * @param indices the indices
 * @return the offsets for the given set of indices
 */
public static int[] offsets(NDArrayIndex... indices){
  int[] ret=new int[indices.length];
  for (int i=0; i < indices.length; i++) {
    int offset=indices[i].offset();
    if (offset == 0 && i > 0 && i < indices.length - 1)     ret[i]=1;
 else     ret[i]=indices[i].offset();
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * The offsets (begin index) for each index
 * @param indices the indices
 * @return the offsets for the given set of indices
 */
public static int[] offsets(NDArrayIndex... indices){
  int[] ret=new int[indices.length];
  for (int i=0; i < indices.length; i++) {
    int offset=indices[i].offset();
    if (offset == 0 && i > 0 && i < indices.length - 1)     ret[i]=1;
 else     ret[i]=indices[i].offset();
  }
  if (ret.length == 1) {
    ret=new int[]{1,ret[0]};
  }
  return ret;
}
Program: 3409
Project: 3409
Buggy source:
/** 
 * Prunes indices of greater length than the shape and fills in missing indices if there are any
 * @param originalShape the original shape to adjust to
 * @param indexes       the indexes to adjust
 * @return the  adjusted indices
 */
public static NDArrayIndex[] adjustIndices(int[] originalShape,NDArrayIndex... indexes){
  if (indexes.length < originalShape.length)   indexes=fillIn(originalShape,indexes);
  if (indexes.length > originalShape.length) {
    NDArrayIndex[] ret=new NDArrayIndex[originalShape.length];
    System.arraycopy(indexes,0,ret,0,originalShape.length);
    return ret;
  }
  if (indexes.length == originalShape.length)   return indexes;
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i].end() >= originalShape[i] || indexes[i] instanceof NDArrayIndex.NDArrayIndexAll)     indexes[i]=NDArrayIndex.interval(0,originalShape[i] - 1);
  }
  return indexes;
}

Fixed version (ground truth):
/** 
 * Prunes indices of greater length than the shape and fills in missing indices if there are any
 * @param originalShape the original shape to adjust to
 * @param indexes       the indexes to adjust
 * @return the  adjusted indices
 */
public static NDArrayIndex[] adjustIndices(int[] originalShape,NDArrayIndex... indexes){
  if (Shape.isVector(originalShape) && indexes.length == 1)   return indexes;
  if (indexes.length < originalShape.length)   indexes=fillIn(originalShape,indexes);
  if (indexes.length > originalShape.length) {
    NDArrayIndex[] ret=new NDArrayIndex[originalShape.length];
    System.arraycopy(indexes,0,ret,0,originalShape.length);
    return ret;
  }
  if (indexes.length == originalShape.length)   return indexes;
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i].end() >= originalShape[i] || indexes[i] instanceof NDArrayIndex.NDArrayIndexAll)     indexes[i]=NDArrayIndex.interval(0,originalShape[i] - 1);
  }
  return indexes;
}
Program: 3410
Project: 3410
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[]{1,stride[0]},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 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);
}
Program: 3411
Project: 3411
Buggy source:
/** 
 * Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions. <p/> See theano for more examples. This will only accept integers and xs. <p/> An x indicates a dimension should be broadcasted rather than permuted.
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public IComplexNDArray dimShuffle(Object[] rearrange,int[] newOrder,boolean[] broadCastable){
}

Fixed version (ground truth):
/** 
 * Dimshuffle: an extension of permute that adds the ability to broadcast various dimensions. <p/> See theano for more examples. This will only accept integers and xs. <p/> An x indicates a dimension should be broadcasted rather than permuted.
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public IComplexNDArray dimShuffle(Object[] rearrange,int[] newOrder,boolean[] broadCastable){
  return (IComplexNDArray)super.dimShuffle(rearrange,newOrder,broadCastable);
}
Program: 3412
Project: 3412
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 IComplexNDArray slice(int slice,int dimension){
  int offset=this.offset + dimension * stride[slice];
  if (slice == 0)   return slice(dimension);
  return Nd4j.createComplex(data,ArrayUtil.removeIndex(shape,dimension),ArrayUtil.removeIndex(stride,dimension),offset,ordering);
}

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 IComplexNDArray slice(int slice,int dimension){
  return (IComplexNDArray)super.slice(slice,dimension);
}
Program: 3413
Project: 3413
Buggy source:
/** 
 * Get the specified column
 * @param c
 */
@Override public IComplexNDArray getColumn(int c){
  if (shape.length == 2) {
    if (ordering == NDArrayFactory.C) {
      IComplexNDArray ret=Nd4j.createComplex(data,new int[]{shape[0]},new int[]{stride[0]},offset + (c * 2),ordering);
      return ret;
    }
 else {
      IComplexNDArray ret=Nd4j.createComplex(data,new int[]{shape[0]},new int[]{stride[0]},offset + (c * 2),ordering);
      return ret;
    }
  }
 else   if (isColumnVector() && c == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the specified column
 * @param c
 */
@Override public IComplexNDArray getColumn(int c){
  return (IComplexNDArray)super.getColumn(c);
}
Program: 3414
Project: 3414
Buggy source:
/** 
 * Get a copy of a row.
 * @param r
 */
@Override public IComplexNDArray getRow(int r){
  if (shape.length == 2) {
    if (ordering == NDArrayFactory.C) {
      IComplexNDArray ret=Nd4j.createComplex(data,new int[]{shape[1]},new int[]{stride[1]},offset + (r * 2) * columns(),ordering);
      return ret;
    }
 else {
      IComplexNDArray ret=Nd4j.createComplex(data,new int[]{shape[1]},new int[]{stride[1]},offset + (r * 2),ordering);
      return ret;
    }
  }
 else   if (isRowVector() && r == 0)   return this;
 else   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get a copy of a row.
 * @param r
 */
@Override public IComplexNDArray getRow(int r){
  return (IComplexNDArray)super.getRow(r);
}
Program: 3415
Project: 3415
Buggy source:
/** 
 * See: http://www.mathworks.com/help/matlab/ref/permute.html
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public IComplexNDArray permute(int[] rearrange){
  if (rearrange.length < shape.length)   return dup();
  checkArrangeArray(rearrange);
  int[] newDims=doPermuteSwap(shape,rearrange);
  int[] newStrides=doPermuteSwap(stride,rearrange);
  IComplexNDArray ret=Nd4j.createComplex(data,newDims,newStrides,offset,ordering);
  return ret;
}

Fixed version (ground truth):
/** 
 * See: http://www.mathworks.com/help/matlab/ref/permute.html
 * @param rearrange the dimensions to swap to
 * @return the newly permuted array
 */
@Override public IComplexNDArray permute(int[] rearrange){
  return (IComplexNDArray)super.permute(rearrange);
}