From a093dd0ee969be5150fdff459db385fbc5613452 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 22 Mar 2015 10:12:05 +0100 Subject: Rewrite flam3_random Disables flam3_mutate. --- math.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'math.h') diff --git a/math.h b/math.h index dc72d87..fa49d09 100644 --- a/math.h +++ b/math.h @@ -19,6 +19,7 @@ #pragma once #include +#include #include "build/config.h" @@ -79,6 +80,20 @@ inline double sum(const double2 in) { return in[0] + in[1]; } +inline void normalize (double * const a, const size_t n) { + double sum = 0.0; + for (unsigned int j = 0; j < n; j++) { + sum += a[j]; + } + assert (sum > 0.0); + + for (unsigned int j = 0; j < n; j++) { + a[j] /= sum; + } +} + +#define max(a,b) ((a) > (b) ? (a) : (b)) + /* Vector wrapping function, could be replaced by true vector functions later */ -- cgit v1.2.3