aboutsummaryrefslogtreecommitdiff
path: root/mp/src/mathlib/halton.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/mathlib/halton.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/mathlib/halton.cpp')
-rw-r--r--mp/src/mathlib/halton.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/mp/src/mathlib/halton.cpp b/mp/src/mathlib/halton.cpp
new file mode 100644
index 00000000..d0c56325
--- /dev/null
+++ b/mp/src/mathlib/halton.cpp
@@ -0,0 +1,30 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=====================================================================================//
+
+#include <halton.h>
+
+HaltonSequenceGenerator_t::HaltonSequenceGenerator_t(int b)
+{
+ base=b;
+ fbase=(float) b;
+ seed=1;
+
+}
+
+float HaltonSequenceGenerator_t::GetElement(int elem)
+{
+ int tmpseed=seed;
+ float ret=0.0;
+ float base_inv=1.0/fbase;
+ while(tmpseed)
+ {
+ int dig=tmpseed % base;
+ ret+=((float) dig)*base_inv;
+ base_inv/=fbase;
+ tmpseed/=base;
+ }
+ return ret;
+}