/*
* 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.
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
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
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2016,2017,2019, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,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.
return std::sqrt(x);
}
+/*! \brief Float cbrt(x). This is the cubic root.
+ *
+ * \param x Argument, should be >= 0.
+ * \result The cubic root of x. Undefined if argument is invalid.
+ *
+ * \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.
+ */
+template<MathOptimization opt = MathOptimization::Safe>
+static inline float cbrt(float x)
+{
+ return std::cbrt(x);
+}
+
/*! \brief Float log(x). This is the natural logarithm.
*
* \param x Argument, should be >0.
return std::sqrt(x);
}
+/*! \brief Double cbrt(x). This is the cubic root.
+ *
+ * \param x Argument, should be >= 0.
+ * \result The cubic root of x. Undefined if argument is invalid.
+ *
+ * \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.
+ */
+template<MathOptimization opt = MathOptimization::Safe>
+static inline double cbrt(double x)
+{
+ return std::cbrt(x);
+}
+
/*! \brief Double log(x). This is the natural logarithm.
*
* \param x Argument, should be >0.