Math¶
Usage
use Math;
or
import Math;
This module provides less 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.
- 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.
- 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.
- proc logBasePow2(val: int(?w), baseLog2)¶
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.
- Return type
int
- proc logBasePow2(val: uint(?w), baseLog2)
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.
- Return type
int
- proc j0(x: real(32)): real(32)¶
Returns the Bessel function of the first kind of order 0 of x.
- proc j0(x: real(64)): real(64)
Returns the Bessel function of the first kind of order 0 of x.
- proc j1(x: real(32)): real(32)¶
Returns the Bessel function of the first kind of order 1 of x.
- proc j1(x: real(64)): real(64)
Returns the Bessel function of the first kind of order 1 of x.
- proc jn(n: int, x: real(32)): real(32)¶
Returns the Bessel function of the first kind of order n of x.
- proc jn(n: int, x: real(64)): real(64)
Returns the Bessel function of the first kind of order n of x.
- proc y0(x: real(32)): real(32)¶
Returns the Bessel function of the second kind of order 0 of x, where x must be greater than 0
- proc y0(x: real(64)): real(64)
Returns the Bessel function of the second kind of order 0 of x, where x must be greater than 0
- proc y1(x: real(32)): real(32)¶
Returns the Bessel function of the second kind of order 1 of x, where x must be greater than 0
- proc y1(x: real(64)): real(64)
Returns the Bessel function of the second kind of order 1 of x, where x must be greater than 0
- proc yn(n: int, x: real(32)): real(32)¶
Returns the Bessel function of the second kind of order n of x, where x must be greater than 0
- proc yn(n: int, x: real(64)): real(64)
Returns the Bessel function of the second kind of order n of x, where x must be greater than 0