Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. void APM_Math()
  2. {
  3.     array_view<float, 1> Matrix_X(N, POSX), Matrix_Y(N, POSY), Matrix_R(N + N, POSR), AX(N, AX_M), AY(N, AY_M);
  4.     Matrix_R.discard_data();
  5.     parallel_for_each(
  6.         Matrix_R.extent, [=](index<1> first) restrict(amp) {
  7.         AX[first[0]] = 0; AY[first[0]] = 0;
  8.         for (int next = 0; next < N; next++) {
  9.             if ((first[0] != next) && ((Matrix_X[next] != Matrix_X[first[0]]) || (Matrix_Y[next] != Matrix_Y[first[0]]))) {
  10.                 int den;
  11.                 den = 100000 * fast_math::sqrt((Matrix_X[next] - Matrix_X[first[0]])*(Matrix_X[next] - Matrix_X[first[0]]) + (Matrix_Y[next] - Matrix_Y[first[0]])*(Matrix_Y[next] - Matrix_Y[first[0]]));
  12.                 AX[first[0]] += (Matrix_X[next] - Matrix_X[first[0]]) / den;
  13.                 AY[first[0]] += (Matrix_Y[next] - Matrix_Y[first[0]]) / den;
  14.             }
  15.         }
  16.         Matrix_R[first[0]] += AX[first[0]];
  17.         Matrix_R[first[0] + N] += AY[first[0]];
  18.     });
  19.     Matrix_R.synchronize();
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement