NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
|
This module provides convenience routines to operate or get information on arrays. More...
Data Types | |
interface | save_array |
save_array Stores an 1D or 2D array to file or stdout More... | |
Functions/Subroutines | |
logical function, public | allclose (a, b, rtol, atol) |
allclose returns True if two arrays are element-wise equal within a tolerance. | |
real(dp) function, dimension(:), allocatable, public | merge_sorted (x1, x2, tolerance) |
This function creates a sorted array with values from two input sorted arrays. | |
real(dp) function, public | std (x) |
std Computes the standard deviation of the array. | |
real(dp) function, public | mean (x) |
mean Computes the arithmetic mean of the array. | |
This module provides convenience routines to operate or get information on arrays.
logical function, public allclose | ( | real(dp), dimension(:), intent(in) | a, |
real(dp), dimension(size(a)), intent(in) | b, | ||
real(dp), intent(in), optional | rtol, | ||
real(dp), intent(in), optional | atol ) |
allclose returns True if two arrays are element-wise equal within a tolerance.
Very similar to Numpy allclose
The tolerance values are positive, typically very small numbers. The relative difference (rtol
* abs(b
)) and the absolute difference atol
are added together to compare against the absolute difference between a
and b
.
If the following equation
abs(a
- b
) <= (atol
+ rtol
* absolute(b
))
is element-wise True, then allclose returns .True.
The above equation is not symmetric in a
and b
, so that allclose(a, b)
might be different from allclose(b, a)
in some rare cases.
[in] | a | Array |
[in] | b | Array |
[in] | rtol | The relative tolerance parameter. Default = 1.e-5 |
[in] | atol | The absolute tolerance parameter. Default = 1.e-8 |
real(dp) function, public mean | ( | real(dp), dimension(:), intent(in) | x | ) |
mean Computes the arithmetic mean of the array.
sum(x)/size(x)
[in] | x | Input array of real values |
Referenced by histograms::histogram(), and std().
real(dp) function, dimension(:), allocatable, public merge_sorted | ( | real(dp), dimension(:), intent(in), target | x1, |
real(dp), dimension(:), intent(in), target | x2, | ||
real(dp), intent(in), optional | tolerance ) |
This function creates a sorted array with values from two input sorted arrays.
Equal values (within tolerance) are only included once
[in] | x1 | First array |
[in] | x2 | Second array |
[in] | tolerance | Defines the minimum value by which two numbers are considered different |
References basic::small.
real(dp) function, public std | ( | real(dp), dimension(:), intent(in) | x | ) |
std Computes the standard deviation of the array.
sqrt(mean(x - mean(x))* alfa )
with alfa= (N/(N-1))
[in] | x | Input array of real values |
References mean().
Referenced by histograms::histogram().