cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Peterp
Journeyman III

Iterate over every row and calculate diff between two elements

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;

}

}

}

0 Likes
1 Reply
gaurav_garg
Adept I

instance().y points to the row number of kernel instance. So, looking at your code it sems that your are working on first row and not first column as you wanted to do.

0 Likes