From 55d618143b3502113ecbf00475c100b58036cb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 17 Dec 2017 17:02:58 +0200 Subject: [PATCH] separate C header file for types Former-commit-id: 0c9797b04726c1d027a1eca96a5a7db3231403fc --- qpms/qpms_types.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ qpms/translations.h | 26 +++++++++++------------ qpms/types.py | 1 + qpms/vectors.h | 18 +--------------- 4 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 qpms/qpms_types.h diff --git a/qpms/qpms_types.h b/qpms/qpms_types.h new file mode 100644 index 0000000..4ce5e14 --- /dev/null +++ b/qpms/qpms_types.h @@ -0,0 +1,50 @@ +#ifndef QPMS_TYPES_H +#define QPMS_TYPES_H +#include +#include +#include +#define M_PI_2 (1.570796326794896619231321691639751442098584699687552910487) + +// integer index types +typedef int qpms_lm_t; +typedef size_t qpms_y_t; + +// Normalisations +typedef enum { + QPMS_NORMALIZATION_XU = 3, // NI! + QPMS_NORMALIZATION_KRISTENSSON = 2, // NI! + QPMS_NORMALIZATION_POWER = QPMS_NORMALIZATION_KRISTENSSON, // NI! + QPMS_NORMALIZATION_TAYLOR = 1, + QPMS_NORMALIZATION_UNDEF = 0 +} qpms_normalization_t; + +typedef enum { + QPMS_SUCCESS = 0; +} qpms_errno_t; + +typedef enum { + QPMS_BESSEL_REGULAR = 1, // regular function j + QPMS_BESSEL_SINGULAR = 2, // singular function y + QPMS_HANKEL_PLUS = 3, // hankel function h1 = j + I*y + QPMS_HANKEL_MINUS = 4, // hankel function h2 = j - I*y + QPMS_BESSEL_UNDEF = 0 +} qpms_bessel_t; + +// coordinate system types +typedef struct { + double x, y, z; +} cart3_t; + +typedef struct { + double x, y; +} cart2_t; + +typedef struct { + double r, theta, phi; +} sph_t; + +typedef struct { + double r, phi; +} pol_t; + +#endif // QPMS_TYPES diff --git a/qpms/translations.h b/qpms/translations.h index 30f9a04..61202ec 100644 --- a/qpms/translations.h +++ b/qpms/translations.h @@ -1,27 +1,18 @@ #ifndef QPMS_TRANSLATIONS_H #define QPMS_TRANSLATIONS_H #include "vectors.h" +#include "qpms_types.h" #include #include #include +// Associated Legendre polynomial at zero argument (DLMF 14.5.1) double qpms_legendre0(int m, int n); +// Associated Legendre polynomial derivative at zero argument (DLMF 14.5.2) double qpms_legendred0(int m, int n); - -typedef enum { - QPMS_NORMALIZATION_TAYLOR = 1, - QPMS_NORMALIZATION_UNDEF = 0 -} qpms_normalization_t; - -typedef enum { - QPMS_BESSEL_REGULAR = 1, // regular function j - QPMS_BESSEL_SINGULAR = 2, // singular function y - QPMS_HANKEL_PLUS = 3, // hankel function h1 = j + I*y - QPMS_HANKEL_MINUS = 4, // hankel function h2 = j - I*y - QPMS_BESSEL_UNDEF = 0 -} qpms_bessel_t; - int qpms_sph_bessel_array(qpms_bessel_t typ, int lmax, double x, complex double *result_array); +// TODO replace the xplicit "Taylor" functions with general, +// taking qpms_bessel_t argument. complex double qpms_trans_single_A_Taylor(int m, int n, int mu, int nu, sph_t kdlj, bool r_ge_d, qpms_bessel_t J); @@ -34,6 +25,13 @@ complex double qpms_trans_single_A_Taylor_ext(int m, int n, int mu, int nu, doub complex double qpms_trans_single_B_Taylor_ext(int m, int n, int mu, int nu, double kdlj_r, double kdlj_th, double kdlj_phi, int r_ge_d, int J); +// Electric wave N; NI +complex double qpms_vswf_single_el(int m, int n, sph_t kdlj, + qpms_bessel_t btyp, qpms_normalization_t norm); +// Magnetic wave M; NI +complex double qpms_vswf_single_mg(int m, int n, sph_t kdlj, + qpms_bessel_t btyp, qpms_normalization_t norm); + typedef struct qpms_trans_calculator { int lMax; diff --git a/qpms/types.py b/qpms/types.py index b56c059..7e25b7d 100644 --- a/qpms/types.py +++ b/qpms/types.py @@ -9,6 +9,7 @@ import enum class NormalizationT(enum.IntEnum): """ Corresponding to the c type qpms_normalization_t from translations.h """ + KRISTENSSON=2 # power-normalised, this should be the default in the future TAYLOR=1 UNDEF=0 diff --git a/qpms/vectors.h b/qpms/vectors.h index 3230223..a998741 100644 --- a/qpms/vectors.h +++ b/qpms/vectors.h @@ -2,23 +2,7 @@ #define VECTORS_H #include #define M_PI_2 (1.570796326794896619231321691639751442098584699687552910487) - -typedef struct { - double x, y, z; -} cart3_t; - -typedef struct { - double x, y; -} cart2_t; - -typedef struct { - double r, theta, phi; -} sph_t; - -typedef struct { - double r, phi; -} pol_t; - +#include "qpms_types.h" //static inline double vectors_h_sq(double x) {return x*x;}