From 999dc7f72e28389f93967884a3e7042637fe97e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 26 Apr 2020 15:58:18 +0300 Subject: [PATCH] Move MIN,MAX,SQ macros to a common header Former-commit-id: 5f2598476b090ca3f9254325c1f69315182c8c30 --- qpms/ewald.c | 3 --- qpms/tiny_inlines.h | 13 +++++++++++++ qpms/tmatrices.c | 4 ---- qpms/translations.c | 2 -- qpms/wigner.c | 3 --- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qpms/ewald.c b/qpms/ewald.c index 1e30483..c992c50 100644 --- a/qpms/ewald.c +++ b/qpms/ewald.c @@ -29,9 +29,6 @@ #define M_SQRTPI 1.7724538509055160272981674833411452 #endif -#define MAX(x,y) ((x)<(y)?(y):(x)) -#define MIN(x,y) ((x)<(y)?(x):(y)) - // sloppy implementation of factorial static inline double factorial(const int n) { diff --git a/qpms/tiny_inlines.h b/qpms/tiny_inlines.h index b07c271..4531b4a 100644 --- a/qpms/tiny_inlines.h +++ b/qpms/tiny_inlines.h @@ -45,4 +45,17 @@ static inline complex double ipow(int x) { static inline int isq(int x) {return x * x;} +#ifndef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#endif + +#ifndef MAX +#define MAX(x, y) (((x) >= (y)) ? (x) : (y)) +#endif + +#ifndef SQ +#define SQ(x) ((x) * (x)) +#endif + + #endif // TINY_INLINES_H diff --git a/qpms/tmatrices.c b/qpms/tmatrices.c index 44b8ed0..5ae6beb 100644 --- a/qpms/tmatrices.c +++ b/qpms/tmatrices.c @@ -36,10 +36,6 @@ #define ELECTRONVOLT (1.602176487e-19) #define SCUFF_OMEGAUNIT (3e14) -#define SQ(x) ((x)*(x)) -#define MAX(x,y) ((x) < (y) ? (y) : (x)) -#define MIN(x,y) ((x) > (y) ? (y) : (x)) - qpms_tmatrix_t *qpms_tmatrix_init(const qpms_vswf_set_spec_t *bspec) { qpms_tmatrix_t *t; QPMS_CRASHING_MALLOC(t, sizeof(qpms_tmatrix_t)); diff --git a/qpms/translations.c b/qpms/translations.c index 5a00b19..b175ece 100644 --- a/qpms/translations.c +++ b/qpms/translations.c @@ -308,8 +308,6 @@ static inline size_t qpms_trans_calculator_index_yyu(const qpms_trans_calculator } -#define SQ(x) ((x)*(x)) - static inline double fsq(double x) {return x * x; } static void qpms_trans_calculator_multipliers_A( diff --git a/qpms/wigner.c b/qpms/wigner.c index bf16c65..07bd43c 100644 --- a/qpms/wigner.c +++ b/qpms/wigner.c @@ -3,9 +3,6 @@ #include "kahansum.h" #define WIGNER_ATOL (1e-15) -#define MIN(a,b) ((a)<(b)?(a):b) -#define MAX(a,b) ((a)>(b)?(a):b) - complex double qpms_wignerD_elem(const qpms_quat_t R, const qpms_l_t l, const qpms_m_t mp, const qpms_m_t m) { // TODO do some optimisations... The combinatoric coeffs could be precomputed.