![]() |
libSUFR
a LIBrary of Some Useful Fortran Routines
|
Procedures for numerical operations. More...
Functions/Subroutines | |
elemental real(double) function | reldiff (x1, x2) |
Return the relative difference between two numbers: dx/<x> - double precision. | |
elemental real function | reldiff_sp (x1, x2) |
Return the relative difference between two numbers: dx/<x> - single precision version. | |
elemental logical function | deq (x1, x2, eps) |
Test whether two double-precision variables are equal to better than a given value (default: 2x machine precision) | |
elemental logical function | deq0 (x0, eps) |
Test whether a double-precision variable is equal to zero better than a given value (default: 2x machine precision) | |
elemental logical function | seq (x1, x2, eps) |
Test whether two single-precision variables are equal to better than a given value (default: 2x machine precision) | |
elemental logical function | seq0 (x0, eps) |
Test whether a single-precision variable ais equal to zero better than a given value (default: 2x machine precision) | |
elemental logical function | dne (x1, x2, eps) |
Test whether two double-precision variables are unequal to better than a given value (default: 2x machine precision) | |
elemental logical function | dne0 (x0, eps) |
Test whether a double-precision variable is unequal to zero better than a given value (default: 2x machine precision) | |
elemental logical function | sne (x1, x2, eps) |
Test whether two single-precision variables are unequal to better than a given value (default: 2x machine precision) | |
elemental logical function | sne0 (x0, eps) |
Test whether a single-precision variable is unequal to zero better than a given value (default: 2x machine precision) | |
elemental logical function | isinf (x0) |
Test whether a double-precision variable is (+/-) infinite. | |
elemental logical function | sisinf (x0) |
Test whether a single-precision variable is (+/-) infinite. | |
elemental logical function | isanan (x0) |
Test whether a double-precision variable is not a number (NaN) | |
elemental logical function | sisanan (x0) |
Test whether a single-precision variable is not a number (NaN) | |
elemental logical function | isnormal (x0) |
Test whether a double-precision variable is normal (not +/- Inf, not NaN) | |
elemental logical function | sisnormal (x0) |
Test whether a single-precision variable is normal (not +/- Inf, not NaN) | |
pure subroutine | plot_ranges (plx, ply, ddx, ddy, xmin, xmax, ymin, ymax, dx, dy) |
Determine plot ranges from data arrays in x and y, and relative margins. | |
elemental integer function | mod1 (number, period) |
A modulo function to wrap array indices properly in Fortran ([1,N], rather than [0,N-1]) | |
integer function | gcd2 (a, b) |
Compute the greatest common divisor (GCD) of two positive integers using the Euclidean algoritm. | |
integer function | gcd (array) |
Computes the greatest common divisor (GCD) for an array of positive integers using the Euclidean algoritm. | |
integer function | lcm (array) |
Computes the least common multiplier (LCM) for an array of positive integers. | |
Procedures for numerical operations.
elemental logical function sufr_numerics::deq | ( | real(double), intent(in) | x1, |
real(double), intent(in) | x2, | ||
real(double), intent(in), optional | eps ) |
Test whether two double-precision variables are equal to better than a given value (default: 2x machine precision)
x1 | First number |
x2 | Second number |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
deq | The two numers are equal (true/false) |
Definition at line 89 of file numerics.f90.
References deq(), and sufr_kinds::double.
Referenced by deq(), dne(), sufr_interpolate::locate_value_in_array(), sufr_solvers::minimum_solver(), plot_ranges(), sufr_statistics::prob_range(), and sufr_solvers::root_solver().
elemental logical function sufr_numerics::deq0 | ( | real(double), intent(in) | x0, |
real(double), intent(in), optional | eps ) |
Test whether a double-precision variable is equal to zero better than a given value (default: 2x machine precision)
x0 | Number to check |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
deq0 | The number is equal to 0 (true/false) |
Definition at line 117 of file numerics.f90.
References deq0(), and sufr_kinds::double.
Referenced by deq0(), dne0(), sufr_time2string::hdm(), sufr_time2string::hhms(), sufr_time2string::hm(), sufr_time2string::hmm(), sufr_time2string::hms(), sufr_time2string::hms_s(), sufr_time2string::hms_sss(), sufr_fitting::nonlin_fit_yerr(), sufr_time2string::um(), sufr_time2string::umm(), sufr_time2string::ums(), sufr_time2string::wum(), sufr_time2string::wumm(), sufr_time2string::wums(), and sufr_time2string::wums_s().
elemental logical function sufr_numerics::dne | ( | real(double), intent(in) | x1, |
real(double), intent(in) | x2, | ||
real(double), intent(in), optional | eps ) |
Test whether two double-precision variables are unequal to better than a given value (default: 2x machine precision)
x1 | First number |
x2 | Second number |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
dne | The two numbers are unequal (true/false) |
Definition at line 201 of file numerics.f90.
References deq(), dne(), and sufr_kinds::double.
Referenced by dne().
elemental logical function sufr_numerics::dne0 | ( | real(double), intent(in) | x0, |
real(double), intent(in), optional | eps ) |
Test whether a double-precision variable is unequal to zero better than a given value (default: 2x machine precision)
x0 | Number to check |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
dne0 | The number is unequal to 0 (true/false) |
Definition at line 223 of file numerics.f90.
References deq0(), dne0(), and sufr_kinds::double.
Referenced by dne0().
integer function sufr_numerics::gcd | ( | integer, dimension(:), intent(in) | array | ) |
Computes the greatest common divisor (GCD) for an array of positive integers using the Euclidean algoritm.
array | The array of positive integers |
gcd | The GCD of the integers |
Definition at line 519 of file numerics.f90.
References gcd(), gcd2(), and sufr_system::quit_program_error().
Referenced by gcd().
integer function sufr_numerics::gcd2 | ( | integer, intent(in) | a, |
integer, intent(in) | b ) |
Compute the greatest common divisor (GCD) of two positive integers using the Euclidean algoritm.
a | Positive integer 1 |
b | Positive integer 2 |
gcd2 | The GCD of the two integers |
Definition at line 479 of file numerics.f90.
References gcd2(), sufr_system::quit_program_error(), and sufr_system::swapint().
Referenced by gcd(), and gcd2().
elemental logical function sufr_numerics::isanan | ( | real(double), intent(in) | x0 | ) |
Test whether a double-precision variable is not a number (NaN)
x0 | Number to check |
isanan | The value is a NaN (true/false) |
Definition at line 327 of file numerics.f90.
References sufr_kinds::double, and isanan().
Referenced by isanan(), and isnormal().
elemental logical function sufr_numerics::isinf | ( | real(double), intent(in) | x0 | ) |
Test whether a double-precision variable is (+/-) infinite.
x0 | Number to check |
isinf | The number is infinite (true/false) |
Definition at line 295 of file numerics.f90.
References sufr_kinds::double, and isinf().
Referenced by isinf(), and isnormal().
elemental logical function sufr_numerics::isnormal | ( | real(double), intent(in) | x0 | ) |
Test whether a double-precision variable is normal (not +/- Inf, not NaN)
x0 | Number to check |
isnormal | This is a normal value (true/false) |
Definition at line 359 of file numerics.f90.
References sufr_kinds::double, isanan(), isinf(), and isnormal().
Referenced by isnormal().
integer function sufr_numerics::lcm | ( | integer, dimension(:), intent(in) | array | ) |
Computes the least common multiplier (LCM) for an array of positive integers.
array | The array of positive integers |
lcm | The LCM of the integers |
Definition at line 544 of file numerics.f90.
References lcm(), and sufr_system::quit_program_error().
Referenced by lcm().
elemental integer function sufr_numerics::mod1 | ( | integer, intent(in) | number, |
integer, intent(in) | period ) |
A modulo function to wrap array indices properly in Fortran ([1,N], rather than [0,N-1])
Since array indices in Fortran run from 1 to N, and the mod() function returns 0 to N-1 which can be used as an array index directly in e.g. C, mod1() provides that service in Fortran.
number | Number to take the modulo of |
period | Period to wrap around |
mod1 | Modulo of the given number with the given period |
Definition at line 457 of file numerics.f90.
References mod1().
Referenced by mod1().
pure subroutine sufr_numerics::plot_ranges | ( | real(double), dimension(:), intent(in) | plx, |
real(double), dimension(:), intent(in) | ply, | ||
real(double), intent(in) | ddx, | ||
real(double), intent(in) | ddy, | ||
real(double), intent(out) | xmin, | ||
real(double), intent(out) | xmax, | ||
real(double), intent(out) | ymin, | ||
real(double), intent(out) | ymax, | ||
real(double), intent(out), optional | dx, | ||
real(double), intent(out), optional | dy ) |
Determine plot ranges from data arrays in x and y, and relative margins.
plx | Array contaiting x values |
ply | Array contaiting y values |
ddx | Relative margin in x |
ddy | Relative margin in y |
xmin | Minimum of plot range in x (output) |
xmax | Maximum of plot range in x (output) |
ymin | Minimum of plot range in y (output) |
ymax | Maximum of plot range in y (output) |
dx | Range width of x (xmax-xmin; output, optional) |
dy | Range wifth of y (ymax-ymin; output, optional) |
Definition at line 404 of file numerics.f90.
References deq(), and sufr_kinds::double.
elemental real(double) function sufr_numerics::reldiff | ( | real(double), intent(in) | x1, |
real(double), intent(in) | x2 ) |
Return the relative difference between two numbers: dx/<x> - double precision.
x1 | First number |
x2 | Second number |
reldiff | The relative difference |
Definition at line 37 of file numerics.f90.
References sufr_kinds::dbl, sufr_kinds::double, and reldiff().
Referenced by reldiff(), and reldiff_sp().
elemental real function sufr_numerics::reldiff_sp | ( | real, intent(in) | x1, |
real, intent(in) | x2 ) |
Return the relative difference between two numbers: dx/<x> - single precision version.
x1 | First number |
x2 | Second number |
reldiff_sp | The relative difference |
Definition at line 67 of file numerics.f90.
References reldiff(), and reldiff_sp().
Referenced by reldiff_sp().
elemental logical function sufr_numerics::seq | ( | real, intent(in) | x1, |
real, intent(in) | x2, | ||
real, intent(in), optional | eps ) |
Test whether two single-precision variables are equal to better than a given value (default: 2x machine precision)
x1 | First number |
x2 | Second number |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
seq | The two numers are equal (true/false) |
Definition at line 147 of file numerics.f90.
References seq().
Referenced by seq(), and sne().
elemental logical function sufr_numerics::seq0 | ( | real, intent(in) | x0, |
real, intent(in), optional | eps ) |
Test whether a single-precision variable ais equal to zero better than a given value (default: 2x machine precision)
x0 | Number to check |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
seq0 | The number is equal to 0 (true/false) |
Definition at line 173 of file numerics.f90.
References seq0().
Referenced by seq0(), and sne0().
elemental logical function sufr_numerics::sisanan | ( | real, intent(in) | x0 | ) |
Test whether a single-precision variable is not a number (NaN)
x0 | Number to check |
sisanan | The value is a NaN (true/false) |
Definition at line 343 of file numerics.f90.
References sisanan().
Referenced by sisanan(), and sisnormal().
elemental logical function sufr_numerics::sisinf | ( | real, intent(in) | x0 | ) |
Test whether a single-precision variable is (+/-) infinite.
x0 | Number to check |
sisinf | The number is infinite (true/false) |
Definition at line 311 of file numerics.f90.
References sisinf().
Referenced by sisinf(), and sisnormal().
elemental logical function sufr_numerics::sisnormal | ( | real, intent(in) | x0 | ) |
Test whether a single-precision variable is normal (not +/- Inf, not NaN)
x0 | Number to check |
sisnormal | This is a normal value (true/false) |
Definition at line 375 of file numerics.f90.
References sisanan(), sisinf(), and sisnormal().
Referenced by sisnormal().
elemental logical function sufr_numerics::sne | ( | real, intent(in) | x1, |
real, intent(in) | x2, | ||
real, intent(in), optional | eps ) |
Test whether two single-precision variables are unequal to better than a given value (default: 2x machine precision)
x1 | First number |
x2 | Second number |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
sne | The two numers are unequal (true/false) |
Definition at line 248 of file numerics.f90.
Referenced by sne().
elemental logical function sufr_numerics::sne0 | ( | real, intent(in) | x0, |
real, intent(in), optional | eps ) |
Test whether a single-precision variable is unequal to zero better than a given value (default: 2x machine precision)
x0 | Number to check |
eps | Maximum absolute difference allowed (optional - default: twice the machine precision) |
sne0 | The number is unequal to 0 (true/false) |
Definition at line 270 of file numerics.f90.
References seq0(), and sne0().
Referenced by sne0().