diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-07-16 21:57:21 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-07-16 21:57:29 +0200 |
commit | 3b1767a3f4fd2f0ff2b03d7daa9307fce115b5ea (patch) | |
tree | 6aeff844fb24693880ee9ae3b48cd9d3d7b9b6f1 /aberth/util.h | |
parent | 5e23e6b4986bb31e15e37309ee6b55224a4a630a (diff) |
Add support for Christensen in CPU aberth
Diffstat (limited to 'aberth/util.h')
-rw-r--r-- | aberth/util.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/aberth/util.h b/aberth/util.h index a276e2a..49195b5 100644 --- a/aberth/util.h +++ b/aberth/util.h @@ -27,3 +27,14 @@ constexpr static T ceil2(T value) { if (value2 == 0) return value << 1; } } + +template <typename T> +constexpr static T ipow(T base, T ex) { + T x = 1, y = base; + while (ex > 0) { + if ((ex & 1) == 1) x *= y; + y *= y; + ex >>= 1; + } + return x; +} |