Skip to content

Commit 95e6308

Browse files
Fixed bugs + added rsqrt
1 parent f4f6bb1 commit 95e6308

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/gravity/octree.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "../struct/particle.h"
33
#include <vector>
44

5-
65
// =========================
76
// Octree definition
87
// =========================
@@ -90,6 +89,12 @@ struct Octree {
9089
}
9190
};
9291

92+
inline float rsqrt(float x) {
93+
float y = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x)));
94+
// optional refinement:
95+
return y * (1.5f - 0.5f * x * y * y);
96+
}
97+
9398
// =========================
9499
// Barnes–Hut force function
95100
// =========================

0 commit comments

Comments
 (0)