<commit_before>#include <pal.h>

/**
 *
 * Calculates the inverse square root of the input vector 'a'.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with 
 **
 * @return      None
 *
 */
#include <math.h>
void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team)
{
    int i;
    for (i = 0; i < n; i++) {
        *(c + i) = 1.0f / sqrtf(*(a + i));
    }
}<commit_msg>Implement faster inverse square root function<commit_after>#include <pal.h>

/**
 *
 * Calculates the inverse square root of the input vector 'a'.
 *
 * This function uses a method of computing the inverse square root
 * made popular by the Quake 3 source code release. <NAME> has
 * provided an exhaustive analysis here: 
 * http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with 
 **
 * @return      None
 *
 */
#include <math.h>
void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team)
{
    // This union allows us to type-pun between integers and floats
    // with fewer strict aliasing concerns than the pointer casts
    // used in the original source.
    union
    {
        int32_t i;
        float f;
    } u;

    int i;
    for (i = 0; i < n; i++) {
        float x = *(a + i);
        float x2 = x * 0.5f;

        // Use some bit hacks to get a decent first approximation
        u.f = x;
        u.i = 0x5f375a86 - (u.i >> 1);
        x = u.f;

        // Perform a couple steps of Newton's method to refine our guess
        x = x * (1.5f - (x2 * x * x));
        x = x * (1.5f - (x2 * x * x));

        *(c + i) = x;
    }
}
{'fraction_non_alphanumeric': 0.12340642529321774, 'fraction_numerical': 0.01631820499745028, 'mean_word_length': 2.1044303797468356, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5860535', 'n_tokens_mistral': 700, 'n_tokens_neox': 667, 'n_words': 262}