diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /mathlib/halton.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'mathlib/halton.cpp')
| -rw-r--r-- | mathlib/halton.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mathlib/halton.cpp b/mathlib/halton.cpp new file mode 100644 index 0000000..f9daae7 --- /dev/null +++ b/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; +} |