Ian Jauslin
summaryrefslogtreecommitdiff
blob: 5b1d26f2213d295932dbdaa95fd117c7f0c9e50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Copyright 2016 Ian Jauslin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
  Preprocessor macros for integration using with long doubles
*/


// reset CPP macros
#undef INTEGRAL_FUNC
#undef INTEGRAL_FLOAT_TYPE
#undef INTEGRAL_FLOAT_INIT
#undef INTEGRAL_FLOAT_FREE
#undef INTEGRAL_FLOAT_SET_D
#undef INTEGRAL_FLOAT_SET_UI
#undef INTEGRAL_FLOAT_ADD
#undef INTEGRAL_FLOAT_SUB
#undef INTEGRAL_FLOAT_UI_SUB
#undef INTEGRAL_FLOAT_MUL
#undef INTEGRAL_FLOAT_POW_UI
#undef INTEGRAL_FLOAT_DIV
#undef INTEGRAL_FLOAT_DIV_UI
#undef INTEGRAL_FLOAT_ISNUMBER
#undef INTEGRAL_FLOATARRAY_TYPE
#undef INTEGRAL_FLOATARRAY_FUNC
#undef INTEGRAL_POLYNOMIAL_FUNC
#undef INTEGRAL_POLYNOMIALARRAY_TYPE
#undef INTEGRAL_POLYNOMIALARRAY_FUNC

// suffix of function names
#define INTEGRAL_FUNC(NAME) NAME ## _ldouble

// type of floats
#define INTEGRAL_FLOAT_TYPE long double
// set float from double
#define INTEGRAL_FLOAT_SET_D(FLOAT, VAL) FLOAT=(long double)VAL
// set float from unsigned int
#define INTEGRAL_FLOAT_SET_UI(FLOAT, VAL) FLOAT=(long double)VAL
// add floats
#define INTEGRAL_FLOAT_ADD(FLOAT, VAL1, VAL2) FLOAT=VAL1+VAL2
// subtract floats
#define INTEGRAL_FLOAT_SUB(FLOAT, VAL1, VAL2) FLOAT=VAL1-VAL2
// subtract floats in which the first is specified as an unsigned int
#define INTEGRAL_FLOAT_UI_SUB(FLOAT, VAL1, VAL2) FLOAT=(long double)VAL1-VAL2
// multiply floats
#define INTEGRAL_FLOAT_MUL(FLOAT, VAL1, VAL2) FLOAT=VAL1*VAL2
// power of a float, specified as an unsigned int
#define INTEGRAL_FLOAT_POW_UI(FLOAT, VAL1, VAL2) FLOAT=powl(VAL1, (long double)VAL2)
// divide floats
#define INTEGRAL_FLOAT_DIV(FLOAT, VAL1, VAL2) FLOAT=VAL1/VAL2
// divide floats, one of which is specified as an unsigned int
#define INTEGRAL_FLOAT_DIV_UI(FLOAT, VAL1, VAL2) FLOAT=VAL1/(long double)VAL2
// check whether a float is a regular number
#define INTEGRAL_FLOAT_ISNUMBER(FLOAT) (fpclassify(FLOAT)>=FP_ZERO)

// type of float arrays
#define INTEGRAL_FLOATARRAY_TYPE array_ldouble
// prefix of float array function names
#define INTEGRAL_FLOATARRAY_FUNC(NAME) array_ldouble_ ## NAME

// prefix of polynomial function names
#define INTEGRAL_POLYNOMIAL_FUNC(NAME) polynomial_ldouble_ ## NAME

// type of polynomial arrays
#define INTEGRAL_POLYNOMIALARRAY_TYPE array_polynomial_ldouble
// prefix of polynomial array function names
#define INTEGRAL_POLYNOMIALARRAY_FUNC(NAME) array_polynomial_ldouble_ ## NAME