## Math Fallback

Math Fallback — Fallback implementations of standard mathematical functions

## Synopsis

    #include <libgwyddion/gwymathfallback.h>

    double              gwy_math_fallback_pow10             (double x);
    double              gwy_math_fallback_cbrt              (double x);
    double              gwy_math_fallback_hypot             (double x,
                                                             double y);
    double              gwy_math_fallback_acosh             (double x);
    double              gwy_math_fallback_asinh             (double x);
    double              gwy_math_fallback_atanh             (double x);
    #define             pow10
    #define             cbrt
    #define             hypot
    #define             acosh
    #define             asinh
    #define             atanh

## Description

Fallback functions `gwy_math_fallback_`foo`` are defined for mathematical functions ``foo`` that might not be implemented on all platforms and are commonly used in Gwyddion. These functions are always defined (as `static inline`), however, you should not use them as they can be less efficient or precise than the standard functions.

For each unavailable function (and only for those), this header file defines a replacement macro expanding to the name of the fallback function. Therefore after including it, you can use for instance `cbrt` regardless if the platform provides it or not. Note this header has to be included explicitly to avoid possible inadvertent clashes with other definitions of `cbrt`.

Since all replacement macros expand to names of functions, it is possible to take the address of any of them.

## Details

### gwy_math_fallback_pow10 ()

    double              gwy_math_fallback_pow10             (double x);

Fallback for the standard mathematical function `pow10`.

`x` : | Floating point number.
Returns : | 10 raised to `x`.

Since 2.9

### gwy_math_fallback_cbrt ()

    double              gwy_math_fallback_cbrt              (double x);

Fallback for the standard mathematical function `cbrt`.

`x` : | Floating point number.
Returns : | Cubic root of `x`.

Since 2.9

### gwy_math_fallback_hypot ()

    double              gwy_math_fallback_hypot             (double x,
                                                             double y);

Fallback for the standard mathematical function `hypot`.

`x` : | Floating point number.
`y` : | Floating point number.
Returns : | Length of hypotenuse of a right-angle triangle with sides of lengths `x` and `y`.

Since 2.9

### gwy_math_fallback_acosh ()

    double              gwy_math_fallback_acosh             (double x);

Fallback for the standard mathematical function `acosh`.

`x` : | Floating point number greater or equal to 1.0.
Returns : | Inverse hyperbolic cosine of `x`.

Since 2.9

### gwy_math_fallback_asinh ()

    double              gwy_math_fallback_asinh             (double x);

Fallback for the standard mathematical function `asinh`.

`x` : | Floating point number.
Returns : | Inverse hyperbolic sine of `x`.

Since 2.9

### gwy_math_fallback_atanh ()

    double              gwy_math_fallback_atanh             (double x);

Fallback for the standard mathematical function `atanh`.

`x` : | Floating point number in the range [-1, 1].
Returns : | Inverse hyperbolic tangent of `x`.

Since 2.9

### pow10

    #define pow10 gwy_math_fallback_pow10

Macro defined to `gwy_math_callback_pow10()` if the platform does not provide `pow10`.

### cbrt

    #define cbrt gwy_math_fallback_cbrt

Macro defined to `gwy_math_callback_cbrt()` if the platform does not provide `cbrt`.

### hypot

    #define hypot gwy_math_fallback_hypot

Macro defined to `gwy_math_callback_hypot()` if the platform does not provide `hypot`.

### acosh

    #define acosh gwy_math_fallback_acosh

Macro defined to `gwy_math_callback_acosh()` if the platform does not provide `acosh`.

### asinh

    #define asinh gwy_math_fallback_asinh

Macro defined to `gwy_math_callback_asinh()` if the platform does not provide `asinh`.

### atanh

    #define atanh gwy_math_fallback_atanh

Macro defined to `gwy_math_callback_atanh()` if the platform does not provide `atanh`.