This module provides simple reductions over rank-1 arrays. To avoid
precision loss and integer overflow, mean, variance and std_dev
always accumulate in and return real(dp), regardless of the input type.
min_max preserves the input type and returns the two extremes in a
length-2 array.
Arithmetic mean of a 1-D array, returned as real(dp).
Returns 0 for an empty array. Supported input types are:
integer(int32), integer(int64), real(sp), real(dp).
Usage: m = mean(array)
Mean of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) |
Mean of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) |
Mean of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) |
Mean of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) |
Minimum and maximum of a 1-D array in a single length-2 result.
Returns [minval(array), maxval(array)], preserving the input type.
The result is undefined for an empty array. Supported types are:
integer(int32), integer(int64), real(sp), real(dp).
Usage: mm = min_max(array) ! mm(1) = min, mm(2) = max
Minimum and maximum of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) |
Minimum and maximum of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) |
Minimum and maximum of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) |
Minimum and maximum of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) |
Standard deviation of a 1-D array, returned as real(dp).
Equal to sqrt(variance(array, sample)); see variance for the meaning
of the optional sample flag.
Usage: s = std_dev(array [, sample])
Standard deviation of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of a 1-D array, returned as real(dp).
By default the unbiased sample variance (dividing by n - 1) is
returned; pass sample = .false. for the population variance (dividing
by n). Returns 0 when there are too few elements to define it.
Supported input types are: integer(int32), integer(int64), real(sp),
real(dp).
Usage: v = variance(array [, sample])
Variance of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of a real(dp) array (core implementation, two-pass).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Mean of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) |
Mean of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) |
Mean of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) |
Mean of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) |
Minimum and maximum of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) |
Minimum and maximum of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) |
Minimum and maximum of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) |
Minimum and maximum of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) |
Standard deviation of a real(dp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Standard deviation of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of a real(dp) array (core implementation, two-pass).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of an integer(int32) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int32), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of an integer(int64) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |
Variance of a real(sp) array.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=sp), | intent(in) | :: | array(:) | |||
| logical, | intent(in), | optional | :: | sample |