# AutoMath¶

Note

All Chapel programs automatically `use` this module by default. An explicit `use` statement is not necessary.

This module provides mathematical constants and functions.

Warning

The module name ‘AutoMath’ is unstable. If you want to use qualified naming on the symbols within it, please `use` or `import` the `Math` module.

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.

Rounding – The rounding mode for floating-point addition (subtraction) is implementation-defined.

Error Handling – At present, Chapel does not provide control over error handling in the AutoMath 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.

## Constant and Function Definitions¶

proc abs(x: int(?w))

Returns the absolute value of the integer argument.

Return type

The type of x.

proc abs(x: uint(?w))

Returns the absolute value of the unsigned integer argument.

Return type

The type of x.

proc abs(param x: integral) param

Returns the absolute value of the integer param argument x.

proc abs(x: real(64)): real(64)

Returns the magnitude of the real argument x.

proc abs(x: real(32)): real(32)

Returns the magnitude of the real argument x.

proc abs(x: imag(64)): real(64)

Returns the real magnitude of the imaginary argument x.

proc abs(x: imag(32)): real(32)

Returns the real magnitude of the imaginary argument x.

proc abs(x: complex(?w)): real(w/2)

Returns the magnitude (often called modulus) of complex x.

In concert with the related `phase` (a.k.a. argument) of x, it can be used to recompute x.

Return type

`real(w/2)` when x has a type of `complex(w)`.

proc abs(i: int(?w))

Returns the absolute value of the integer argument.

Return type

The type of i.

Warning

The argument name ‘i’ is deprecated for ‘abs’, please use ‘x’ instead

proc abs(i: uint(?w))

Returns the absolute value of the unsigned integer argument.

Return type

The type of i.

Warning

The argument name ‘i’ is deprecated for ‘abs’, please use ‘x’ instead

proc abs(param i: integral) param

Returns the absolute value of the integer param argument i.

Warning

The argument name ‘i’ is deprecated for param function ‘abs’, please use ‘x’ instead

proc abs(r: real(64)): real(64)

Returns the magnitude of the real argument r.

Warning

The argument name ‘r’ is deprecated for ‘abs’, please use ‘x’ instead

proc abs(im: imag(64)): real(64)

Returns the real magnitude of the imaginary argument im.

Warning

The argument name ‘im’ is deprecated for ‘abs’, please use ‘x’ instead

proc abs(im: imag(32)): real(32)

Returns the real magnitude of the imaginary argument im.

Warning

The argument name ‘im’ is deprecated for ‘abs’, please use ‘x’ instead

proc abs(z: complex(?w)): real(w/2)

Returns the magnitude (often called modulus) of complex z.

In concert with the related `phase` (a.k.a. argument) of z, it can be used to recompute z.

Return type

`real(w/2)` when z has a type of `complex(w)`.

Warning

The argument name ‘z’ is deprecated for ‘abs’, please use ‘x’ instead

proc carg(z: complex(?w)): real(w/2)

Returns the phase (often called argument) of complex z, an angle (in radians).

In concert with the related `abs`, the magnitude (a.k.a. modulus) of z, it can be used to recompute z.

Return type

`real(w/2)` when z has a type of `complex(w)`.

Warning

‘carg’ is deprecated, please use `phase` instead

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.

Warning

In an upcoming release ‘acos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘acos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc acos(z: complex(64)): complex(64)

Returns the arc cosine of the argument z.

Warning

In an upcoming release ‘acos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc acos(z: complex(128)): complex(128)

Returns the arc cosine of the argument z.

Warning

In an upcoming release ‘acos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘acosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘acosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc acosh(z: complex(64)): complex(64)

Returns the inverse hyperbolic cosine of the argument z.

Warning

In an upcoming release ‘acosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc acosh(z: complex(128)): complex(128)

Returns the inverse hyperbolic cosine of the argument z.

Warning

In an upcoming release ‘acosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘asin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘asin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asin(z: complex(64)): complex(64)

Returns the arc sine of the argument z.

Warning

In an upcoming release ‘asin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asin(z: complex(128)): complex(128)

Returns the arc sine of the argument z.

Warning

In an upcoming release ‘asin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asinh(x: real(64)): real(64)

Returns the inverse hyperbolic sine of the argument x.

Warning

In an upcoming release ‘asinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asinh(x: real(32)): real(32)

Returns the inverse hyperbolic sine of the argument x.

