aboutsummaryrefslogtreecommitdiffstats
path: root/src/video-math.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-02 17:30:22 +0200
committerMattias Andrée <maandree@kth.se>2017-07-02 17:30:22 +0200
commitc91c5cb8e892f1c19c970cef033cc03c9f47f98a (patch)
treecde7cfa7b9f3b80516459e2f5e773e6ffbd3e752 /src/video-math.h
parentAdd blind-norm (diff)
downloadblind-c91c5cb8e892f1c19c970cef033cc03c9f47f98a.tar.gz
blind-c91c5cb8e892f1c19c970cef033cc03c9f47f98a.tar.bz2
blind-c91c5cb8e892f1c19c970cef033cc03c9f47f98a.tar.xz
Add mod to blind-arithm
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/video-math.h')
-rw-r--r--src/video-math.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/video-math.h b/src/video-math.h
index 709afb9..fe0e604 100644
--- a/src/video-math.h
+++ b/src/video-math.h
@@ -17,6 +17,20 @@ nnpowf(float a, float b)
return neg ? -a : a;
}
+static inline double
+posmod(double a, double b)
+{
+ double x = fmod(a, b);
+ return x < 0 ? x + b : x;
+}
+
+static inline float
+posmodf(float a, float b)
+{
+ float x = fmodf(a, b);
+ return x < 0 ? x + b : x;
+}
+
#define GENERIC(TYPE, FUNC, ...)\
TYPE: FUNC(__VA_ARGS__),\
TYPE *: FUNC(__VA_ARGS__),\
@@ -52,6 +66,8 @@ nnpowf(float a, float b)
#define g_isinf(...) MATH_GENERIC_1(isinf, __VA_ARGS__)
#define g_isfinite(...) MATH_GENERIC_1(isfinite, __VA_ARGS__)
#define nnpow(...) MATH_GENERIC_N(nnpow, __VA_ARGS__)
+#define mod(...) MATH_GENERIC_N(fmod, __VA_ARGS__)
+#define posmod(...) MATH_GENERIC_N(posmod, __VA_ARGS__)
#define srgb_encode(...) BLIND_GENERIC_1(srgb_encode, __VA_ARGS__)
#define srgb_decode(...) BLIND_GENERIC_1(srgb_decode, __VA_ARGS__)