aboutsummaryrefslogtreecommitdiff
path: root/chaos/src/chaos.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'chaos/src/chaos.hpp')
-rw-r--r--chaos/src/chaos.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/chaos/src/chaos.hpp b/chaos/src/chaos.hpp
index 0f87b51..2e2eb8b 100644
--- a/chaos/src/chaos.hpp
+++ b/chaos/src/chaos.hpp
@@ -27,6 +27,8 @@
#include "chaos_defs.hpp"
#include <cmath>
+#include <cstdlib>
+
/* internal we can work with a higher precision than pd */
#ifdef DOUBLE_PRECISION
typedef double data_t;
@@ -36,6 +38,21 @@ typedef float data_t;
#define CHAOS_ABS(x) fabsf(x)
#endif
+inline data_t chaos_mod(data_t x, data_t y)
+{
+#ifdef DOUBLE_PRECISION
+ return fmod(x,y);
+#else
+ return fmodf(x,y);
+#endif
+}
+
+inline data_t rand_range(data_t low, data_t high)
+{
+ return low + ( (rand() * (high - low)) / RAND_MAX);
+}
+
+
#define __chaos_hpp
#endif /* __chaos_hpp */