From 04894949d2436bd5ccdd4179cf6a775cf187c523 Mon Sep 17 00:00:00 2001 From: Gonzalo Brito Gadeschi Date: Mon, 12 Aug 2024 10:46:20 -0700 Subject: [PATCH] all-pairs should not compute force against self --- src/all_pairs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/all_pairs.h b/src/all_pairs.h index fac5a9a..a5eddfb 100644 --- a/src/all_pairs.h +++ b/src/all_pairs.h @@ -18,6 +18,7 @@ void all_pairs_force(System& system) { auto ai = vec::splat(0); auto pi = s.x[i]; for (typename System::index_t j = 0; j < s.sz; j++) { + if (i == j) continue; auto pj = s.x[j]; ai += s.m[j] * (pj - pi) / dist3(pi, pj); }