1 Reply Latest reply on Apr 30, 2009 6:56 AM by gaurav.garg

    Iterate over every row and calculate diff between two elements

    Peterp

      Hi,

      i have a 2D Matrix and i want to iterate through every row starting at the 0th element in every row and calculate something. My code is not working, i think i don't adress the 0th element correct

      kernel void calculateMatrix2D(int d2, double speed,

      double in1[][],double in2[][],

      out double out3[][])

      {

      int index = instance().y;

      const int row_length = dim2-1;

      double temp;

      int i;

      if(index==0)

      {

      for(i = 0;i<row_length;i++)

      {

      temp = speed * (in1[index][i+1]-in1[index]);

      out3[index] = in1[index]+temp;

      out3[index][i+1] = in1[index][i+1]-temp;

      }

      }

      }