Added scalar functions cbrt as well as masked Rcp
[alexxy/gromacs.git] / src / gromacs / simd / scalar / scalar.h
index 25f0471a43ec6e71dc5c74f5fbf8a9dd1b7844a7..6beb22595dcbf960f37130d23c49b644a928f493 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019,2020, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -212,6 +212,21 @@ static inline float maskzFma(float a, float b, float c, float m)
     return m != 0.0F ? (a * b + c) : 0.0F;
 }
 
+/*! \brief Float 1.0/x, masked version.
+ *
+ * \param x Argument, x>0 for entries where mask is true.
+ * \param m Mask
+ * \return 1/x. The result for masked-out entries will be 0.0.
+ *
+ * \note This function might be superficially meaningless, but it helps us to
+ *       write templated SIMD/non-SIMD code. For clarity it should not be used
+ *       outside such code.
+ */
+static inline float gmx_simdcall maskzRcp(float x, float m)
+{
+    return m != 0.0F ? 1.0F / x : 0.0F;
+}
+
 /*! \brief Float Floating-point abs().
  *
  * \param a any floating point values
@@ -603,6 +618,21 @@ static inline double maskzFma(double a, double b, double c, double m)
     return m != 0.0 ? (a * b + c) : 0.0;
 }
 
+/*! \brief Double 1.0/x, masked version.
+ *
+ * \param x Argument, x>0 for entries where mask is true.
+ * \param m Mask
+ * \return Approximation of 1/x. The result for masked-out entries will be 0.0.
+ *
+ * \note This function might be superficially meaningless, but it helps us to
+ *       write templated SIMD/non-SIMD code. For clarity it should not be used
+ *       outside such code.
+ */
+static inline double gmx_simdcall maskzRcp(double x, double m)
+{
+    return m != 0.0 ? 1.0 / x : 0.0;
+}
+
 /*! \brief double doubleing-point abs().
  *
  * \param a any doubleing point values