chiark / gitweb /
a64221318b1112a9f951e271f64bab2e179790de
[moebius2.git] / common.h
1 /*
2  * Generally useful stuff.
3  */
4
5 #ifndef COMMON_H
6 #define COMMON_H
7
8 #ifndef _GNU_SOURCE
9 #define _GNU_SOURCE
10 #endif
11
12 #include <math.h>
13 #include <float.h>
14 #include <limits.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <assert.h>
18
19 #define D3 3
20
21 double hypotD(const double p[D3], const double q[D3]);
22 double hypotD2(const double p[D3], const double q[D3]);
23 double hypotD2plus(const double p[D3], const double q[D3], double add);
24
25 double magnD(const double pq[D3]);
26 void xprod(double r[D3], const double a[D3], const double b[D3]);
27
28 void flushoutput(void);
29 void diee(const char *what);
30
31 #define FOR_COORD(k) \
32   for ((k)=0; (k)<D3; (k)++)
33
34 #define K FOR_COORD(k)
35
36 #ifdef FP_FAST_FMA
37 # define fma_fast fma
38 #else
39 # define fma_fast(f1,f2,t) ((f1)*(f2)+(t))
40 #endif
41 #define ffsqa(factor,term) fma_fast((factor),(factor),(term))
42
43 #endif /*COMMON_H*/