diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-03-22 10:12:05 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-05-02 21:36:45 +0200 |
commit | a093dd0ee969be5150fdff459db385fbc5613452 (patch) | |
tree | 2809703489b70d94c7e8fd9deac967abe6ae2bcf /math.h | |
parent | 539286a9a5b7663dfba7849328998601816b6f14 (diff) | |
download | pucket-a093dd0ee969be5150fdff459db385fbc5613452.tar.gz pucket-a093dd0ee969be5150fdff459db385fbc5613452.tar.bz2 pucket-a093dd0ee969be5150fdff459db385fbc5613452.zip |
Rewrite flam3_random
Disables flam3_mutate.
Diffstat (limited to 'math.h')
-rw-r--r-- | math.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -19,6 +19,7 @@ #pragma once #include <math.h> +#include <assert.h> #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 */ |