chiark / gitweb /
can rescale
[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 #include <errno.h>
19 #include <string.h>
20
21 #include <gsl/gsl_vector.h>
22 #include <gsl/gsl_matrix.h>
23 #include <gsl/gsl_blas.h>
24 #include <gsl/gsl_linalg.h>
25
26 #define D3 3
27
28 double hypotD(const double p[D3], const double q[D3]);
29 double hypotD2(const double p[D3], const double q[D3]);
30 double hypotD2plus(const double p[D3], const double q[D3], double add);
31
32 double magnD(const double pq[D3]);
33 void xprod(double r[D3], const double a[D3], const double b[D3]);
34
35 void flushoutput(void);
36 void diee(const char *what);
37
38 #define FOR_COORD(k) \
39   for ((k)=0; (k)<D3; (k)++)
40
41 #define K FOR_COORD(k)
42
43 #ifdef FP_FAST_FMA
44 # define fma_fast fma
45 #else
46 # define fma_fast(f1,f2,t) ((f1)*(f2)+(t))
47 #endif
48 #define ffsqa(factor,term) fma_fast((factor),(factor),(term))
49
50 #endif /*COMMON_H*/