3 Mathematical framework

3.1 General tools

The macros and functions of this paragraph are defined in pnl/pnl_mathtools.h.

3.1.1 Constants

A few mathematical constants are provided by the library. Most of them are actually already defined in math.h, values.h or limits.h and a few others have been added.

M_E

e1
M_LOG2E

log 2e
M_LOG10E

log 10e
M_LN2

log e2
M_LN10

log e10
M_PI

π
M_2PI

2π
M_PI_2

π∕2
M_PI_4

π∕4
M_1_PI

1∕π
M_2_PI

2∕π
M_2_SQRTPI

2√ π-
M_SQRT2PI

sqrt2π
M_SQRT2

√ --
  2
M_EULER

γ = lim n→∞(              )
 ∑n   -1- ln(n)
   k=1k
M_SQRT1_2

1√ --
  2
M_1_SQRT2PI

1√ ---
  2π
M_SQRT2_PI

∘ ----
  2∕π
INT_MAX

2147483647
MAX_INT

INT_MAX
DBL_MAX

1.79769313486231470e + 308
DOUBLE_MAX

DBL_MAX
DBL_EPSILON

2.2204460492503131e - 16
PNL_NEGINF

-∞
PNL_POSINF

+
PNL_INF

+
NAN

Not a Number

3.1.2 A few macros

3.1.3 Classifying a floating–point number

3.1.4 Rouding a floating–point number

3.1.5 Some standard mathematical functions

3.1.6 Comparison of floating–point numbers

3.2 Complex numbers

3.2.1 Overview

The complex type and related functions are defined in the header pnl/pnl_complex.h.

The first native implementation of complex numbers in the C language appeared in C99, which is unfortunately not available on all platforms. For this reason, we provide here an implementation of complex numbers.

typedef struct { 
    double r; /*!< real part */ 
    double i; /*!< imaginary part */ 
} dcomplex;

3.2.2 Constants

CZERO

0 as a complex number
CONE

1 as a complex number
CI

I the unit complex number

3.2.3 Functions

Most algebraic operations on complex numbers are implemented using the following naming for the functions

For example C_op_idamcb is id(    )
 a- b. So functions are :