Warning

In an upcoming release ‘asinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asinh(z: complex(64)): complex(64)

Returns the inverse hyperbolic sine of the argument z.

Warning

In an upcoming release ‘asinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc asinh(z: complex(128)): complex(128)

Returns the inverse hyperbolic sine of the argument z.

Warning

In an upcoming release ‘asinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atan(x: real(64)): real(64)

Returns the arc tangent of the argument x.

Warning

In an upcoming release ‘atan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atan(x: real(32)): real(32)

Returns the arc tangent of the argument x.

Warning

In an upcoming release ‘atan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atan(z: complex(64)): complex(64)

Returns the arc tangent of the argument z.

Warning

In an upcoming release ‘atan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atan(z: complex(128)): complex(128)

Returns the arc tangent of the argument z.

Warning

In an upcoming release ‘atan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘atan2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atan2(y: real(32), x: real(32)): real(32)

Returns the arc tangent 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.

Warning

In an upcoming release ‘atan2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘atanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘atanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atanh(z: complex(64)): complex(64)

Returns the inverse hyperbolic tangent of the argument z.

Warning

In an upcoming release ‘atanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc atanh(z: complex(128)): complex(128)

Returns the inverse hyperbolic tangent of the argument z.

Warning

In an upcoming release ‘atanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cbrt(x: real(64)): real(64)

Returns the cube root of the argument x.

proc cbrt(x: real(32)): real(32)

Returns the cube root of the argument x.

proc ceil(x: real(64)): real(64)

Returns the value of the argument x rounded up to the nearest integer.

proc ceil(x: real(32)): real(32)

Returns the value of the argument x rounded up to the nearest integer.

proc conj(x: complex(?w))

Returns the complex conjugate of the complex argument x.

Return type

A complex number of the same type as x.

proc conj(x: imag(?w))

Returns the complex conjugate of the imaginary argument x.

Return type

An imaginary number of the same type as x.

proc conj(x: int(?w))

Returns the argument x.

Return type

A number that is not complex or imaginary of the same type as x.

proc conj(x: uint(?w))
proc conj(x: real(?w))
proc conjg(z: complex(?w))

Returns the complex conjugate of the complex argument z.

Return type

A complex number of the same type as z.

Warning

‘conjg’ with a ‘z’ argument has been deprecated, please use ‘conj’ with an ‘x’ argument instead

proc conjg(z: imag(?w))

Returns the complex conjugate of the imaginary argument z.

Return type

An imaginary number of the same type as z.

Warning

‘conjg’ with a ‘z’ argument has been deprecated, please use ‘conj’ with an ‘x’ argument instead

proc conjg(z: int(?w))

Returns the argument z.

Return type

A number that is not complex or imaginary of the same type as z.

Warning

‘conjg’ with a ‘z’ argument has been deprecated, please use ‘conj’ with an ‘x’ argument instead

proc conjg(z: uint(?w))

Warning

‘conjg’ with a ‘z’ argument has been deprecated, please use ‘conj’ with an ‘x’ argument instead

proc conjg(z: real(?w))

Warning

‘conjg’ with a ‘z’ argument has been deprecated, please use ‘conj’ with an ‘x’ argument instead

proc cproj(z: complex(?w)): complex(w)

Returns the projection of z on a Riemann sphere.

Warning

‘cproj’ has been deprecated, please use `riemProj` instead

proc cos(x: real(64)): real(64)

Returns the cosine of the argument x.

Warning

In an upcoming release ‘cos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cos(x: real(32)): real(32)

Returns the cosine of the argument x.

Warning

In an upcoming release ‘cos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cos(z: complex(64)): complex(64)

Returns the cosine of the argument z.

Warning

In an upcoming release ‘cos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cos(z: complex(128)): complex(128)

Returns the cosine of the argument z.

Warning

In an upcoming release ‘cos’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cosh(x: real(64)): real(64)

Returns the hyperbolic cosine of the argument x.

Warning

In an upcoming release ‘cosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cosh(x: real(32)): real(32)

Returns the hyperbolic cosine of the argument x.

Warning

In an upcoming release ‘cosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cosh(z: complex(64)): complex(64)

Returns the hyperbolic cosine of the argument z.

Warning

In an upcoming release ‘cosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc cosh(z: complex(128)): complex(128)

Returns the hyperbolic cosine of the argument z.

Warning

