From dfacb30ddd36ef0c2b354f581b83d7578ce2a72b Mon Sep 17 00:00:00 2001 From: Achmad Imam Kistijantoro <imam@informatika.org> Date: Tue, 11 Dec 2018 16:01:44 +0700 Subject: [PATCH] Upload New File --- check.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 check.h diff --git a/check.h b/check.h new file mode 100644 index 0000000..c07ef0f --- /dev/null +++ b/check.h @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <math.h> + +void checkAccuracy(float *p, int nBodies) +{ + if (nBodies != 2<<11) return; + + // Assuming N is set to 11, the x y and z coordinates of a particle + // (chosen at random) should + // equal the following values: + + // -11.943975 + // 3.198896 + // 10.517184 + + int position1IsCorrect = ( (int)(p[9*6]) ) == -11; + int position2IsCorrect = ( (int)(p[(9*6) + 1] ) == 3); + int position3IsCorrect = ( (int)(p[(9*6) + 2] ) == 10); + int positionsAreCorrect = (position1IsCorrect == 1) && (position2IsCorrect == 1) && (position3IsCorrect == 1); + + printf("%s\n", positionsAreCorrect + ? "Simulator is calculating positions correctly." + : "Simulator is not calculating positions correctly."); + + return; +} -- GitLab