
Calculate diff. of a matrix [X(2)X(1) X(3)X(2) ... X(n)X(n1)]
dukeleto Jun 11, 2009 7:15 AM (in response to Peterp)Hi Peter,
a gather array input with a normal output works just fine for this: I have higher order finite differences code working in exactly the same way.
For example:
kernel void compute_diff( double in_stream[], out double out_stream<> {
// get the index of the out stream being treated
int4 outpos = instance();
int xpos = outpos.x;
// compute the finite difference
out_stream = in_stream[xpos+1]  in_stream[xpos] ;
}
That's all there is to it; if you declare your receiving stream to be one shorter in length than the original matrix, you will have no problems with the last value. If both streams have the same length, you will need to deal with the last position in out_stream, either by calling the kernel on out_stream.domain() with the appropriate limit, or by using the kernel offset possibility in brook+1.4.
Regards,
Olivier

Calculate diff. of a matrix [X(2)X(1) X(3)X(2) ... X(n)X(n1)]
ryta1203 Jun 12, 2009 5:02 PM (in response to dukeleto)It seems there would be a good way to do this without using scatter or gather by rearranging your data.
