HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_ISqrt.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT library (C++)
7  *
8  * COMMENTS: Fast lookup to get integer square roots. The square roots
9  * will round, thus UTisqrt(3) = 2, UTisqrt(2) = 1
10  * The table is good for positive integers up to 1024
11  *
12  */
13 
14 #ifndef __UT_ISqrt_h__
15 #define __UT_ISqrt_h__
16 
17 #include "UT_API.h"
18 #include <SYS/SYS_Types.h>
19 
20 #define MAX_ISQRT 1024
21 
22 UT_API extern int UTisqrtTable[];
23 UT_API extern float UTinvSqrtTable[];
24 
25 UT_API unsigned int UTbigISqrt(unsigned int val);
26 
27 inline int UTisqrtFast(unsigned val) { return UTisqrtTable[val]; }
28 inline float UTinverseSqrtFast(unsigned val) { return UTinvSqrtTable[val]; }
29 
30 inline int
31 UTisqrt(unsigned val)
32 {
33  return val <= MAX_ISQRT ? UTisqrtTable[val] : UTbigISqrt(val);
34 }
35 
36 inline float
37 UTinverseSqrt(unsigned val)
38 {
39  return val <= MAX_ISQRT ? UTinvSqrtTable[val]
40  : 1.0F/(float)UTbigISqrt(val);
41 }
42 
43 #endif
#define MAX_ISQRT
Definition: UT_ISqrt.h:20
UT_API float UTinvSqrtTable[]
int UTisqrtFast(unsigned val)
Definition: UT_ISqrt.h:27
#define UT_API
Definition: UT_API.h:12
UT_API unsigned int UTbigISqrt(unsigned int val)
UT_API int UTisqrtTable[]
GLuint GLfloat * val
Definition: glcorearb.h:1607
float UTinverseSqrt(unsigned val)
Definition: UT_ISqrt.h:37
float UTinverseSqrtFast(unsigned val)
Definition: UT_ISqrt.h:28
int UTisqrt(unsigned val)
Definition: UT_ISqrt.h:31