FORCES
FORtran lib for Comp. Env. Sys.
|
Mean of vector. More...
Public Member Functions | |
real(sp) function | average_sp (dat, mask) |
real(dp) function | average_dp (dat, mask) |
Mean of vector.
Calculates the average value of a vector, i.e. the first moment of a series of numbers:
\[ AVE = \sum_i \frac{x_i}{N} \]
If an optional mask is given, the average is only over those locations that correspond to true values in the mask. \( x\) can be single or double precision. The result will have the same numerical precision.
Example
vec = (/ 1., 2, 3., -999., 5., 6. /) m = average(vec, mask=(vec >= 0.)) --> m = 3.4
See also example in pf_tests directory.
[in] | real(sp/dp) :: dat(:) | 1D-array with input numbers |
real(sp/dp) :: average | Average of all elements in dat |
[in] | logical, optional :: mask(:) | 1D-array of logical values with size(dat) . If present, only those locations in dat corresponding to the true values in mask are used. |
Definition at line 119 of file mo_moment.f90.
real(dp) function mo_moment::average::average_dp | ( | real(dp), dimension(:), intent(in) | dat, |
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 681 of file mo_moment.f90.
real(sp) function mo_moment::average::average_sp | ( | real(sp), dimension(:), intent(in) | dat, |
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 707 of file mo_moment.f90.