Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void APM_Math()
- {
- 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);
- Matrix_R.discard_data();
- parallel_for_each(
- Matrix_R.extent, [=](index<1> first) restrict(amp) {
- AX[first[0]] = 0; AY[first[0]] = 0;
- for (int next = 0; next < N; next++) {
- if ((first[0] != next) && ((Matrix_X[next] != Matrix_X[first[0]]) || (Matrix_Y[next] != Matrix_Y[first[0]]))) {
- int den;
- 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]]));
- AX[first[0]] += (Matrix_X[next] - Matrix_X[first[0]]) / den;
- AY[first[0]] += (Matrix_Y[next] - Matrix_Y[first[0]]) / den;
- }
- }
- Matrix_R[first[0]] += AX[first[0]];
- Matrix_R[first[0] + N] += AY[first[0]];
- });
- Matrix_R.synchronize();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement