libSUFR
a LIBrary of Some Useful Fortran Routines
All Classes Namespaces Files Functions Variables Pages
sufr_numerics Module Reference

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.
 

Detailed Description

Procedures for numerical operations.

Function/Subroutine Documentation

◆ deq()

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)

Parameters
x1First number
x2Second number
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
deqThe 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().

Here is the call graph for this function:

◆ deq0()

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)

Parameters
x0Number to check
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
deq0The 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().

Here is the call graph for this function:

◆ dne()

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)

Parameters
x1First number
x2Second number
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
dneThe two numbers are unequal (true/false)

Definition at line 201 of file numerics.f90.

References deq(), dne(), and sufr_kinds::double.

Referenced by dne().

Here is the call graph for this function:

◆ dne0()

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)

Parameters
x0Number to check
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
dne0The 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().

Here is the call graph for this function:

◆ gcd()

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.

Parameters
arrayThe array of positive integers
Return values
gcdThe GCD of the integers
Note
This function uses gcd2() iteratively
See also
https://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations

Definition at line 519 of file numerics.f90.

References gcd(), gcd2(), and sufr_system::quit_program_error().

Referenced by gcd().

Here is the call graph for this function:

◆ gcd2()

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.

Parameters
aPositive integer 1
bPositive integer 2
Return values
gcd2The GCD of the two integers
See also
https://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations

Definition at line 479 of file numerics.f90.

References gcd2(), sufr_system::quit_program_error(), and sufr_system::swapint().

Referenced by gcd(), and gcd2().

Here is the call graph for this function:

◆ isanan()

elemental logical function sufr_numerics::isanan ( real(double), intent(in) x0)

Test whether a double-precision variable is not a number (NaN)

Parameters
x0Number to check
Return values
isananThe 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().

Here is the call graph for this function:

◆ isinf()

elemental logical function sufr_numerics::isinf ( real(double), intent(in) x0)

Test whether a double-precision variable is (+/-) infinite.

Parameters
x0Number to check
Return values
isinfThe number is infinite (true/false)

Definition at line 295 of file numerics.f90.

References sufr_kinds::double, and isinf().

Referenced by isinf(), and isnormal().

Here is the call graph for this function:

◆ isnormal()

elemental logical function sufr_numerics::isnormal ( real(double), intent(in) x0)

Test whether a double-precision variable is normal (not +/- Inf, not NaN)

Parameters
x0Number to check
Return values
isnormalThis 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().

Here is the call graph for this function:

◆ lcm()

integer function sufr_numerics::lcm ( integer, dimension(:), intent(in) array)

Computes the least common multiplier (LCM) for an array of positive integers.

Parameters
arrayThe array of positive integers
Return values
lcmThe LCM of the integers
See also
https://en.wikipedia.org/wiki/Least_common_multiple#A_simple_algorithm

Definition at line 544 of file numerics.f90.

References lcm(), and sufr_system::quit_program_error().

Referenced by lcm().

Here is the call graph for this function:

◆ mod1()

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.
Parameters
numberNumber to take the modulo of
periodPeriod to wrap around
Return values
mod1Modulo of the given number with the given period

Definition at line 457 of file numerics.f90.

References mod1().

Referenced by mod1().

Here is the call graph for this function:

◆ plot_ranges()

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.

Parameters
plxArray contaiting x values
plyArray contaiting y values
ddxRelative margin in x
ddyRelative margin in y
xminMinimum of plot range in x (output)
xmaxMaximum of plot range in x (output)
yminMinimum of plot range in y (output)
ymaxMaximum of plot range in y (output)
dxRange width of x (xmax-xmin; output, optional)
dyRange wifth of y (ymax-ymin; output, optional)

Definition at line 404 of file numerics.f90.

References deq(), and sufr_kinds::double.

Here is the call graph for this function:

◆ reldiff()

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.

Parameters
x1First number
x2Second number
Return values
reldiffThe 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().

Here is the call graph for this function:

◆ 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.

Parameters
x1First number
x2Second number
Return values
reldiff_spThe relative difference

Definition at line 67 of file numerics.f90.

References reldiff(), and reldiff_sp().

Referenced by reldiff_sp().

Here is the call graph for this function:

◆ seq()

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)

Parameters
x1First number
x2Second number
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
seqThe two numers are equal (true/false)

Definition at line 147 of file numerics.f90.

References seq().

Referenced by seq(), and sne().

Here is the call graph for this function:

◆ seq0()

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)

Parameters
x0Number to check
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
seq0The number is equal to 0 (true/false)

Definition at line 173 of file numerics.f90.

References seq0().

Referenced by seq0(), and sne0().

Here is the call graph for this function:

◆ sisanan()

elemental logical function sufr_numerics::sisanan ( real, intent(in) x0)

Test whether a single-precision variable is not a number (NaN)

Parameters
x0Number to check
Return values
sisananThe value is a NaN (true/false)

Definition at line 343 of file numerics.f90.

References sisanan().

Referenced by sisanan(), and sisnormal().

Here is the call graph for this function:

◆ sisinf()

elemental logical function sufr_numerics::sisinf ( real, intent(in) x0)

Test whether a single-precision variable is (+/-) infinite.

Parameters
x0Number to check
Return values
sisinfThe number is infinite (true/false)

Definition at line 311 of file numerics.f90.

References sisinf().

Referenced by sisinf(), and sisnormal().

Here is the call graph for this function:

◆ sisnormal()

elemental logical function sufr_numerics::sisnormal ( real, intent(in) x0)

Test whether a single-precision variable is normal (not +/- Inf, not NaN)

Parameters
x0Number to check
Return values
sisnormalThis is a normal value (true/false)

Definition at line 375 of file numerics.f90.

References sisanan(), sisinf(), and sisnormal().

Referenced by sisnormal().

Here is the call graph for this function:

◆ sne()

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)

Parameters
x1First number
x2Second number
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
sneThe two numers are unequal (true/false)

Definition at line 248 of file numerics.f90.

References seq(), and sne().

Referenced by sne().

Here is the call graph for this function:

◆ sne0()

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)

Parameters
x0Number to check
epsMaximum absolute difference allowed (optional - default: twice the machine precision)
Return values
sne0The number is unequal to 0 (true/false)

Definition at line 270 of file numerics.f90.

References seq0(), and sne0().

Referenced by sne0().

Here is the call graph for this function: