My Project
Means.hpp File Reference

Implements some common averages. More...

#include <cmath>

Go to the source code of this file.

Functions

template<class Scalar >
Scalar Opm::arithmeticMean (Scalar x, Scalar y)
 Computes the arithmetic average of two values. More...
 
template<class Scalar >
Scalar Opm::geometricMean (Scalar x, Scalar y)
 Computes the geometric average of two values. More...
 
template<class Scalar >
Scalar Opm::harmonicMean (Scalar x, Scalar y)
 Computes the harmonic average of two values. More...
 

Detailed Description

Implements some common averages.

i.e., arithmetic, geometric and harmonic averages.

Function Documentation

◆ arithmeticMean()

template<class Scalar >
Scalar Opm::arithmeticMean ( Scalar  x,
Scalar  y 
)
inline

Computes the arithmetic average of two values.

This uses the usual definition of the arithmethic mean:

\[ <a(x,y)> = (x+y)/2 \]

◆ geometricMean()

template<class Scalar >
Scalar Opm::geometricMean ( Scalar  x,
Scalar  y 
)
inline

Computes the geometric average of two values.

This uses the usual definition of the geometric mean:

\[ <a(x,y)> = \sqrt{x^2 + y^2} \]

◆ harmonicMean()

template<class Scalar >
Scalar Opm::harmonicMean ( Scalar  x,
Scalar  y 
)
inline

Computes the harmonic average of two values.

This uses the usual definition of the harmonic mean:

\[ <a(x,y)> = \frac{2}{1/x + 1/y} \]