float e;
int main(int argc, char *argv[]) {
int n = ...;
float *x, *y;
x = new float[n+1];
y = new float[n+1];
... // fill x, y
// do computation e = 0;
#pragma omp for reduction(+:e)
for (int i=1; i<n; ++i) {
x[i] += ( y[i+1] + y[i-1] )*.5;
e += y[i] * y[i];
}
... // output x, e
delete[] x, y;
return 0;
}
|