10 #include "tinyMathFunction.h"
12 #define INVSQRT_NEWTON_METHOD_NUM (2)
26 float tInvSqrt(
float x) {
27 float halfx = 0.5f * x;
30 i = 0x5f3759df - (i >> 1);
33 for (i = 0; i < INVSQRT_NEWTON_METHOD_NUM; i++)
35 y = y * (1.5f - (halfx * y * y));
51 float halfx = 0.5f * x;
55 if (x == 0.0f)
return 0.0f;
59 i = 0x5f3759df - (i >> 1);
62 y = y * (1.5f - (halfx * y * y));
63 y = y * (1.5f - (halfx * y * y));
64 y = y * (1.5f - (halfx * y * y));
80 void quickSort(
int numbers[],
int left,
int right)
82 int pivot, l_hold, r_hold;
86 pivot = numbers[left];
89 while ((numbers[right] >= pivot) && (left < right))
93 numbers[left] = numbers[right];
96 while ((numbers[left] <= pivot) && (left < right))
100 numbers[right] = numbers[left];
104 numbers[left] = pivot;
109 quickSort(numbers, left, pivot-1);
111 quickSort(numbers, pivot+1, right);