### 3.8 Single-argument math functions ¶

All of the functions described in this section are element-wise. For example, this code–

    Array<float,2> A, B;   //
    A = sin(B);

results in `A(i,j) = sin(B(i,j))` for all (i,j).

#### ANSI C++ math functions ¶

These math functions are available on all platforms:

`abs()` ¶

  Absolute value

`acos()` ¶

  Inverse cosine. For real arguments, the return value is in the range [0, \pi].

`arg()` ¶

  Argument of a complex number (`atan2(Im,Re)`).

`asin()` ¶

  Inverse sine. For real arguments, the return value is in the range [-\pi/2, \pi/2].

`atan()` ¶

  Inverse tangent. For real arguments, the return value is in the range [-\pi/2, \pi/2]. See also `atan2()` in section Two-argument math functions.

`ceil()` ¶

  Ceiling function: smallest floating-point integer value not less than the argument.

`cexp()` ¶

  Complex exponential; same as `exp()`.

`conj()` ¶

  Conjugate of a complex number.

`cos()` ¶

  Cosine. Works for `complex<T>`.

`cosh()` ¶

  Hyperbolic cosine. Works for `complex<T>`.

`csqrt()` ¶

  Complex square root; same as `sqrt()`.

`exp()` ¶

  Exponential. Works for `complex<T>`.

`fabs()` ¶

  Same as `abs()`.

`floor()` ¶

  Floor function: largest floating-point integer value not greater than the argument.

`log()` ¶

  Natural logarithm. Works for `complex<T>`.

`log10()` ¶

  Base 10 logarithm. Works for `complex<T>`.

`pow2(), pow3(), pow4(), pow5(), pow6(), pow7(), pow8()` ¶

  These functions compute an integer power. They expand to a series of multiplications, so they can be used on any type for which multiplication is well-defined.

`sin()` ¶

  Sine. Works for `complex<T>`.

`sinh()` ¶

  Hyperbolic sine. Works for `complex<T>`.

`sqr()` ¶

  Same as `pow2()`. Computes `x*x`. Works for `complex<T>`.

`sqrt()` ¶

  Square root. Works for `complex<T>`.

`tan()` ¶

  Tangent. Works for `complex<T>`.

`tanh()` ¶

  Hyperbolic tangent. Works for `complex<T>`.

#### IEEE/System V math functions ¶

These functions are only available on platforms which provide the IEEE Math library (libm.a) and/or System V Math Library (libmsaa.a). Apparently not all platforms provide all of these functions, so what you can use on your platform may be a subset of these. If you choose to use one of these functions, be aware that you may be limiting the portability of your code.

On some platforms, the preprocessor symbols `_XOPEN_SOURCE` and/or `_XOPEN_SOURCE_EXTENDED` need to be defined to use these functions. These symbols can be enabled by compiling with `-DBZ_ENABLE_XOPEN_SOURCE`. (In previous version of Blitz++, `_XOPEN_SOURCE` and `_XOPEN_SOURCE_EXTENDED` were declared by default. This was found to cause too many problems, so users must manually enable them with `-DBZ_ENABLE_XOPEN_SOURCE`.).

In the current version, Blitz++ divides these functions into two groups: IEEE and System V. This distinction is probably artificial. If one of the functions in a group is missing, Blitz++ won’t allow you to use any of them. You can see the division of these functions in the files `Blitz++/compiler/ieeemath.cpp` and `Blitz++/compiler/sysvmath.cpp`. This arrangement is unsatisfactory and will probably change in a future version.

You may have to link with `-lm` and/or `-lmsaa` to use these functions.

None of these functions are available for `complex<T>`.

`acosh()` ¶

  Inverse hyperbolic cosine

`asinh()` ¶

  Inverse hyperbolic sine

`atanh()` ¶

  Inverse hyperbolic tangent

`_class()` ¶

  Classification of floating point values. The return type is integer and will be one of:

  `FP_PLUS_NORM` ¶

    Positive normalized, nonzero

  `FP_MINUS_NORM` ¶

    Negative normalized, nonzero

  `FP_PLUS_DENORM` ¶

    Positive denormalized, nonzero

  `FP_MINUS_DENORM` ¶

    Negative denormalized, nonzero

  `FP_PLUS_ZERO` ¶

    +0.0

  `FP_MINUS_ZERO` ¶

    -0.0

  `FP_PLUS_INF` ¶

    Positive infinity

  `FP_MINUS_INF` ¶

    Negative infinity

  `FP_NANS` ¶

    Signalling Not a Number (NaNS)

  `FP_NANQ` ¶

    Quiet Not a Number (NaNQ)

`cbrt()` ¶

  Cubic root

`expm1()` ¶

  Computes exp(x)-1

`erf()` ¶

  Computes the error function: erf(x) = 2/sqrt(Pi) * integral(exp(-t^2), t=0..x)

  Note that for large values of the parameter, calculating can result in extreme loss of accuracy. Instead, use `erfc()`.

`erfc()` ¶

  Computes the complementary error function erfc(x) = 1 - erf(x).

`finite()` ¶

  Returns a nonzero integer if the parameter is a finite number (i.e. not +INF, -INF, NaNQ or NaNS).

`ilogb()` ¶

  Returns an integer which is equal to the unbiased exponent of the parameter.

`blitz_isnan()` ¶

  Returns a nonzero integer if the parameter is NaNQ or NaNS (quiet or signalling Not a Number).

`itrunc()` ¶

  Round a floating-point number to a signed integer. Returns the nearest signed integer to the parameter in the direction of 0.

`j0()` ¶

  Bessel function of the first kind, order 0.

`j1()` ¶

  Bessel function of the first kind, order 1.

`lgamma()` ¶

  Natural logarithm of the gamma function. The gamma function is defined as: Gamma(x) = integral(e^(-t) * t^(x-1), t=0..infinity))

`logb()` ¶

  Returns a floating-point double that is equal to the unbiased exponent of the parameter.

`log1p()` ¶

  Calculates log(1+x), where x is the parameter.

`nearest()` ¶

  Returns the nearest floating-point integer value to the parameter. If the parameter is exactly halfway between two integer values, an even value is returned.

`rint()` ¶

  Rounds the parameter and returns a floating-point integer value. Whether `rint()` rounds up or down or to the nearest integer depends on the current floating-point rounding mode. If you haven’t altered the rounding mode, `rint()` should be equivalent to `nearest()`. If rounding mode is set to round towards +INF, `rint()` is equivalent to `ceil()`. If the mode is round toward -INF, `rint()` is equivalent to `floor()`. If the mode is round toward zero, `rint()` is equivalent to `trunc()`.

`rsqrt()` ¶

  Reciprocal square root.

`uitrunc()` ¶

  Returns the nearest unsigned integer to the parameter in the direction of zero.

`y0()` ¶

  Bessel function of the second kind, order 0.

`y1()` ¶

  Bessel function of the second kind, order 1.

There may be better descriptions of these functions in your system man pages.