tavoid NaN values from harmonic mean computation - Granular.jl - Julia package … | |
git clone git://src.adamsgaard.dk/Granular.jl | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4ef34d5d68a9760142cecc7e851a72bb298201c4 | |
parent e6423e746bc3d5ee39a065427f18b4be7a8021b3 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 12 May 2017 10:51:10 -0400 | |
avoid NaN values from harmonic mean computation | |
Diffstat: | |
M src/interaction.jl | 6 +++--- | |
1 file changed, 3 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/src/interaction.jl b/src/interaction.jl | |
t@@ -159,9 +159,9 @@ function interactIceFloes!(simulation::Simulation, i::Int,… | |
end | |
function harmonicMean(a::Any, b::Any) | |
- hm = 2.*a*b/(a + b) | |
- if isnan(hm) | |
+ if a ≈ 0. && b ≈ 0 | |
return 0. | |
+ else | |
+ return 2.*a*b/(a + b) | |
end | |
- return hm | |
end |