Notes on evaluating Δ_n factor in the lattice sums.
[qpms.git] / qpms / tiny_inlines.h
blob4531b4a32417a39fbc38c7f234ad4adec790a7eb
1 #ifndef TINY_INLINES_H
2 #define TINY_INLINES_H
3 #include <stdlib.h>
5 static inline int min1pow(int pow) { return (pow % 2) ? -1 : 1; }
8 // This is useful for calculating spherical harmonics with negative m
9 // if spharm-normalised legendre functions for positive m are available.
10 // TODO: write a function that gets legendre buffer, m, n, and returns the correct spharm
11 // and use it in the code (mainly translations.c, ewald.c).
12 static inline int min1pow_m_neg(int m) {
13 return (m < 0) ? min1pow(m) : 1;
17 #if 0
18 #ifdef __GSL_SF_LEGENDRE_H__
19 static inline complex double
20 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) {
22 return;
24 #endif
25 #endif
27 // this has shitty precision:
28 // static inline complex double ipow(int x) { return cpow(I, x); }
30 static inline complex double ipow(int x) {
31 x = ((x % 4) + 4) % 4;
32 switch(x) {
33 case 0:
34 return 1;
35 case 1:
36 return I;
37 case 2:
38 return -1;
39 case 3:
40 return -I;
41 default:
42 abort();
46 static inline int isq(int x) {return x * x;}
48 #ifndef MIN
49 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
50 #endif
52 #ifndef MAX
53 #define MAX(x, y) (((x) >= (y)) ? (x) : (y))
54 #endif
56 #ifndef SQ
57 #define SQ(x) ((x) * (x))
58 #endif
61 #endif // TINY_INLINES_H