aboutsummaryrefslogtreecommitdiff
path: root/sp/src/mathlib/powsse.cpp
diff options
context:
space:
mode:
authorJørgen P. Tjernø <[email protected]>2013-12-02 19:31:46 -0800
committerJørgen P. Tjernø <[email protected]>2013-12-02 19:46:31 -0800
commitf56bb35301836e56582a575a75864392a0177875 (patch)
treede61ddd39de3e7df52759711950b4c288592f0dc /sp/src/mathlib/powsse.cpp
parentMark some more files as text. (diff)
downloadsource-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz
source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/mathlib/powsse.cpp')
-rw-r--r--sp/src/mathlib/powsse.cpp192
1 files changed, 96 insertions, 96 deletions
diff --git a/sp/src/mathlib/powsse.cpp b/sp/src/mathlib/powsse.cpp
index 111f8d24..b026c642 100644
--- a/sp/src/mathlib/powsse.cpp
+++ b/sp/src/mathlib/powsse.cpp
@@ -1,96 +1,96 @@
-//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=====================================================================================//
-
-#include "mathlib/ssemath.h"
-
-// NOTE: This has to be the last file included!
-#include "tier0/memdbgon.h"
-
-
-fltx4 Pow_FixedPoint_Exponent_SIMD( const fltx4 & x, int exponent)
-{
- fltx4 rslt=Four_Ones; // x^0=1.0
- int xp=abs(exponent);
- if (xp & 3) // fraction present?
- {
- fltx4 sq_rt=SqrtEstSIMD(x);
- if (xp & 1) // .25?
- rslt=SqrtEstSIMD(sq_rt); // x^.25
- if (xp & 2)
- rslt=MulSIMD(rslt,sq_rt);
- }
- xp>>=2; // strip fraction
- fltx4 curpower=x; // curpower iterates through x,x^2,x^4,x^8,x^16...
-
- while(1)
- {
- if (xp & 1)
- rslt=MulSIMD(rslt,curpower);
- xp>>=1;
- if (xp)
- curpower=MulSIMD(curpower,curpower);
- else
- break;
- }
- if (exponent<0)
- return ReciprocalEstSaturateSIMD(rslt); // pow(x,-b)=1/pow(x,b)
- else
- return rslt;
-}
-
-
-
-
-/*
- * (c) Ian Stephenson
- *
- *
- * Fast pow() reference implementation
- */
-
-
-static float shift23=(1<<23);
-static float OOshift23=1.0/(1<<23);
-
-float FastLog2(float i)
-{
- float LogBodge=0.346607f;
- float x;
- float y;
- x=*(int *)&i;
- x*= OOshift23; //1/pow(2,23);
- x=x-127;
-
- y=x-floorf(x);
- y=(y-y*y)*LogBodge;
- return x+y;
-}
-float FastPow2(float i)
-{
- float PowBodge=0.33971f;
- float x;
- float y=i-floorf(i);
- y=(y-y*y)*PowBodge;
-
- x=i+127-y;
- x*= shift23; //pow(2,23);
- *(int*)&x=(int)x;
- return x;
-}
-float FastPow(float a, float b)
-{
- if (a <= OOshift23)
- {
- return 0.0f;
- }
- return FastPow2(b*FastLog2(a));
-}
-float FastPow10( float i )
-{
- return FastPow2( i * 3.321928f );
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=====================================================================================//
+
+#include "mathlib/ssemath.h"
+
+// NOTE: This has to be the last file included!
+#include "tier0/memdbgon.h"
+
+
+fltx4 Pow_FixedPoint_Exponent_SIMD( const fltx4 & x, int exponent)
+{
+ fltx4 rslt=Four_Ones; // x^0=1.0
+ int xp=abs(exponent);
+ if (xp & 3) // fraction present?
+ {
+ fltx4 sq_rt=SqrtEstSIMD(x);
+ if (xp & 1) // .25?
+ rslt=SqrtEstSIMD(sq_rt); // x^.25
+ if (xp & 2)
+ rslt=MulSIMD(rslt,sq_rt);
+ }
+ xp>>=2; // strip fraction
+ fltx4 curpower=x; // curpower iterates through x,x^2,x^4,x^8,x^16...
+
+ while(1)
+ {
+ if (xp & 1)
+ rslt=MulSIMD(rslt,curpower);
+ xp>>=1;
+ if (xp)
+ curpower=MulSIMD(curpower,curpower);
+ else
+ break;
+ }
+ if (exponent<0)
+ return ReciprocalEstSaturateSIMD(rslt); // pow(x,-b)=1/pow(x,b)
+ else
+ return rslt;
+}
+
+
+
+
+/*
+ * (c) Ian Stephenson
+ *
+ *
+ * Fast pow() reference implementation
+ */
+
+
+static float shift23=(1<<23);
+static float OOshift23=1.0/(1<<23);
+
+float FastLog2(float i)
+{
+ float LogBodge=0.346607f;
+ float x;
+ float y;
+ x=*(int *)&i;
+ x*= OOshift23; //1/pow(2,23);
+ x=x-127;
+
+ y=x-floorf(x);
+ y=(y-y*y)*LogBodge;
+ return x+y;
+}
+float FastPow2(float i)
+{
+ float PowBodge=0.33971f;
+ float x;
+ float y=i-floorf(i);
+ y=(y-y*y)*PowBodge;
+
+ x=i+127-y;
+ x*= shift23; //pow(2,23);
+ *(int*)&x=(int)x;
+ return x;
+}
+float FastPow(float a, float b)
+{
+ if (a <= OOshift23)
+ {
+ return 0.0f;
+ }
+ return FastPow2(b*FastLog2(a));
+}
+float FastPow10( float i )
+{
+ return FastPow2( i * 3.321928f );
+}
+