2018-08-21 18:13:42 +03:00
|
|
|
#ifndef TINY_INLINES_H
|
|
|
|
#define TINY_INLINES_H
|
2018-08-27 09:45:11 +03:00
|
|
|
#include <stdlib.h>
|
2018-08-21 18:13:42 +03:00
|
|
|
|
|
|
|
static inline int min1pow(int pow) { return (pow % 2) ? -1 : 1; }
|
|
|
|
|
2018-09-10 15:28:41 +03:00
|
|
|
|
|
|
|
// This is useful for calculating spherical harmonics with negative m
|
|
|
|
// if spharm-normalised legendre functions for positive m are available.
|
2018-09-11 10:07:37 +03:00
|
|
|
// TODO: write a function that gets legendre buffer, m, n, and returns the correct spharm
|
|
|
|
// and use it in the code (mainly translations.c, ewald.c).
|
2018-09-10 15:28:41 +03:00
|
|
|
static inline int min1pow_m_neg(int m) {
|
|
|
|
return (m < 0) ? min1pow(m) : 1;
|
|
|
|
}
|
|
|
|
|
2018-08-21 18:13:42 +03:00
|
|
|
// this has shitty precision:
|
|
|
|
// static inline complex double ipow(int x) { return cpow(I, x); }
|
|
|
|
|
|
|
|
static inline complex double ipow(int x) {
|
|
|
|
x = ((x % 4) + 4) % 4;
|
|
|
|
switch(x) {
|
|
|
|
case 0:
|
|
|
|
return 1;
|
|
|
|
case 1:
|
|
|
|
return I;
|
|
|
|
case 2:
|
|
|
|
return -1;
|
|
|
|
case 3:
|
|
|
|
return -I;
|
2018-08-27 09:45:11 +03:00
|
|
|
default:
|
|
|
|
abort();
|
2018-08-21 18:13:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TINY_INLINES_H
|