Disable "hard" examples in CI
[qpms.git] / qpms / tiny_inlines.h
blobebde555a6ee8a1a5350628bb28c4fccc2a1fcdd0
1 /*! \file tiny_inlines.h
2 * \brief Simple but frequently used inline functions and macros.
3 */
4 #ifndef TINY_INLINES_H
5 #define TINY_INLINES_H
6 #include <stdlib.h>
8 static inline int min1pow(int pow) { return (pow % 2) ? -1 : 1; }
11 // This is useful for calculating spherical harmonics with negative m
12 // if spharm-normalised legendre functions for positive m are available.
13 // TODO: write a function that gets legendre buffer, m, n, and returns the correct spharm
14 // and use it in the code (mainly translations.c, ewald.c).
15 static inline int min1pow_m_neg(int m) {
16 return (m < 0) ? min1pow(m) : 1;
20 #if 0
21 #ifdef __GSL_SF_LEGENDRE_H__
22 static inline complex double
23 spharm_eval(gsl_sf_legendre_t P_normconv, int P_csphase, qpms_l_t l, qpms_m_t m, double P_n_abs_m, complex double exp_imf) {
25 return;
27 #endif
28 #endif
30 // this has shitty precision:
31 // static inline complex double ipow(int x) { return cpow(I, x); }
33 static inline complex double ipow(int x) {
34 x = ((x % 4) + 4) % 4;
35 switch(x) {
36 case 0:
37 return 1;
38 case 1:
39 return I;
40 case 2:
41 return -1;
42 case 3:
43 return -I;
44 default:
45 abort();
49 static inline int isq(int x) {return x * x;}
51 #ifndef MIN
52 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
53 #endif
55 #ifndef MAX
56 #define MAX(x, y) (((x) >= (y)) ? (x) : (y))
57 #endif
59 #ifndef SQ
60 #define SQ(x) ((x) * (x))
61 #endif
64 #endif // TINY_INLINES_H