MolSSI Integral Reference Project
math.h
Go to the documentation of this file.
1 /*! \file
2  *
3  * \brief Some miscellaneous mathematical functions and constants
4  */
5 
6 #pragma once
7 
8 #include <arb.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 /*! \brief Calculates the minimum value of two variables */
15 #define MIN(a,b) (((a)<(b))?(a):(b))
16 
17 
18 /*! \brief Calculates the maximum value of two variables */
19 #define MAX(a,b) (((a)>(b))?(a):(b))
20 
21 /*! \brief Smallest subnormal double-precision value */
22 #define MIRP_DBL_TRUE_MIN 4.9406564584124654e-324
23 
24 
25 /*! \brief Calculates (-1) to a given power
26  *
27  * This replaces pow(-1, n)
28  */
29 #define NEG1_POW(n) (((n)%2)?(-1):(1))
30 
31 
32 /*! \brief The value of the constant pi in double precision */
33 #define MIRP_PI 3.14159265358979324
34 
35 
36 /*! \brief The value of the sqrt(pi) in double precision */
37 #define MIRP_SQRT_PI 1.7724538509055160273
38 
39 
40 /*! \brief The value of the pi**(3/2) in double precision */
41 #define MIRP_PI_32 5.5683279968317078453
42 
43 
44 /*! \brief log_10(2)
45  *
46  * For conversion between binary precision and decimal precision
47  * (number of decimal digits)
48  *
49  * ndigits = log10(2) * precision (in bits)
50  */
51 #define MIRP_LOG_10_2 0.3010299956639812
52 
53 
54 /*! \brief Finds the least number of accuracy bits in a vector
55  *
56  * \param [in] v The vector to search the minimum accuracy of
57  * \param [in] n The length of the vector
58  * \return The minimum accuracy found of all elements of the vector
59  */
60 slong mirp_min_accuracy_bits(arb_srcptr v, size_t n);
61 
62 
63 /*! \brief Calculates b^e with e being a signed integer */
64 void mirp_pow_si(arb_t output, const arb_t b, long e, slong prec);
65 
66 
67 /*! \brief Calculates a factorial using interval arithmetic */
68 void mirp_factorial(arb_t output, long n);
69 
70 
71 /*! \brief Calculates a double factorial using interval arithmetic */
72 void mirp_factorial2(arb_t output, long n);
73 
74 
75 /*! \brief Calculates a binomial coefficient using interval arithmetic */
76 void mirp_binomial(arb_t output, long n, long k);
77 
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
void mirp_binomial(arb_t output, long n, long k)
Calculates a binomial coefficient using interval arithmetic.
Definition: math.c:77
slong mirp_min_accuracy_bits(arb_srcptr v, size_t n)
Finds the least number of accuracy bits in a vector.
Definition: math.c:11
void mirp_factorial(arb_t output, long n)
Calculates a factorial using interval arithmetic.
Definition: math.c:36
void mirp_factorial2(arb_t output, long n)
Calculates a double factorial using interval arithmetic.
Definition: math.c:53
void mirp_pow_si(arb_t output, const arb_t b, long e, slong prec)
Calculates b^e with e being a signed integer.
Definition: math.c:24