separate C header file for types

Former-commit-id: 0c9797b04726c1d027a1eca96a5a7db3231403fc
This commit is contained in:
Marek Nečada 2017-12-17 17:02:58 +02:00
parent 00a59e4320
commit 55d618143b
4 changed files with 64 additions and 31 deletions

50
qpms/qpms_types.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef QPMS_TYPES_H
#define QPMS_TYPES_H
#include <complex.h>
#include <stdbool.h>
#include <stddef.h>
#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

View File

@ -1,27 +1,18 @@
#ifndef QPMS_TRANSLATIONS_H
#define QPMS_TRANSLATIONS_H
#include "vectors.h"
#include "qpms_types.h"
#include <complex.h>
#include <stdbool.h>
#include <stddef.h>
// 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;

View File

@ -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

View File

@ -2,23 +2,7 @@
#define VECTORS_H
#include <math.h>
#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;}