.. default-domain:: chpl .. module:: Math :synopsis: This module provides frequently used mathematical constants and functions. Math ==== **Usage** .. code-block:: chapel use Math; or .. code-block:: chapel import Math; This module provides frequently used mathematical constants and functions. It includes wrappers for many of the constants and functions in the C Math library, which is part of the C Language Standard (ISO/IEC 9899) as described in Section 7.12. Please consult that standard for an authoritative description of the expected properties of those constants and routines. In general, where the C math library provides a *double* and a *float* version of a function, the float version has a suffix 'f'. In the Chapel interface, the suffix is dropped, and the type of the operand determines which version is called -- according to the usual function overloading and resolution rules. Normally, the result has the same precision as the argument(s). Please consult the C standard for specifics. Error Handling -- At present, Chapel does not provide control over error handling in the Math module. The default behavior is as if the macro ``math_errhandling`` is set to 0: Given erroneous input at run-time, all math functions will return an implementation-defined value; no exception will be generated. Automatically Available Symbols ------------------------------- .. note:: These symbols can also be accessed using ``Math.`` as their qualified access prefix. .. include:: AutoMath.rst :start-line: 7 :start-after: Automatically included Math symbols :end-before: .. function:: Non-Automatically Available Symbols ----------------------------------- .. _math-constants: Constants ^^^^^^^^^ :param:`~Math.e` :param:`~Math.log2E` :param:`~Math.log10E` :param:`~Math.ln2` :param:`~Math.ln10` :param:`~Math.pi` :param:`~Math.halfPi` :param:`~Math.quarterPi` :param:`~Math.reciprPi` :param:`~Math.twiceReciprPi` :param:`~Math.twiceReciprSqrtPi` :param:`~Math.sqrt2` :param:`~Math.reciprSqrt2` .. _math-trigonometry: Trigonometric Functions ^^^^^^^^^^^^^^^^^^^^^^^ :proc:`~Math.acos` :proc:`~Math.acosh` :proc:`~Math.asin` :proc:`~Math.asinh` :proc:`~Math.atan` :proc:`~Math.atan2` :proc:`~Math.atanh` :proc:`~Math.cos` :proc:`~Math.cosh` :proc:`~Math.sin` :proc:`~Math.sinh` :proc:`~Math.tan` :proc:`~Math.tanh` .. _math-log: Log Functions ^^^^^^^^^^^^^ :proc:`~Math.ln` :proc:`~Math.log` :proc:`~Math.log10` :proc:`~Math.log1p` :proc:`~Math.logBasePow2` :proc:`~Math.log2` .. _math-exponential: Exponential Functions ^^^^^^^^^^^^^^^^^^^^^ :proc:`~Math.exp` :proc:`~Math.exp2` :proc:`~Math.expm1` :proc:`~Math.ldExp` .. _math-rounding: Rounding ^^^^^^^^ :proc:`~Math.divCeil` :proc:`~Math.divCeilPos` :proc:`~Math.divFloor` :proc:`~Math.divFloorPos` :proc:`~Math.nearbyint` :proc:`~Math.rint` .. _math-gamma: Gamma Functions ^^^^^^^^^^^^^^^ :proc:`~Math.gamma` :proc:`~Math.lnGamma` .. _math-error: Error Functions ^^^^^^^^^^^^^^^ :proc:`~Math.erf` :proc:`~Math.erfc` .. _math-algorithms: Algorithms ^^^^^^^^^^ :proc:`~Math.gcd` .. _math-bessel: Bessel Functions ^^^^^^^^^^^^^^^^ :proc:`~Math.j0` :proc:`~Math.j1` :proc:`~Math.jn` :proc:`~Math.y0` :proc:`~Math.y1` :proc:`~Math.yn` .. _math-optimization: Optimization Functions ^^^^^^^^^^^^^^^^^^^^^^ :proc:`~Math.fma` .. _automath-constant-and-function-definitions: Automatically Included Constant and Function Definitions -------------------------------------------------------- .. include:: AutoMath.rst :start-after: :proc:`~Math.mod` .. _math-constant-and-function-definitions: Constant and Function Definitions for Math ------------------------------------------ .. data:: param e = 2.7182818284590452354 e - exp(1) or the base of the natural logarithm .. data:: param log2E = 1.4426950408889634074 log2(e) .. data:: param log2_e = 1.4426950408889634074 .. warning:: 'log2_e' is deprecated, please use :param:`log2E` instead log2(e) .. data:: param log10E = 0.43429448190325182765 log10(e) .. data:: param log10_e = 0.43429448190325182765 .. warning:: 'log10_e' is deprecated, please use :param:`log10E` instead log10(e) .. data:: param ln2 = 0.69314718055994530942 ln(2) (natural logarithm) .. data:: param ln_2 = 0.69314718055994530942 .. warning:: 'ln_2' is deprecated, please use :param:`ln2` instead log(2) (natural logarithm) .. data:: param ln10 = 2.30258509299404568402 ln(10) (natural logarithm) .. data:: param ln_10 = 2.30258509299404568402 .. warning:: 'ln_10' is deprecated, please use :param:`ln10` instead log(10) (natural logarithm) .. data:: param pi = 3.14159265358979323846 pi - the circumference/the diameter of a circle .. data:: param halfPi = 1.57079632679489661923 .. warning:: 'halfPi' is unstable due to questions about its utility. If you are seeing negative performance impacts from using 'pi/2' instead of this 'param', please let us know! pi/2 .. data:: param half_pi = 1.57079632679489661923 .. warning:: 'half_pi' is deprecated, please use :param:`halfPi` or 'pi/2' instead pi/2 .. data:: param quarterPi = 0.78539816339744830962 .. warning:: 'quarterPi' is unstable due to questions about its utility. If you are seeing negative performance impacts from using 'pi/4' instead of this 'param', please let us know! pi/4 .. data:: param quarter_pi = 0.78539816339744830962 .. warning:: 'quarter_pi' is deprecated, please use :param:`quarterPi` or 'pi/4' instead pi/4 .. data:: param reciprPi = 0.31830988618379067154 .. warning:: 'reciprPi' is unstable due to questions about its utility. If you are seeing negative performance impacts from using '1/pi' instead of this 'param', please let us know! 1/pi .. data:: param recipr_pi = 0.31830988618379067154 .. warning:: 'recipr_pi' is deprecated, please use :param:`reciprPi` or '1/pi' instead 1/pi .. data:: param twiceReciprPi = 0.63661977236758134308 .. warning:: 'twiceReciprPi' is unstable due to questions about its utility. If you are seeing negative performance impacts from using '2/pi' instead of this 'param', please let us know! 2/pi .. data:: param twice_recipr_pi = 0.63661977236758134308 .. warning:: 'twice_recipr_pi' is deprecated, please use :param:`twiceReciprPi` or '2/pi' instead 2/pi .. data:: param twiceReciprSqrtPi = 1.12837916709551257390 .. warning:: 'twiceReciprSqrtPi' is unstable due to questions about its utility. If you are using this symbol, please let us know! 2/sqrt(pi) .. data:: param twice_recipr_sqrt_pi = 1.12837916709551257390 .. warning:: 'twice_recipr_sqrt_pi' is deprecated, please use :param:`twiceReciprSqrtPi` or '2/sqrt(pi)' instead 2/sqrt(pi) .. data:: param sqrt2 = 1.41421356237309504880 .. warning:: 'sqrt2' is unstable due to questions about its utility. If you are using this symbol, please let us know! sqrt(2) .. data:: param sqrt_2 = 1.41421356237309504880 .. warning:: 'sqrt_2' is deprecated, please use :param:`sqrt2` or 'sqrt(2)' instead sqrt(2) .. data:: param reciprSqrt2 = 0.70710678118654752440 .. warning:: 'reciprSqrt2' is unstable due to questions about its utility. If you are using this symbol, please let us know! 1/sqrt(2) .. data:: param recipr_sqrt_2 = 0.70710678118654752440 .. warning:: 'recipr_sqrt_2' is deprecated, please use :param:`reciprSqrt2` or '1/sqrt(2)' instead 1/sqrt(2) .. function:: proc acos(x: real(64)): real(64) Returns the arc cosine of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc acos(x: real(32)): real(32) Returns the arc cosine of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc acos(x: complex(64)): complex(64) Returns the arc cosine of the argument `x`. .. function:: proc acos(x: complex(128)): complex(128) Returns the arc cosine of the argument `x`. .. function:: proc acosh(x: real(64)): real(64) Returns the inverse hyperbolic cosine of the argument `x`. It is an error if `x` is less than 1. .. function:: proc acosh(x: real(32)): real(32) Returns the inverse hyperbolic cosine of the argument `x`. It is an error if `x` is less than 1. .. function:: proc acosh(x: complex(64)): complex(64) Returns the inverse hyperbolic cosine of the argument `x`. .. function:: proc acosh(x: complex(128)): complex(128) Returns the inverse hyperbolic cosine of the argument `x`. .. function:: proc asin(x: real(64)): real(64) Returns the arc sine of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc asin(x: real(32)): real(32) Returns the arc sine of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc asin(x: complex(64)): complex(64) Returns the arc sine of the argument `x`. .. function:: proc asin(x: complex(128)): complex(128) Returns the arc sine of the argument `x`. .. function:: proc asinh(x: real(64)): real(64) Returns the inverse hyperbolic sine of the argument `x`. .. function:: proc asinh(x: real(32)): real(32) Returns the inverse hyperbolic sine of the argument `x`. .. function:: proc asinh(x: complex(64)): complex(64) Returns the inverse hyperbolic sine of the argument `x`. .. function:: proc asinh(x: complex(128)): complex(128) Returns the inverse hyperbolic sine of the argument `x`. .. function:: proc atan(x: real(64)): real(64) Returns the arc tangent of the argument `x`. .. function:: proc atan(x: real(32)): real(32) Returns the arc tangent of the argument `x`. .. function:: proc atan(x: complex(64)): complex(64) Returns the arc tangent of the argument `x`. .. function:: proc atan(x: complex(128)): complex(128) Returns the arc tangent of the argument `x`. .. function:: proc atan2(y: real(64), x: real(64)): real(64) Returns the arc tangent of the ratio of the two arguments. This is equivalent to the arc tangent of `y` / `x` except that the signs of `y` and `x` are used to determine the quadrant of the result. .. function:: proc atan2(y: real(32), x: real(32)): real(32) Returns the arc tangent of the ratio of the two arguments. This is equivalent to the arc tangent of `y` / `x` except that the signs of `y` and `x` are used to determine the quadrant of the result. .. function:: proc atanh(x: real(64)): real(64) Returns the inverse hyperbolic tangent of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc atanh(x: real(32)): real(32) Returns the inverse hyperbolic tangent of the argument `x`. It is an error if `x` is less than -1 or greater than 1. .. function:: proc atanh(x: complex(64)): complex(64) Returns the inverse hyperbolic tangent of the argument `x`. .. function:: proc atanh(x: complex(128)): complex(128) Returns the inverse hyperbolic tangent of the argument `x`. .. function:: proc cos(x: real(64)): real(64) Returns the cosine of the argument `x`. .. function:: proc cos(x: real(32)): real(32) Returns the cosine of the argument `x`. .. function:: proc cos(x: complex(64)): complex(64) Returns the cosine of the argument `x`. .. function:: proc cos(x: complex(128)): complex(128) Returns the cosine of the argument `x`. .. function:: proc cosh(x: real(64)): real(64) Returns the hyperbolic cosine of the argument `x`. .. function:: proc cosh(x: real(32)): real(32) Returns the hyperbolic cosine of the argument `x`. .. function:: proc cosh(x: complex(64)): complex(64) Returns the hyperbolic cosine of the argument `x`. .. function:: proc cosh(x: complex(128)): complex(128) Returns the hyperbolic cosine of the argument `x`. .. function:: proc divCeil(param x: integral, param y: integral) param Returns :proc:`~Math.ceil`\(`x`/`y`), i.e., the fraction `x`/`y` rounded up to the nearest integer. If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time. .. function:: proc divCeil(x: integral, y: integral) Returns :proc:`~Math.ceil`\(`x`/`y`), i.e., the fraction `x`/`y` rounded up to the nearest integer. If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time. .. function:: proc divCeilPos(x: integral, y: integral) .. warning:: divCeilPos is unstable due to questions about its utility. If you find this function valuable, please let us know! A variant of :proc:`divCeil` that performs no runtime checks. The user must ensure that both arguments are strictly positive (not 0) and are of a signed integer type (not `uint`). .. function:: proc divFloor(param x: integral, param y: integral) param Returns :proc:`~Math.floor`\(`x`/`y`), i.e., the fraction `x`/`y` rounded down to the nearest integer. If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time. .. function:: proc divFloor(x: integral, y: integral) Returns :proc:`~Math.floor`\(`x`/`y`), i.e., the fraction `x`/`y` rounded down to the nearest integer. If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time. .. function:: proc divFloorPos(x: integral, y: integral) .. warning:: divFloorPos is unstable due to questions about its utility. If you find this function valuable, please let us know! A variant of :proc:`divFloor` that performs no runtime checks. The user must ensure that both arguments are strictly positive (not 0) and are of a signed integer type (not `uint`). .. function:: proc erf(x: real(64)): real(64) .. warning:: 'erf' is unstable and may be renamed or moved to a different module in the future Returns the error function of the argument `x`. This is equivalent to ``2/sqrt(pi)`` * the integral of ``exp(-t**2)dt`` from 0 to `x`. .. function:: proc erf(x: real(32)): real(32) .. warning:: 'erf' is unstable and may be renamed or moved to a different module in the future Returns the error function of the argument `x`. This is equivalent to ``2/sqrt(pi)`` * the integral of ``exp(-t**2)dt`` from 0 to `x`. .. function:: proc erfc(x: real(64)): real(64) .. warning:: 'erfc' is unstable and may be renamed or moved to a different module in the future Returns the complementary error function of the argument `x`. This is equivalent to 1.0 - :proc:`erf`\(`x`). .. function:: proc erfc(x: real(32)): real(32) .. warning:: 'erfc' is unstable and may be renamed or moved to a different module in the future Returns the complementary error function of the argument `x`. This is equivalent to 1.0 - :proc:`erf`\(`x`). .. function:: proc exp(x: real(64)): real(64) Returns the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc exp(x: real(32)): real(32) Returns the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc exp(x: complex(64)): complex(64) Returns the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc exp(x: complex(128)): complex(128) Returns the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc exp2(x: real(64)): real(64) Returns the value of `2` raised to the power of the argument `x`. .. function:: proc exp2(x: real(32)): real(32) Returns the value of `2` raised to the power of the argument `x`. .. function:: proc expm1(x: real(64)): real(64) Returns one less than the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc expm1(x: real(32)): real(32) Returns one less than the value of the Napierian :param:`e` raised to the power of the argument `x`. .. function:: proc gamma(x: real(64)): real(64) Returns the gamma function of the argument `x`. .. function:: proc gamma(x: real(32)): real(32) Returns the gamma function of the argument `x`. .. function:: proc ldExp(x: real(64), exp: int(32)): real(64) Returns the value of the argument `x` multiplied by 2 raised to the argument `exp` power, i.e., ``x * 2**exp``. .. function:: proc ldExp(x: real(32), exp: int(32)): real(32) Returns the value of the argument `x` multiplied by 2 raised to the argument `exp` power, i.e., ``x * 2**exp``. .. function:: proc ldexp(x: real(64), n: int(32)): real(64) .. warning:: 'ldexp' with an 'n' argument has been deprecated, please use :proc:`ldExp` with an 'exp' argument instead Returns the value of the argument `x` multiplied by 2 raised to the argument `n` power, i.e., ``x * 2**n``. .. function:: proc ldexp(x: real(32), n: int(32)): real(32) .. warning:: 'ldexp' with an 'n' argument has been deprecated, please use :proc:`ldExp` with an 'exp' argument instead Returns the value of the argument `x` multiplied by 2 raised to the argument `n` power, i.e., ``x * 2**n``. .. function:: proc lnGamma(x: real(64)): real(64) Returns the natural logarithm of the absolute value of the gamma function of the argument `x`. .. function:: proc lnGamma(x: real(32)): real(32) Returns the natural logarithm of the absolute value of the gamma function of the argument `x`. .. function:: proc lgamma(x: real(64)): real(64) .. warning:: 'lgamma' has been deprecated in favor of :proc:`lnGamma`, please use that instead Returns the natural logarithm of the absolute value of the gamma function of the argument `x`. .. function:: proc lgamma(x: real(32)): real(32) .. warning:: 'lgamma' has been deprecated in favor of :proc:`lnGamma`, please use that instead Returns the natural logarithm of the absolute value of the gamma function of the argument `x`. .. function:: proc ln(x: real(64)): real(64) Returns the natural logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc ln(x: real(32)): real(32) Returns the natural logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc ln(x: complex(64)): complex(64) Returns the natural logarithm of the argument `x`. .. function:: proc ln(x: complex(128)): complex(128) Returns the natural logarithm of the argument `x`. .. function:: proc log(x: real(64)): real(64) Returns the natural logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log(x: real(32)): real(32) Returns the natural logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log(x: complex(64)): complex(64) Returns the natural logarithm of the argument `x`. .. function:: proc log(x: complex(128)): complex(128) Returns the natural logarithm of the argument `x`. .. function:: proc log10(x: real(64)): real(64) Returns the base 10 logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log10(x: real(32)): real(32) Returns the base 10 logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log1p(x: real(64)): real(64) Returns the natural logarithm of `x` + 1. It is an error if `x` is less than or equal to -1. .. function:: proc log1p(x: real(32)): real(32) Returns the natural logarithm of `x` + 1. It is an error if `x` is less than or equal to -1. .. function:: proc logBasePow2(x: int(?w), exp) .. warning:: 'logBasePow2' is unstable due to questions about its utility. If you rely on this function, please let us know! Returns the log to the base `2**exp` of the given `x` value. If `exp` is `1`, then returns the log to the base `2`; if `exp` is `2`, then returns the log to the base `4`, etc. Any fractional part is discarded. :rtype: `int` .. function:: proc logBasePow2(x: uint(?w), exp) .. warning:: 'logBasePow2' is unstable due to questions about its utility. If you rely on this function, please let us know! Returns the log to the base `2**exp` of the given `x` value. If `exp` is `1`, then returns the log to the base `2`; if `exp` is `2`, then returns the log to the base `4`, etc. Any fractional part is discarded. :rtype: `int` .. function:: proc logBasePow2(val: int(?w), baseLog2) .. warning:: The 'val' and 'baseLog2' argument names are now deprecated, please use 'x' and 'exp' respectively Returns the log to the base `2**baseLog2` of the given `in` value. If `baseLog2` is `1`, then returns the log to the base `2`; if `baseLog2` is `2`, then returns the log to the base `4`, etc. Any fractional part is discarded. :rtype: `int` .. function:: proc logBasePow2(val: uint(?w), baseLog2) .. warning:: The 'val' and 'baseLog2' argument names are now deprecated, please use 'x' and 'exp' respectively Returns the log to the base `2**baseLog2` of the given `in` value. If `baseLog2` is `1`, then returns the log to the base `2`; if `baseLog2` is `2`, then returns the log to the base `4`, etc. Any fractional part is discarded. :rtype: `int` .. function:: proc log2(x: real(64)): real(64) Returns the base 2 logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log2(x: real(32)): real(32) Returns the base 2 logarithm of the argument `x`. It is an error if `x` is less than or equal to zero. .. function:: proc log2(x: int(?w)) .. warning:: The version of 'log2' that takes an int argument is unstable Returns the base 2 logarithm of the argument `x`, rounded down. :rtype: `int` It is an error if `x` is less than or equal to zero. .. function:: proc log2(x: uint(?w)) .. warning:: The version of 'log2' that takes an uint argument is unstable Returns the base 2 logarithm of the argument `x`, rounded down. :rtype: `int` It is an error if `x` is equal to zero. .. function:: proc nearbyint(x: real(64)): real(64) .. warning:: nearbyint is unstable while we design more thorough rounding support Returns the rounded integral value of the argument `x` determined by the current rounding direction. :proc:`nearbyint` will not raise the "inexact" floating-point exception. .. function:: proc nearbyint(x: real(32)): real(32) .. warning:: nearbyint is unstable while we design more thorough rounding support Returns the rounded integral value of the argument `x` determined by the current rounding direction. :proc:`nearbyint` will not raise the "inexact" floating-point exception. .. function:: proc rint(x: real(64)): real(64) .. warning:: rint is unstable while we design more thorough rounding support Returns the rounded integral value of the argument `x` determined by the current rounding direction. :proc:`rint` may raise the "inexact" floating-point exception. .. function:: proc rint(x: real(32)): real(32) .. warning:: rint is unstable while we design more thorough rounding support Returns the rounded integral value of the argument `x` determined by the current rounding direction. :proc:`rint` may raise the "inexact" floating-point exception. .. function:: proc sin(x: real(64)): real(64) Returns the sine of the argument `x`. .. function:: proc sin(x: real(32)): real(32) Returns the sine of the argument `x`. .. function:: proc sin(x: complex(64)): complex(64) Returns the sine of the argument `x`. .. function:: proc sin(x: complex(128)): complex(128) Returns the sine of the argument `x`. .. function:: proc sinh(x: real(64)): real(64) Returns the hyperbolic sine of the argument `x`. .. function:: proc sinh(x: real(32)): real(32) Returns the hyperbolic sine of the argument `x`. .. function:: proc sinh(x: complex(64)): complex(64) Returns the hyperbolic sine of the argument `x`. .. function:: proc sinh(x: complex(128)): complex(128) Returns the hyperbolic sine of the argument `x`. .. function:: proc tan(x: real(64)): real(64) Returns the tangent of the argument `x`. .. function:: proc tan(x: real(32)): real(32) Returns the tangent of the argument `x`. .. function:: proc tan(x: complex(64)): complex(64) Returns the tangent of the argument `x`. .. function:: proc tan(x: complex(128)): complex(128) Returns the tangent of the argument `x`. .. function:: proc tanh(x: real(64)): real(64) Returns the hyperbolic tangent of the argument `x`. .. function:: proc tanh(x: real(32)): real(32) Returns the hyperbolic tangent of the argument `x`. .. function:: proc tanh(x: complex(64)): complex(64) Returns the hyperbolic tangent of the argument `x`. .. function:: proc tanh(x: complex(128)): complex(128) Returns the hyperbolic tangent of the argument `x`. .. function:: proc tgamma(x: real(64)): real(64) .. warning:: 'tgamma' has been deprecated in favor of :proc:`gamma`, please use that instead Returns the gamma function of the argument `x`. .. function:: proc tgamma(x: real(32)): real(32) .. warning:: 'tgamma' has been deprecated in favor of :proc:`gamma`, please use that instead Returns the gamma function of the argument `x`. .. function:: proc gcd(in x: int, in y: int): int Returns the greatest common divisor of the integer arguments `x` and `y`. .. function:: proc gcd(in x: int(32), in y: int(32)): int(32) Returns the greatest common divisor of the integer arguments `x` and `y`. .. function:: proc gcd(in x: int(16), in y: int(16)): int(16) Returns the greatest common divisor of the integer arguments `x` and `y`. .. function:: proc gcd(in x: int(8), in y: int(8)): int(8) Returns the greatest common divisor of the integer arguments `x` and `y`. .. function:: proc gcd(in x: uint(64), in y: uint(64)): uint(64) Returns the greatest common divisor of the unsigned integer arguments `x` and `y`. .. function:: proc gcd(in x: uint(32), in y: uint(32)): uint(32) Returns the greatest common divisor of the unsigned integer arguments `x` and `y`. .. function:: proc gcd(in x: uint(16), in y: uint(16)): uint(16) Returns the greatest common divisor of the unsigned integer arguments `x` and `y`. .. function:: proc gcd(in x: uint(8), in y: uint(8)): uint(8) Returns the greatest common divisor of the unsigned integer arguments `x` and `y`. .. function:: proc j0(x: real(32)): real(32) .. warning:: 'j0' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `0` of `x`. .. function:: proc j0(x: real(64)): real(64) .. warning:: 'j0' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `0` of `x`. .. function:: proc j1(x: real(32)): real(32) .. warning:: 'j1' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `1` of `x`. .. function:: proc j1(x: real(64)): real(64) .. warning:: 'j1' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `1` of `x`. .. function:: proc jn(n: int, x: real(32)): real(32) .. warning:: 'jn' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `n` of `x`. .. function:: proc jn(n: int, x: real(64)): real(64) .. warning:: 'jn' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the first kind of order `n` of `x`. .. function:: proc y0(x: real(32)): real(32) .. warning:: 'y0' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `0` of `x`, where `x` must be greater than 0. .. function:: proc y0(x: real(64)): real(64) .. warning:: 'y0' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `0` of `x`, where `x` must be greater than 0. .. function:: proc y1(x: real(32)): real(32) .. warning:: 'y1' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `1` of `x`, where `x` must be greater than 0. .. function:: proc y1(x: real(64)): real(64) .. warning:: 'y1' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `1` of `x`, where `x` must be greater than 0. .. function:: proc yn(n: int, x: real(32)): real(32) .. warning:: 'yn' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `n` of `x`, where `x` must be greater than 0. .. function:: proc yn(n: int, x: real(64)): real(64) .. warning:: 'yn' is unstable and may be renamed or moved to a different module in the future Returns the Bessel function of the second kind of order `n` of `x`, where `x` must be greater than 0. .. function:: proc fma(x: real(64), y: real(64), z: real(64)): real(64) .. warning:: The 'fma()' procedure was recently added, and may change based on feedback Performs a fused multiply-add operation that multiplies ``x`` and ``y`` and adds ``z`` to the result. The advantage of ``fma()`` over the expression ``(x*y)+z`` is that it avoids the additional error introduced by performing two separate floating point operations. It can also be faster on machines that implement the operation as a single instruction. .. note:: When compiling with ``CHPL_TARGET_COMPILER=llvm``, this procedure should reliably generate a single hardware instruction on ``x86`` if ``--specialize`` is thrown and ``CHPL_TARGET_CPU`` is set (provided that the ``x86`` CPU supports hardware FMA). When compiling with C, this procedure will call out to the ``fma()`` routines defined in the C header `math.h`. Any optimization performed is decided by the C compiler. .. function:: proc fma(x: real(32), y: real(32), z: real(32)): real(32) .. warning:: The 'fma()' procedure was recently added, and may change based on feedback .. function:: proc fma(x: imag(64), y: imag(64), z: imag(64)): imag(64) .. warning:: The 'fma()' procedure was recently added, and may change based on feedback .. function:: proc fma(x: imag(32), y: imag(32), z: imag(32)): imag(32) .. warning:: The 'fma()' procedure was recently added, and may change based on feedback