In an upcoming release ‘cosh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc divceil(param m: integral, param n: integral) param

Returns `ceil`(m/n), i.e., the fraction m/n rounded up to the nearest integer.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

Warning

In an upcoming release ‘divceil’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divCeil` and its argument names have changed to ‘x’ and ‘y’

proc divceil(m: integral, n: integral)

Returns `ceil`(m/n), i.e., the fraction m/n rounded up to the nearest integer.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

Warning

In an upcoming release ‘divceil’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divCeil` and its argument names have changed to ‘x’ and ‘y’

proc divceilpos(m: integral, n: integral)

A variant of `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).

Warning

In an upcoming release ‘divceilpos’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divCeilPos` and its argument names have changed to ‘x’ and ‘y’

proc divfloor(param m: integral, param n: integral) param

Returns `floor`(m/n), i.e., the fraction m/n rounded down to the nearest integer.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

Warning

In an upcoming release ‘divfloor’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divFloor` and its argument names have changed to ‘x’ and ‘y’

proc divfloor(m: integral, n: integral)

Returns `floor`(m/n), i.e., the fraction m/n rounded down to the nearest integer.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

Warning

In an upcoming release ‘divfloor’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divFloor` and its argument names have changed to ‘x’ and ‘y’

proc divfloorpos(m: integral, n: integral)

