Pink Iguana

Home » Code » Reciprocal Square Root

Reciprocal Square Root


Reciprocal Square Root function code, here. Includes Quake 3 magic number hack.

#ifndef __FRSQRT_HH
#define __FRSQRT_HH
// Functions for the fast computation of reciprocal square roots
// by means of Newton iteration, e.g. compute a good initial
// guess and iterate up to desired precision.
// Optimisations for/by
//     Altivec   : USE_RSQRT_ALTIVEC
//     Lookup    : Lookup table approach by Ken Turkowski
//                 USE_RSQRT_LOOKUP
//     Magic No. : Magic numbers for initial guess
//                 USE_RSQRT_MAGIC
//     Fallback  : standard implementation via libm
//                 USE_RSQRT_LIBM
// If no manual override is specified, the optimisation is
// chosen automatically depending on available compiler.
// To initialise RSQRT, call init_rsqrt() first. Afterwards
// "rsqrtf" and "rsqrt" compute the reciprocal square root.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: