rotex__functions Module

Contains various small functions used in the code



Interfaces

public interface are_approx_eq

Compare two a and b and see if the magnitude of their difference is smaller than a tolerance, taking machine epsilon*max(|a|,|b|) for their precision as the default value

  • private pure elemental module function are_approx_eqz(a, b, tol) result(res)

    Comparre two a and b and see if magnitude of their difference is smaller than a tolerance, taking machine epsilon for their precision as the default value

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: a
    complex(kind=dp), intent(in) :: b
    real(kind=dp), intent(in), optional :: tol

    Return Value logical

  • private pure elemental module function are_approx_eqr(a, b, tol) result(res)

    Comparre two a and b and see if magnitude of their difference is smaller than a tolerance, taking machine epsilon for their precision as the default value

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: a
    real(kind=dp), intent(in) :: b
    real(kind=dp), intent(in), optional :: tol

    Return Value logical

public interface factorial

!n

  • private pure elemental module function factorial_int(n) result(res)

    !n

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: n

    Return Value real(kind=dp)

  • private pure elemental module function factorial_real(n) result(res)

    !n

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: n

    Return Value real(kind=dp)

public interface log_factorial

ln(!n)

  • private pure elemental module function log_factorial_i(n) result(res)

    returns ln(n!) for integer n

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: n

    Return Value real(kind=dp)

  • private pure elemental module function log_factorial_r(n) result(res)

    returns ln(n!) for real n

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: n

    Return Value real(kind=dp)

public interface expm1

  • private module function expm1r(x) result(res)

    Returns . TODO, replace with a fast and accurate version coded natively in fortran !

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in), value :: x

    Return Value real(kind=dp)

  • private module function expm1z(z) result(res)

    Returns . TODO, replace with a fast and accurate version coded natively in fortran !

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: z

    Return Value complex(kind=dp)

public interface logb

  • private pure elemental function logb_ii(b, x) result(res)

    Returns the logarithm of x in the base b

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: b
    integer, intent(in) :: x

    Return Value real(kind=dp)

  • private pure elemental function logb_rr(b, x) result(res)

    Returns the logarithm of x in the base b

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: b
    real(kind=dp), intent(in) :: x

    Return Value real(kind=dp)

  • private pure elemental function logb_cc(b, x) result(res)

    Returns the logarithm of x in the base b

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: b
    complex(kind=dp), intent(in) :: x

    Return Value complex(kind=dp)

public interface logrange

  • private pure function logrange_ib(a, b, n, base, inclast) result(res)

    Returns an array of n log-spaced values from a to b. By default, the base is 10 if omitted but can be changed by the user

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=dp), intent(in) :: a
    integer(kind=dp), intent(in) :: b
    integer, intent(in) :: n
    integer, intent(in), optional :: base

    Logarithm base

    logical, intent(in), optional :: inclast

    Whether to include the last value b

    Return Value real(kind=dp), (n)

  • private pure function logrange_rb(a, b, n, base, inclast) result(res)

    Returns an array of n log-spaced values from a to b. By default, the base is 10 if omitted but can be changed by the user

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: a
    real(kind=dp), intent(in) :: b
    integer, intent(in) :: n
    real(kind=dp), intent(in), optional :: base

    Logarithm base

    logical, intent(in), optional :: inclast

    Whether to include the last value b

    Return Value real(kind=dp), (n)

public interface isinteger

Check if a real/complex number is an integer

  • private pure elemental module function isintegerr(x) result(res)

    Check if x is an integer

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: x

    Return Value logical

  • private pure elemental module function isintegerz(z) result(res)

    Check if z is an integer

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: z

    Return Value logical

public interface isnatural

Check if a real/complex number is a natrual number

  • private pure elemental module function isnaturalr(x) result(res)

    Check if x is a natural number (1, 2, 3, ...)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: x

    Return Value logical

  • private pure elemental module function isnaturalz(z) result(res)

    Check if z is a natural number (1, 2, 3, ...)

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: z

    Return Value logical

public interface arg

Return the phase of a complex number in (-π,π]

  • private pure elemental module function argi(z) result(res)

    Return the phase of an integer (as a complex number) in (-π,π]

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: z

    Return Value real(kind=dp)

  • private pure elemental module function argr(z) result(res)

    Return the phase of a real number (as a complex number) in (-π,π]

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: z

    Return Value real(kind=dp)

  • private pure elemental module function argc(z) result(res)

    Return the phase of a complex number in (-π,π]

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: z

    Return Value real(kind=dp)

public interface inv

Compute 1/z

  • private pure elemental module function invi(i) result(res)

    Return the real 1/i for integer i

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: i

    Return Value real(kind=dp)

  • private pure elemental module function invr(x) result(res)

    Return 1/x

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: x

    Return Value real(kind=dp)

  • private pure elemental module function invz(z) result(res)

    Return 1/z for complex z. If the imaginary part of z is 0, flip its sign

    Arguments

    Type IntentOptional Attributes Name
    complex(kind=dp), intent(in) :: z

    Return Value complex(kind=dp)


Functions

public pure elemental module function delta(m, n) result(res)

Return the Kronecker delta function

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: m
integer, intent(in) :: n

Return Value real(kind=dp)

public pure elemental module function iseven(n) result(res)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Return Value logical

public pure elemental module function isodd(n) result(res)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Return Value logical

public pure elemental module function istriangle(a, b, c) result(res)

returns whether the arguments satisfy the triangle inequality, assuming that they're positive quantities

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: a
integer, intent(in) :: b
integer, intent(in) :: c

Return Value logical

public pure elemental module function neg(i) result(res)

Returns the integer }

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

Return Value integer