A variant of `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).

Warning

In an upcoming release ‘divfloorpos’ will no longer be included by default. Please ‘use’ or ‘import’ the `Math` module to prepare for this move, noting that its name has changed to `divFloorPos` and its argument names have changed to ‘x’ and ‘y’

proc erf(x: real(64)): real(64)

Warning

In an upcoming release ‘erf’ will no longer be included by default, please ‘use’ or ‘import’ the ‘Math’ module to call it

proc erf(x: real(32)): real(32)

Warning

In an upcoming release ‘erf’ will no longer be included by default, please ‘use’ or ‘import’ the ‘Math’ module to call it

proc erfc(x: real(64)): real(64)

Warning

In an upcoming release ‘erfc’ will no longer be included by default, please ‘use’ or ‘import’ the ‘Math’ module to call it

proc erfc(x: real(32)): real(32)

Warning

In an upcoming release ‘erfc’ will no longer be included by default, please ‘use’ or ‘import’ the ‘Math’ module to call it

proc exp(x: real(64)): real(64)

Returns the value of the Napierian e raised to the power of the argument x.

Warning

In an upcoming release ‘exp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc exp(x: real(32)): real(32)

Returns the value of the Napierian e raised to the power of the argument.

Warning

In an upcoming release ‘exp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc exp(z: complex(64)): complex(64)

Returns the value of the Napierian e raised to the power of the argument.

Warning

In an upcoming release ‘exp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc exp(z: complex(128)): complex(128)

Returns the value of the Napierian e raised to the power of the argument.

Warning

In an upcoming release ‘exp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc exp2(x: real(64)): real(64)

Returns the value of 2 raised to the power of the argument x.

Warning

In an upcoming release ‘exp2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc exp2(x: real(32)): real(32)

Returns the value of 2 raised to the power of the argument x.

Warning

In an upcoming release ‘exp2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc expm1(x: real(64)): real(64)

Returns one less than the value of the Napierian e raised to the power of the argument x.

Warning

In an upcoming release ‘expm1’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc expm1(x: real(32)): real(32)

Returns one less than the value of the Napierian e raised to the power of the argument x.

Warning

In an upcoming release ‘expm1’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc floor(x: real(64)): real(64)

Returns the value of the argument x rounded down to the nearest integer.

proc floor(x: real(32)): real(32)

Returns the value of the argument x rounded down to the nearest integer.

proc inf param: real(64)

Returns a value for which `isInf` will return true.

proc INFINITY param: real(64)

Returns a value for which `isInf` will return true.

Warning

‘INFINITY’ has been deprecated in favor of `inf`, please use that instead

proc isFinite(x: real(64)): bool

Returns true if the argument x is a representation of a finite value; false otherwise.

proc isFinite(x: real(32)): bool

Returns true if the argument x is a representation of a finite value; false otherwise.

proc isfinite(x: real(64)): bool

Returns true if the argument x is a representation of a finite value; false otherwise.

Warning

‘isfinite’ is deprecated in favor of `isFinite`, please use that instead

proc isfinite(x: real(32)): bool

Returns true if the argument x is a representation of a finite value; false otherwise.

Warning

‘isfinite’ is deprecated in favor of `isFinite`, please use that instead

proc isInf(x: real(64)): bool

Returns true if the argument x is a representation of infinity; false otherwise.

proc isInf(x: real(32)): bool

Returns true if the argument x is a representation of infinity; false otherwise.

proc isinf(x: real(64)): bool

Returns true if the argument x is a representation of infinity; false otherwise.

Warning

‘isinf’ is deprecated in favor of `isInf`, please use that instead

proc isinf(x: real(32)): bool

Returns true if the argument x is a representation of infinity; false otherwise.

Warning

‘isinf’ is deprecated in favor of `isInf`, please use that instead

proc isNan(x: real(64)): bool

Returns true if the argument x does not represent a valid number; false otherwise.

proc isNan(x: real(32)): bool

Returns true if the argument x does not represent a valid number; false otherwise.

proc isnan(x: real(64)): bool

Returns true if the argument x does not represent a valid number; false otherwise.

Warning

‘isnan’ is deprecated in favor of `isNan`, please use that instead

proc isnan(x: real(32)): bool

Returns true if the argument x does not represent a valid number; false otherwise.

Warning

‘isnan’ is deprecated in favor of `isNan`, please use that instead

proc ldexp(x: real(64), n: int(32)): real(64)

Warning

In an upcoming release ‘ldexp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the version in the Math module is now named ‘ldExp’

proc ldexp(x: real(32), n: int(32)): real(32)

Warning

In an upcoming release ‘ldexp’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the version in the Math module is now named ‘ldExp’

proc lgamma(x: real(64)): real(64)

Warning

In an upcoming release ‘lgamma’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the function has been renamed to ‘lnGamma’ there

proc lgamma(x: real(32)): real(32)

Warning

In an upcoming release ‘lgamma’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the function has been renamed to ‘lnGamma’ there

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.

Warning

In an upcoming release ‘log’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘log’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc log(z: complex(64)): complex(64)

Returns the natural logarithm of the argument z.

Warning

In an upcoming release ‘log’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc log(z: complex(128)): complex(128)

Returns the natural logarithm of the argument z.

Warning

In an upcoming release ‘log’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘log10’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘log10’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘log2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

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.

Warning

In an upcoming release ‘log2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc log2(val: int(?w))

Returns the base 2 logarithm of the argument x, rounded down.

Return type

int

It is an error if x is less than or equal to zero.

Warning

In an upcoming release ‘log2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc log2(val: uint(?w))

Returns the base 2 logarithm of the argument x, rounded down.

Return type

int

It is an error if x is less than or equal to zero.

Warning

In an upcoming release ‘log2’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc max(x, y)  where !isArray(x) && !isArray(y) && !(isNumeric(_desync(x.type)) && isNumeric(_desync(y.type)))

Returns the maximum value of two arguments using the `>` operator for comparison. If one of the arguments is `AutoMath.nan`, the result is also nan.

Return type

The type of x.

proc max(x, y, z ...?k)

Returns the maximum value of 3 or more arguments using the above call.

proc max(param x: numeric, param y: numeric) param  where !(isComplex(x) || isComplex(y))

Returns the maximum of 2 param `int`, `uint`, `real`, or `imag` values as a param.

proc min(x, y)  where !isArray(x) && !isArray(y) && !(isNumeric(_desync(x.type)) && isNumeric(_desync(y.type)))

Returns the minimum value of two arguments using the `<` operator for comparison.

If one of the arguments is `AutoMath.nan`, the result is also nan.

Return type

The type of x.

proc min(x, y, z ...?k)

Returns the minimum value of 3 or more arguments using the above call.

proc min(param x: numeric, param y: numeric) param  where !(isComplex(x) || isComplex(y))

Returns the minimum of 2 param `int`, `uint`, `real`, or `imag` values as a param.

proc mod(param m: integral, param n: integral) param

Computes the mod operator on the two arguments, defined as `mod(m,n) = m - n * floor(m / n)`.

The result is always >= 0 if n > 0. It is an error if n == 0.

Warning

The argument names ‘m’ and ‘n’ are deprecated for param ‘mod’, please use ‘x’ and ‘y’ instead

proc mod(m: integral, n: integral)

Computes the mod operator on the two arguments, defined as `mod(m,n) = m - n * floor(m / n)`.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

The result is always >= 0 if n > 0. It is an error if n == 0.

Warning

The argument names ‘m’ and ‘n’ are deprecated for ‘mod’, please use ‘x’ and ‘y’ instead

proc mod(param x: integral, param y: integral) param

Computes the mod operator on the two arguments, defined as `mod(x,y) = x - y * floor(x / y)`.

The result is always >= 0 if y > 0. It is an error if y == 0.

Note

This does not have the same behavior as the Modulus Operators (%) when y is negative.

proc mod(x: integral, y: integral)

Computes the mod operator on the two arguments, defined as `mod(x,y) = x - y * floor(x / y)`.

If the arguments are of unsigned type, then fewer conditionals will be evaluated at run time.

The result is always >= 0 if y > 0. It is an error if y == 0.

Note

This does not have the same behavior as the Modulus Operators (%) when y is negative.

proc mod(x: real(32), y: real(32)): real(32)

Computes the mod operator on the two numbers, defined as `mod(x,y) = x - y * floor(x / y)`.

proc mod(x: real(64), y: real(64)): real(64)

Computes the mod operator on the two numbers, defined as `mod(x,y) = x - y * floor(x / y)`.

proc nan param: real(64)

Returns a value for which `isNan` will return true.

proc NAN param: real(64)

Returns a value for which `isNan` will return true.

Warning

‘NAN’ is deprecated in favor of `nan`, please use that instead

proc nearbyint(x: real(64)): real(64)

Returns the rounded integral value of the argument x determined by the current rounding direction. `nearbyint` will not raise the “inexact” floating-point exception.

Warning

In an upcoming release ‘nearbyint’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc nearbyint(x: real(32)): real(32)

Returns the rounded integral value of the argument x determined by the current rounding direction. `nearbyint` will not raise the “inexact” floating-point exception.

Warning

In an upcoming release ‘nearbyint’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc phase(x: complex(?w)): real(w/2)

Returns the phase (often called argument) of complex x, an angle (in radians).

In concert with the related `abs`, the magnitude (a.k.a. modulus) of x, it can be used to recompute x.

Return type

`real(w/2)` when x has a type of `complex(w)`.

proc riemProj(x: complex(?w)): complex(w)

Returns the projection of x on a Riemann sphere.

proc rint(x: real(64)): real(64)

Returns the rounded integral value of the argument x determined by the current rounding direction. `rint` may raise the “inexact” floating-point exception.

Warning

In an upcoming release ‘rint’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc rint(x: real(32)): real(32)

Returns the rounded integral value of the argument x determined by the current rounding direction. `rint` may raise the “inexact” floating-point exception.

Warning

In an upcoming release ‘rint’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc round(x: real(64)): real(64)

Returns the nearest integral value of the argument x, returning that value which is larger than x in absolute value for the half-way case.

proc round(x: real(32)): real(32)

Returns the nearest integral value of the argument x, returning that value which is larger than x in absolute value for the half-way case.

proc sgn(i: int(?w)): int(8)

Returns the signum function of the integer argument i: 1 if positive, -1 if negative, 0 if zero.

Warning

The argument name ‘i’ is deprecated for ‘sgn’, please use ‘x’ instead

proc sgn(i: uint(?w)): uint(8)

Returns the signum function of the unsigned integer argument i: 1 if positive, -1 if negative, 0 if zero.

Warning

The argument name ‘i’ is deprecated for ‘sgn’, please use ‘x’ instead

proc sgn(param i: integral) param

Returns the signum function of the integer param argument i: 1 if positive, -1 if negative, 0 if zero.

Warning

The argument name ‘i’ is deprecated for param ‘sgn’, please use ‘x’ instead

proc sgn(x: int(?w)): int(8)

Returns the signum function of the integer argument x: 1 if positive, -1 if negative, 0 if zero.

proc sgn(x: uint(?w)): uint(8)

Returns the signum function of the unsigned integer argument x: 1 if positive, -1 if negative, 0 if zero.

proc sgn(param x: integral) param

Returns the signum function of the integer param argument x: 1 if positive, -1 if negative, 0 if zero.

proc sgn(x: real(?w)): int(8)

Returns the signum function of the real argument x: 1 if positive, -1 if negative, 0 if zero.

proc sin(x: real(64)): real(64)

Returns the sine of the argument x.

Warning

In an upcoming release ‘sin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sin(x: real(32)): real(32)

Returns the sine of the argument x.

Warning

In an upcoming release ‘sin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sin(z: complex(64)): complex(64)

Returns the sine of the argument z.

Warning

In an upcoming release ‘sin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sin(z: complex(128)): complex(128)

Returns the sine of the argument z.

Warning

In an upcoming release ‘sin’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sinh(x: real(64)): real(64)

Returns the hyperbolic sine of the argument x.

Warning

In an upcoming release ‘sinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sinh(x: real(32)): real(32)

Returns the hyperbolic sine of the argument x.

Warning

In an upcoming release ‘sinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sinh(z: complex(64)): complex(64)

Returns the hyperbolic sine of the argument z.

Warning

In an upcoming release ‘sinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sinh(z: complex(128)): complex(128)

Returns the hyperbolic sine of the argument z.

Warning

In an upcoming release ‘sinh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc sqrt(x: real(64)): real(64)

Returns the square root of the argument x.

It is an error if the x is less than zero.

proc sqrt(x: real(32)): real(32)

Returns the square root of the argument x.

It is an error if x is less than zero.

proc sqrt(x: complex(64)): complex(64)

Returns the square root of the argument z.

proc sqrt(x: complex(128)): complex(128)

Returns the square root of the argument z.

proc sqrt(z: complex(64)): complex(64)

Returns the square root of the argument z.

Warning

The argument name ‘z’ is deprecated for ‘sqrt’, please use ‘x’ instead

proc sqrt(z: complex(128)): complex(128)

Returns the square root of the argument z.

Warning

The argument name ‘z’ is deprecated for ‘sqrt’, please use ‘x’ instead

proc tan(x: real(64)): real(64)

Returns the tangent of the argument x.

Warning

In an upcoming release ‘tan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tan(x: real(32)): real(32)

Returns the tangent of the argument x.

Warning

In an upcoming release ‘tan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tan(z: complex(64)): complex(64)

Returns the tangent of the argument z.

Warning

In an upcoming release ‘tan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tan(z: complex(128)): complex(128)

Returns the tangent of the argument z.

Warning

In an upcoming release ‘tan’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tanh(x: real(64)): real(64)

Returns the hyperbolic tangent of the argument x.

Warning

In an upcoming release ‘tanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tanh(x: real(32)): real(32)

Returns the hyperbolic tangent of the argument x.

Warning

In an upcoming release ‘tanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tanh(z: complex(64)): complex(64)

Returns the hyperbolic tangent of the argument z.

Warning

In an upcoming release ‘tanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tanh(z: complex(128)): complex(128)

Returns the hyperbolic tangent of the argument z.

Warning

In an upcoming release ‘tanh’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc tgamma(x: real(64)): real(64)

Warning

In an upcoming release ‘tgamma’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the function has been renamed to ‘gamma’ there

proc tgamma(x: real(32)): real(32)

Warning

In an upcoming release ‘tgamma’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it. Note that the function has been renamed to ‘gamma’ there

proc trunc(x: real(64)): real(64)

Returns the nearest integral value to the argument x that is not larger than x in absolute value.

proc trunc(x: real(32)): real(32)

Returns the nearest integral value to the argument x that is not larger than x in absolute value.

proc gcd(in a: int, in b: int): int

Returns the greatest common divisor of the integer argument a and b.

Warning

In an upcoming release ‘gcd’ will no longer be included by default, please ‘use’ or ‘import’ the `Math` module to call it

proc isClose(x, y, relTol = 1e-5, absTol = 0.0): bool

Returns true if x and y are approximately equal, else returns false.

relTol specifies the relative tolerance for differences between x and y, while absTol specifies the absolute tolerance. Both must be positive when specified.

x and y must be either real, imag, or complex.

proc isclose(x, y, rtol = 1e-5, atol = 0.0): bool

Returns true if x and y are approximately equal, else returns false.

Warning

isclose with ‘rtol’ and ‘atol’ arguments is now deprecated, please use `isClose` with ‘relTol’ and ‘absTol’ arguments instead

proc signbit(x: real(32)): bool

Returns true if the sign of x is negative, else returns false. It detects the sign bit of zeroes, infinities, and nans

Warning

signbit is unstable and may change its name in the future

proc signbit(x: real(64)): bool

Returns true if the sign of x is negative, else returns false. It detects the sign bit of zeroes, infinities, and nans

Warning

signbit is unstable and may change its name in the future