Lethe Open-Source Library
version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
include
core
auxiliary_math_functions.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) 2022, 2024 The Lethe Authors
2
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4
#ifndef lethe_auxiliary_math_functions_h
5
#define lethe_auxiliary_math_functions_h
6
7
#include <limits>
8
9
/**
10
* Carries out the calculation of the harmonic mean of two values.
11
* The harmonic mean of x and y is defined by 2*x*y/(x+y)
12
*
13
* @param value_one
14
* @param value_two
15
* @return harmonic mean of value_one and value_two
16
*/
17
inline
double
18
harmonic_mean
(
const
double
&value_one,
const
double
&value_two)
19
{
20
return
(2 * value_one * value_two /
21
(value_one + value_two + std::numeric_limits<double>::min()));
22
}
23
24
#endif
harmonic_mean
double harmonic_mean(const double &value_one, const double &value_two)
Definition
auxiliary_math_functions.h:18
Generated by
1.15.0