1 Reply Latest reply on Feb 4, 2008 7:59 AM by 807603

    Conversion from 1D array to 2D array

    807603
      Hi,

      Below is my code to convert 1D array to 2D array.
      Can any one let me know whether i am correct or wrong.
      If wrong where am i going wrong?

      public static float [][] OneDToTwoD(float oneD[]){
      int i = 0;
      int j = 0;
      int k = 0;

      int N = oneD.length;
      for(k = 0; k < oneD.length; k++){           
      if(k < ngridx && k < ngridy && k < i){
      array2D[i][j] = oneD[k];
      if (j < Math.sqrt(N) ){
      j++;
      }//if
      else if(j >Math.sqrt(N) ) {
      j = 0;
      i++;
      }//else
      }
      }//for k
      return(array2D);
      }//OneDToTwoD

      Thanks & Regards