elementary_functions_m Module

Elementary mathematical functions



Functions

public pure function factorial(n) result(res)

Factorial of integer n; wrapper around intrinsic gamma function. Output is real to increase overflow threshold. For overflow case, result = Infinity; for n < 0, result = NaN.

Arguments

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

Integer to take the factorial of

Return Value real(kind=fp)

public pure function gaussian(x0, wx, x)

Gaussian exp[-(x-x0)^2/wx^2]

Arguments

Type IntentOptional Attributes Name
real(kind=FP), intent(in) :: x0

Center of Gaussion

real(kind=FP), intent(in) :: wx

Width of Gaussion

real(kind=FP), intent(in) :: x

Position where Gaussian is evaluated

Return Value real(kind=fp)

public pure function step_tanh(x0, x, wx)

Smooth step function based on hyperbolic tangent

Arguments

Type IntentOptional Attributes Name
real(kind=FP), intent(in) :: x0

Position of center of step

real(kind=FP), intent(in) :: x

Position where function is evaluated

real(kind=FP), intent(in), optional :: wx

Width of step, if set to zero yields heaviside function

Return Value real(kind=fp)

public pure function heaviside(x0, x)

Heaviside function, i.e. discontinuous step function

Arguments

Type IntentOptional Attributes Name
real(kind=FP), intent(in) :: x0

Position of step

real(kind=FP), intent(in) :: x

Position where function is evaluated

Return Value real(kind=fp)

public pure function step_hermite(x0, x, wx, order)

Smooth step function based on Hermite interpolation exactly zero for x < wx/2 and one for x > wx/2 see https://en.wikipedia.org/wiki/Smoothstep

Arguments

Type IntentOptional Attributes Name
real(kind=FP), intent(in) :: x0

Position of step

real(kind=FP), intent(in) :: x

Position where function is evaluated

real(kind=FP), intent(in), optional :: wx

Width of step

integer, intent(in), optional :: order

Order of smoothstep function Default value 2

Return Value real(kind=fp)

public pure function binomial_coefficient_r(n, k)

Computes binomial coefficient n over k Returns -1 for invalid input, i.e. n or k < 0 or k > n

Arguments

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

Top number of binomal coefficient

integer, intent(in) :: k

Bottom number of binomal coefficient

Return Value real(kind=fp)