Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd harmonic_mean function - granular - granular dynamics simulation
git clone git://src.adamsgaard.dk/granular
Log
Files
Refs
README
LICENSE
---
commit 1530b4bb345ad9e65cdf43acda89c5b5ca48ded6
parent f4eaf592d0d80b9eed6e31d89337a6b4eebcef40
Author: Anders Damsgaard <[email protected]>
Date: Wed, 21 Apr 2021 13:54:33 +0200
add harmonic_mean function
Diffstat:
M util.c | 9 +++++++++
M util.h | 2 ++
2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/util.c b/util.c
t@@ -123,3 +123,12 @@ xreallocarray(void *m, size_t n, size_t s)
return nm;
}
+
+double
+harmonic_mean(double a, double b)
+{
+ if (a < 1e-16 || b < 1e-16)
+ return 0.0;
+ else
+ return 2.0 * a * b / (a + b);
+}
diff --git a/util.h b/util.h
t@@ -17,4 +17,6 @@ double random_value_powerlaw(double min, double max);
void * xreallocarray(void *m, size_t n, size_t s);
+double harmonic_mean(double a, double b);
+
#endif
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.