QPMS
Electromagnetic multiple scattering library and toolkit.
tiny_inlines.h
Go to the documentation of this file.
1 
4 #ifndef TINY_INLINES_H
5 #define TINY_INLINES_H
6 #include <stdlib.h>
7 
8 static inline int min1pow(int pow) { return (pow % 2) ? -1 : 1; }
9 
10 
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;
17 }
18 
19 
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) {
24 
25  return;
26 }
27 #endif
28 #endif
29 
30 // this has shitty precision:
31 // static inline complex double ipow(int x) { return cpow(I, x); }
32 
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();
46  }
47 }
48 
49 static inline int isq(int x) {return x * x;}
50 
51 #ifndef MIN
52 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
53 #endif
54 
55 #ifndef MAX
56 #define MAX(x, y) (((x) >= (y)) ? (x) : (y))
57 #endif
58 
59 #ifndef SQ
60 #define SQ(x) ((x) * (x))
61 #endif
62 
63 
64 #endif // TINY_INLINES_H
int qpms_l_t
Type for spherical harmonic degree l.
Definition: qpms_types.h:27
qpms_lm_t qpms_m_t
Type for spherical harmonic order m.
Definition: qpms_types.h:31
A VSWF representation element of the qpms_l_t l
< The O(3) element in the quaternion representation.
Definition: quaternions.h:214