// // This file is part of the Bones source-to-source compiler examples. This C-code // example is meant to illustrate the use of Bones. For more information on Bones // use the contact information below. // // == More information on Bones // Contact............Cedric Nugteren // Web address........http://parse.ele.tue.nl/bones/ // // == File information // Filename...........neighbourhood/example2.c // Author.............Cedric Nugteren // Last modified on...16-April-2012 // #include #define A 256 #define B 512 // This is 'example2', demonstrating a 2D array, a 2D neighbourhood and a for-loop-less notation of the neighbourhood accesses int main(void) { int i,j; // Declare input/output arrays float in[A][B]; float out[A][B]; // Set the input data for(i=0;i 0:255,0:511|element for(i=0;i= 1 && j >= 1 && i < (A-1) && j < (B-1)) { out[i][j] = (in[i+1][j+1] + in[i+1][ j ] + in[i+1][j-1] + in[ i ][j+1] + in[ i ][ j ] + in[ i ][j-1] + in[i-1][j+1] + in[i-1][ j ] + in[i-1][j-1])/9.0; } else { out[i][j] = in[i][j]; } } } #pragma species endkernel example2 // Clean-up and exit the function fflush(stdout); return 0; }