Files
WFR-UnitTests/iwir/coderepo/wavefront/atomic1.code
T
2017-04-11 15:49:55 +02:00

24 lines
826 B
Plaintext
Executable File

#define Idx2D(x, y) (x)*(N+1)+(y)
double* mat_a = sin->mat_a.getValue();
long chunksize = sin->chunksize.getValue();
long N = sin->N.getValue();
long i_min = sin->i.getValue();
long i_max = std::min(i_min + chunksize, 2*N-2);
//fprintf(stderr, "i = [%d, %d)\n", i_min, i_max);
for(long i=i_min; i<i_max; ++i) {
if(i<N) {
for(long j=1; j<=i; ++j) {
long x = i-j+1;
double old = mat_a[Idx2D(x, j)];
mat_a[Idx2D(x, j)] = 0.8*old + 0.2*0.25*mat_a[Idx2D(x-1, j)]*mat_a[Idx2D(x+1, j)]*mat_a[Idx2D(x, j-1)]*mat_a[Idx2D(x, j+1)];
}
} else {
for(long j=i-N+2; j<N; ++j) {
long x = i-j+1;
double old = mat_a[Idx2D(x, j)];
mat_a[Idx2D(x, j)] = 0.9*old + 0.1*0.25*mat_a[Idx2D(x-1, j)]*mat_a[Idx2D(x+1, j)]*mat_a[Idx2D(x, j-1)]*mat_a[Idx2D(x, j+1)];
}
}
}
sout->result.setValue(mat_a);