tAvoid NaN in normalized shear velocities - cngf-pf - continuum model for granu… | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit aae696d07b2ad99164b83902f3a3c2981022e85e | |
parent 790b6e51d3e0cacbe391cd8940eb2ac7d941820a | |
Author: Anders Damsgaard <[email protected]> | |
Date: Mon, 8 Jul 2019 16:10:31 +0200 | |
Avoid NaN in normalized shear velocities | |
Diffstat: | |
M arrays.c | 4 ++++ | |
1 file changed, 4 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/arrays.c b/arrays.c | |
t@@ -237,6 +237,10 @@ normalize(const double* in, const int n) | |
out = malloc(n*sizeof(double)); | |
copy_values(in, out, n); | |
max_val = max(out, n); | |
+ | |
+ if (max_val == 0.0) | |
+ max_val = 1.0; | |
+ | |
for (i=0; i<n; ++i) | |
out[i] /= max_val; | |
return out; |