From 74d7747fa35715d6e1c2307f587fe68339c11d27 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 16 Mar 2021 09:58:59 -0700 Subject: [PATCH] ircd::math: Add fallback for vectorized single-precision power of. --- include/ircd/math/math.h | 2 ++ include/ircd/math/pow.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/ircd/math/pow.h diff --git a/include/ircd/math/math.h b/include/ircd/math/math.h index 93b45277a..daeca759e 100644 --- a/include/ircd/math/math.h +++ b/include/ircd/math/math.h @@ -15,6 +15,7 @@ #include "inv.h" #include "mean.h" #include "tanh.h" +#include "pow.h" #include "fmma.h" #include "norm.h" @@ -22,4 +23,5 @@ namespace ircd { using math::mean; using math::tanh; + using math::pow; } diff --git a/include/ircd/math/pow.h b/include/ircd/math/pow.h new file mode 100644 index 000000000..894f5da3a --- /dev/null +++ b/include/ircd/math/pow.h @@ -0,0 +1,32 @@ +// Matrix Construct +// +// Copyright (C) Matrix Construct Developers, Authors & Contributors +// Copyright (C) 2016-2021 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_MATH_POW_H + +namespace ircd::math +{ + template + typename std::enable_if(), T>::type + pow(T, const E); +} + +template +inline typename std::enable_if(), T>::type +ircd::math::pow(T a, + const E e) +{ + for(uint i(0); i < simd::lanes(); ++i) + a[i] = std::pow(a[i], e); + + return a; +}