Core: Unify scalar math dispatch through numext and extend SYCL support

libeigen/eigen!3437

diff --git a/Eigen/src/Cholesky/BunchKaufman.h b/Eigen/src/Cholesky/BunchKaufman.h
index 63462cb..1f2285b 100644
--- a/Eigen/src/Cholesky/BunchKaufman.h
+++ b/Eigen/src/Cholesky/BunchKaufman.h
@@ -394,7 +394,7 @@
  * (Bunch & Kaufman, 1977). */
 template <typename RealScalar>
 EIGEN_DEVICE_FUNC inline RealScalar bunch_kaufman_alpha() {
-  using std::sqrt;
+  using numext::sqrt;
   return (RealScalar(1) + sqrt(RealScalar(17))) / RealScalar(8);
 }
 
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h
index 12a377d..0fecdf9 100644
--- a/Eigen/src/Cholesky/LDLT.h
+++ b/Eigen/src/Cholesky/LDLT.h
@@ -779,7 +779,7 @@
   // dst = D^-* (L^-1 P b)
   // dst = D^-1 (L^-*T P b)
   // more precisely, use pseudo-inverse of D (see bug 241)
-  using std::abs;
+  using numext::abs;
   const typename Diagonal<const MatrixType>::RealReturnType vecD(vectorD());
   // In some previous versions, tolerance was set to the max of 1/highest (or rather numeric_limits::min())
   // and the maximal diagonal entry * epsilon as motivated by LAPACK's xGELSS:
diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h
index 716f9d5..d13a5c2 100644
--- a/Eigen/src/Cholesky/LLT.h
+++ b/Eigen/src/Cholesky/LLT.h
@@ -321,7 +321,7 @@
 template <typename MatrixType, typename VectorType>
 static Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec,
                                    const typename MatrixType::RealScalar& sigma) {
-  using std::sqrt;
+  using numext::sqrt;
   using Scalar = typename MatrixType::Scalar;
   using RealScalar = typename MatrixType::RealScalar;
   using ColXpr = typename MatrixType::ColXpr;
@@ -387,7 +387,7 @@
   using RealScalar = typename NumTraits<Scalar>::Real;
   template <typename MatrixType>
   static Index unblocked(MatrixType& mat) {
-    using std::sqrt;
+    using numext::sqrt;
 
     EIGEN_INTERNAL_ASSERT_SQUARE(mat);
     const Index size = mat.rows();
diff --git a/Eigen/src/CholmodSupport/CholmodSupport.h b/Eigen/src/CholmodSupport/CholmodSupport.h
index eb0877d..cec6726 100644
--- a/Eigen/src/CholmodSupport/CholmodSupport.h
+++ b/Eigen/src/CholmodSupport/CholmodSupport.h
@@ -410,15 +410,11 @@
   }
 
   /** \returns the determinant of the underlying matrix from the current factorization */
-  Scalar determinant() const {
-    using std::exp;
-    return exp(logDeterminant());
-  }
+  Scalar determinant() const { return numext::exp(logDeterminant()); }
 
   /** \returns the log determinant of the underlying matrix from the current factorization */
   Scalar logDeterminant() const {
     using numext::real;
-    using std::log;
     eigen_assert(m_factorizationIsOk &&
                  "The decomposition is not in a valid state for solving, you must first call either compute() or "
                  "symbolic()/numeric()");
@@ -448,7 +444,7 @@
       // Simplicial factorization stored as standard CSC matrix.
       StorageIndex* p = static_cast<StorageIndex*>(m_cholmodFactor->p);
       Index size = m_cholmodFactor->n;
-      for (Index k = 0; k < size; ++k) logDet += log(real(x[p[k]]));
+      for (Index k = 0; k < size; ++k) logDet += numext::log(real(x[p[k]]));
     }
     if (m_cholmodFactor->is_ll) logDet *= 2.0;
     return logDet;
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index 7d40a34..391dd64 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -478,8 +478,7 @@
 struct lpNorm_selector {
   using RealScalar = typename NumTraits<typename traits<Derived>::Scalar>::Real;
   EIGEN_DEVICE_FUNC static inline RealScalar run(const MatrixBase<Derived>& m) {
-    EIGEN_USING_STD(pow)
-    return pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1) / p);
+    return numext::pow(m.cwiseAbs().array().pow(p).sum(), RealScalar(1) / p);
   }
 };
 
diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h
index 9a845a3..f83c848 100644
--- a/Eigen/src/Core/GenericPacketMath.h
+++ b/Eigen/src/Core/GenericPacketMath.h
@@ -795,7 +795,7 @@
  */
 template <typename Packet>
 EIGEN_DEVICE_FUNC inline Packet pldexp(const Packet& a, const Packet& exponent) {
-  EIGEN_USING_STD(ldexp)
+  using numext::ldexp;
   return static_cast<Packet>(ldexp(a, static_cast<int>(exponent)));
 }
 
@@ -1308,85 +1308,73 @@
 /** \internal \returns the sine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin(const Packet& a) {
-  EIGEN_USING_STD(sin);
-  return sin(a);
+  return numext::sin(a);
 }
 
 /** \internal \returns the cosine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcos(const Packet& a) {
-  EIGEN_USING_STD(cos);
-  return cos(a);
+  return numext::cos(a);
 }
 
 /** \internal \returns the tan of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptan(const Packet& a) {
-  EIGEN_USING_STD(tan);
-  return tan(a);
+  return numext::tan(a);
 }
 
 /** \internal \returns the arc sine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pasin(const Packet& a) {
-  EIGEN_USING_STD(asin);
-  return asin(a);
+  return numext::asin(a);
 }
 
 /** \internal \returns the arc cosine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pacos(const Packet& a) {
-  EIGEN_USING_STD(acos);
-  return acos(a);
+  return numext::acos(a);
 }
 
 /** \internal \returns the hyperbolic sine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psinh(const Packet& a) {
-  EIGEN_USING_STD(sinh);
-  return sinh(a);
+  return numext::sinh(a);
 }
 
 /** \internal \returns the hyperbolic cosine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcosh(const Packet& a) {
-  EIGEN_USING_STD(cosh);
-  return cosh(a);
+  return numext::cosh(a);
 }
 
 /** \internal \returns the arc tangent of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet patan(const Packet& a) {
-  EIGEN_USING_STD(atan);
-  return atan(a);
+  return numext::atan(a);
 }
 
 /** \internal \returns the hyperbolic tan of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptanh(const Packet& a) {
-  EIGEN_USING_STD(tanh);
-  return tanh(a);
+  return numext::tanh(a);
 }
 
 /** \internal \returns the arc tangent of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet patanh(const Packet& a) {
-  EIGEN_USING_STD(atanh);
-  return atanh(a);
+  return numext::atanh(a);
 }
 
 /** \internal \returns the inverse hyperbolic sine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pasinh(const Packet& a) {
-  EIGEN_USING_STD(asinh);
-  return asinh(a);
+  return numext::asinh(a);
 }
 
 /** \internal \returns the inverse hyperbolic cosine of \a a (coeff-wise) */
 template <typename Packet>
 EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pacosh(const Packet& a) {
-  EIGEN_USING_STD(acosh);
-  return acosh(a);
+  return numext::acosh(a);
 }
 
 /** \internal \returns the exp of \a a (coeff-wise) */
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
index 0605cb9..24fdcc5 100644
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -1375,6 +1375,10 @@
   return EIGEN_MATHFUNC_IMPL(copysign, Scalar)::run(x, y);
 }
 
+#if defined(EIGEN_SYCL_DEVICE_ONLY)
+SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(copysign, copysign)
+#endif
+
 template <typename Scalar>
 EIGEN_DEVICE_FUNC inline Scalar negate(const Scalar& x) {
   return EIGEN_MATHFUNC_IMPL(negate, Scalar)::run(x);
@@ -1498,6 +1502,7 @@
 }
 
 #if defined(EIGEN_SYCL_DEVICE_ONLY)
+SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(rint, rint)
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(round, round)
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(floor, floor)
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(ceil, ceil)
@@ -1570,6 +1575,25 @@
   return log2(x);
 }
 
+#if defined(EIGEN_SYCL_DEVICE_ONLY)
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log10(float x) {
+  return cl::sycl::log10(x);
+}
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log10(double x) {
+  return cl::sycl::log10(x);
+}
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float log2(float x) {
+  return cl::sycl::log2(x);
+}
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double log2(double x) {
+  return cl::sycl::log2(x);
+}
+#endif
+
 /** Log base 2 for 32 bits positive integers.
  * Conveniently returns 0 for x==0. */
 constexpr int log2(int x) {
@@ -1608,6 +1632,14 @@
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(sqrt, sqrt)
 #endif
 
+#if defined(EIGEN_VECTORIZE_SSE)
+// Half/BFloat16 scalar wrappers precede the SSE definitions and must not instantiate the primary template.
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE float sqrt(const float& x);
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double sqrt(const double& x);
+#endif
+
 /** \returns the cube root of \a x. **/
 template <typename T>
 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::enable_if_t<!NumTraits<T>::IsComplex, T> cbrt(const T& x) {
@@ -1621,6 +1653,10 @@
   return pow(x, typename NumTraits<T>::Real(1.0 / 3.0));
 }
 
+#if defined(EIGEN_SYCL_DEVICE_ONLY)
+SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(cbrt, cbrt)
+#endif
+
 /** \returns the reciprocal square root of \a x. **/
 template <typename T>
 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T rsqrt(const T& x) {
@@ -2011,6 +2047,7 @@
 }
 
 #if defined(EIGEN_SYCL_DEVICE_ONLY)
+SYCL_SPECIALIZE_FLOATING_TYPES_BINARY(atan2, atan2)
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atan, atan)
 SYCL_SPECIALIZE_FLOATING_TYPES_UNARY(atanh, atanh)
 #endif
diff --git a/Eigen/src/Core/MathFunctionsImpl.h b/Eigen/src/Core/MathFunctionsImpl.h
index b97a069..d1dd784 100644
--- a/Eigen/src/Core/MathFunctionsImpl.h
+++ b/Eigen/src/Core/MathFunctionsImpl.h
@@ -157,10 +157,10 @@
   if ((numext::isinf)(x) || (numext::isinf)(y)) return NumTraits<RealScalar>::infinity();
   if ((numext::isnan)(x) || (numext::isnan)(y)) return NumTraits<RealScalar>::quiet_NaN();
 
-  EIGEN_USING_STD(sqrt);
   RealScalar p = numext::maxi(x, y);
   if (numext::is_exactly_zero(p)) return RealScalar(0);
   RealScalar qp = numext::mini(y, x) / p;
+  using numext::sqrt;
   return p * sqrt(RealScalar(1) + qp * qp);
 }
 
@@ -272,8 +272,7 @@
   // Computes complex log.
   using T = typename NumTraits<ComplexT>::Real;
   T a = numext::abs(z);
-  EIGEN_USING_STD(atan2);
-  T b = atan2(z.imag(), z.real());
+  T b = numext::atan2(z.imag(), z.real());
   // log|z| is finite where |z| itself overflows or rounds to a subnormal: scale z exactly by a power of two first.
   if (EIGEN_PREDICT_FALSE((numext::isinf)(a) && (numext::isfinite)(z.real()) && (numext::isfinite)(z.imag()))) {
     const T half = T(0.5);
@@ -292,8 +291,7 @@
 EIGEN_DEVICE_FUNC ComplexT complex_log2(const ComplexT& z) {
   using T = typename NumTraits<ComplexT>::Real;
   const T a = numext::abs(z);
-  EIGEN_USING_STD(atan2);
-  const T b = T(EIGEN_LOG2E) * atan2(z.imag(), z.real());
+  const T b = T(EIGEN_LOG2E) * numext::atan2(z.imag(), z.real());
   if (EIGEN_PREDICT_FALSE((numext::isinf)(a) && (numext::isfinite)(z.real()) && (numext::isfinite)(z.imag()))) {
     const T half = T(0.5);
     return ComplexT(numext::log2(numext::abs(ComplexT(z.real() * half, z.imag() * half))) + T(1), b);
diff --git a/Eigen/src/Core/RankRevealingBase.h b/Eigen/src/Core/RankRevealingBase.h
index 45d1393..a45d187 100644
--- a/Eigen/src/Core/RankRevealingBase.h
+++ b/Eigen/src/Core/RankRevealingBase.h
@@ -93,7 +93,7 @@
    *       setThreshold(const RealScalar&).
    */
   inline Index rank() const {
-    using std::abs;
+    using numext::abs;
     eigen_assert(self().m_isInitialized && "Decomposition is not initialized.");
     RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold();
     Index result = 0;
diff --git a/Eigen/src/Core/SafeScaling.h b/Eigen/src/Core/SafeScaling.h
index ddc3b83..c719024 100644
--- a/Eigen/src/Core/SafeScaling.h
+++ b/Eigen/src/Core/SafeScaling.h
@@ -692,7 +692,7 @@
     if (exponent < kMinScaleExponent) exponent = kMinScaleExponent;
     if (exponent > kMaxScaleExponent) exponent = kMaxScaleExponent;
 
-    EIGEN_USING_STD(ldexp);
+    using numext::ldexp;
     const long double scale = ldexp(1.0L, exponent);
     return {scale, 1.0L / scale};
   }
diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h
index 654d78c..2fbf48d 100644
--- a/Eigen/src/Core/StableNorm.h
+++ b/Eigen/src/Core/StableNorm.h
@@ -157,7 +157,7 @@
 template <typename VectorType,
           std::enable_if_t<VectorType::IsVectorAtCompileTime && VectorType::MaxSizeAtCompileTime != 0, int> = 0>
 typename VectorType::RealScalar stable_norm_impl(const VectorType& vec) {
-  using std::sqrt;
+  using numext::sqrt;
 
   Index n = vec.size();
   if (EIGEN_PREDICT_FALSE(n == 1)) return numext::abs(vec.coeff(0));
@@ -176,7 +176,7 @@
 template <typename MatrixType,
           std::enable_if_t<!MatrixType::IsVectorAtCompileTime && MatrixType::MaxSizeAtCompileTime != 0, int> = 0>
 typename MatrixType::RealScalar stable_norm_impl(const MatrixType& mat) {
-  using std::sqrt;
+  using numext::sqrt;
 
   using RealScalar = typename MatrixType::RealScalar;
   using Accumulator = typename stable_norm_accumulator<RealScalar>::type;
@@ -233,8 +233,8 @@
   using RealScalar = typename Derived::RealScalar;
   using Accumulator = typename stable_norm_accumulator<RealScalar>::type;
   using Scalar = typename traits<Derived>::Scalar;
+  using numext::sqrt;
   using std::pow;
-  using std::sqrt;
 
   const Derived& vec(_vec.derived());
   if (vec.size() == 0) return RealScalar(0);
diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h
index 70f348e..6312932 100644
--- a/Eigen/src/Core/arch/Default/BFloat16.h
+++ b/Eigen/src/Core/arch/Default/BFloat16.h
@@ -733,14 +733,8 @@
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16& a) { return bfloat16(numext::log(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log1p(const bfloat16& a) { return bfloat16(numext::log1p(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log10(const bfloat16& a) { return bfloat16(numext::log10(float(a))); }
-EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log2(const bfloat16& a) {
-  return bfloat16(static_cast<float>(EIGEN_LOG2E) * numext::log(float(a)));
-}
-EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sqrt(const bfloat16& a) {
-  // numext::sqrt<float> would be instantiated here, before the SSE specialization is declared.
-  EIGEN_USING_STD(sqrt);
-  return bfloat16(sqrt(float(a)));
-}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log2(const bfloat16& a) { return bfloat16(numext::log2(float(a))); }
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sqrt(const bfloat16& a) { return bfloat16(numext::sqrt(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 cbrt(const bfloat16& a) { return bfloat16(numext::cbrt(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16& a, const bfloat16& b) {
   return bfloat16(numext::pow(float(a), float(b)));
@@ -757,9 +751,8 @@
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sinh(const bfloat16& a) { return bfloat16(numext::sinh(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 cosh(const bfloat16& a) { return bfloat16(numext::cosh(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 tanh(const bfloat16& a) {
-  // numext::tanh(float) can select an approximation instead of the math-library implementation.
-  EIGEN_USING_STD(tanh);
-  return bfloat16(tanh(float(a)));
+  // Select the scalar template, not the host fast-math overload, to preserve bfloat16 rounding.
+  return bfloat16(numext::tanh<float>(float(a)));
 }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 asinh(const bfloat16& a) { return bfloat16(numext::asinh(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 acosh(const bfloat16& a) { return bfloat16(numext::acosh(float(a))); }
diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h
index 6b139b0..65cc133 100644
--- a/Eigen/src/Core/arch/Default/Half.h
+++ b/Eigen/src/Core/arch/Default/Half.h
@@ -952,17 +952,13 @@
 }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log1p(const half& a) { return half(numext::log1p(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log10(const half& a) { return half(numext::log10(float(a))); }
-EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log2(const half& a) {
-  return half(static_cast<float>(EIGEN_LOG2E) * numext::log(float(a)));
-}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half log2(const half& a) { return half(numext::log2(float(a))); }
 
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half sqrt(const half& a) {
 #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
   return half(hsqrt(::__half(a)));
 #else
-  // numext::sqrt<float> would be instantiated here, before the SSE specialization is declared.
-  EIGEN_USING_STD(sqrt);
-  return half(sqrt(float(a)));
+  return half(numext::sqrt(float(a)));
 #endif
 }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half pow(const half& a, const half& b) {
@@ -975,9 +971,8 @@
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half cos(const half& a) { return half(numext::cos(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tan(const half& a) { return half(numext::tan(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half tanh(const half& a) {
-  // numext::tanh(float) can select an approximation that changes half rounding.
-  EIGEN_USING_STD(tanh);
-  return half(tanh(float(a)));
+  // Select the scalar template, not the host fast-math overload, to preserve half rounding.
+  return half(numext::tanh<float>(float(a)));
 }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half asin(const half& a) { return half(numext::asin(float(a))); }
 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half acos(const half& a) { return half(numext::acos(float(a))); }
diff --git a/Eigen/src/Core/functors/UnaryFunctors.h b/Eigen/src/Core/functors/UnaryFunctors.h
index b6cff2b..62f88cc 100644
--- a/Eigen/src/Core/functors/UnaryFunctors.h
+++ b/Eigen/src/Core/functors/UnaryFunctors.h
@@ -1469,8 +1469,7 @@
   }
 
   EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
-    EIGEN_USING_STD(pow);
-    return static_cast<Scalar>(pow(a, m_exponent));
+    return static_cast<Scalar>(numext::pow(a, m_exponent));
   }
   template <typename Packet>
   EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet packetOp(const Packet& a) const {
@@ -1493,6 +1492,7 @@
                                 unary_pow::use_repeated_squaring<Scalar>(exponent)) {}
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar operator()(const Scalar& a) const {
     if (m_use_repeated_squaring) return unary_pow::int_pow(a, m_exponent);
+    // std::pow can promote the complex component for a wider exponent before casting back to Scalar.
     EIGEN_USING_STD(pow);
     return static_cast<Scalar>(pow(a, m_exponent));
   }
diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h
index f849a61..7d74c60 100644
--- a/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h
+++ b/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h
@@ -60,7 +60,6 @@
     static void run(Index rows, Index cols, Index depth, const EIGTYPE* lhs_, Index lhsStride, const EIGTYPE* rhs_,    \
                     Index rhsStride, Scalar* res, Index resIncr, Index resStride, EIGTYPE alpha,                       \
                     level3_blocking<EIGTYPE, EIGTYPE>& blocking, GemmParallelInfo<Index>* info) {                      \
-      using std::conj;                                                                                                 \
       if (rows == 0 || cols == 0 || depth == 0 || numext::is_exactly_zero(alpha)) return;                              \
       if (!blas_compatible_stride<LhsStorageOrder>(rows, depth, lhsStride) ||                                          \
           !blas_compatible_stride<RhsStorageOrder>(depth, cols, rhsStride) ||                                          \
@@ -148,7 +147,6 @@
                   const Eigen::bfloat16* rhs_, Index rhsStride, Eigen::bfloat16* res, Index resIncr, Index resStride,
                   Eigen::bfloat16 alpha, level3_blocking<Eigen::bfloat16, Eigen::bfloat16>& blocking,
                   GemmParallelInfo<Index>* info) {
-    using std::conj;
     if (rows == 0 || cols == 0 || depth == 0 || numext::is_exactly_zero(alpha)) return;
     if (!blas_compatible_stride<LhsStorageOrder>(rows, depth, lhsStride) ||
         !blas_compatible_stride<RhsStorageOrder>(depth, cols, rhsStride)) {
diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h
index 0e535dd..bf7a102 100644
--- a/Eigen/src/Core/util/BlasUtil.h
+++ b/Eigen/src/Core/util/BlasUtil.h
@@ -515,7 +515,7 @@
   enum { IsComplex = NumTraits<Scalar>::IsComplex, NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex };
   EIGEN_DEVICE_FUNC static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
   EIGEN_DEVICE_FUNC static inline Scalar extractScalarFactor(const XprType& x) {
-    return conj(Base::extractScalarFactor(x.nestedExpression()));
+    return numext::conj(Base::extractScalarFactor(x.nestedExpression()));
   }
 };
 
diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h
index c27d813..e2fe66a 100644
--- a/Eigen/src/Eigenvalues/ComplexSchur.h
+++ b/Eigen/src/Eigenvalues/ComplexSchur.h
@@ -310,7 +310,8 @@
 /** Compute the shift in the current QR iteration. */
 template <typename MatrixType>
 typename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::computeShift(Index iu, Index iter) {
-  using std::abs;
+  using numext::abs;
+  using numext::sqrt;
   if ((iter == 10 || iter == 20) && iu > 1) {
     // exceptional shift, taken from http://www.netlib.org/eispack/comqr.f
     return ComplexSchur<MatrixType>::ComplexScalar(abs(numext::real(m_matT.coeff(iu, iu - 1))) +
diff --git a/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h b/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
index 7dfa043..8bc90fb 100644
--- a/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
+++ b/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
@@ -319,6 +319,8 @@
  * held by m_realQZ. */
 template <typename MatrixType>
 GeneralizedEigenSolver<MatrixType>& GeneralizedEigenSolver<MatrixType>::computeFromQZ(bool computeEigenvectors) {
+  using numext::conj;
+  using numext::real;
   const Index size = m_realQZ.matrixS().cols();
   if (m_realQZ.info() == Success) {
     // Resize storage
diff --git a/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h b/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h
index b452692..d3482a2 100644
--- a/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h
+++ b/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h
@@ -110,7 +110,7 @@
  */
 template <typename Derived>
 inline typename MatrixBase<Derived>::RealScalar MatrixBase<Derived>::operatorNorm() const {
-  using std::sqrt;
+  using numext::sqrt;
   typename Derived::PlainObject m_eval(derived());
   // FIXME: if eigenvalues are guaranteed to be sorted, comparing the first and last is sufficient.
   return sqrt((m_eval * m_eval.adjoint()).eval().template selfadjointView<Lower>().eigenvalues().maxCoeff());
diff --git a/Eigen/src/Eigenvalues/RealQZ.h b/Eigen/src/Eigenvalues/RealQZ.h
index e44ff26..2b70453 100644
--- a/Eigen/src/Eigenvalues/RealQZ.h
+++ b/Eigen/src/Eigenvalues/RealQZ.h
@@ -301,7 +301,7 @@
 /** \internal Look for single small sub-diagonal element S(res, res-1) and return res (or 0) */
 template <typename MatrixType>
 inline Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu) {
-  using std::abs;
+  using numext::abs;
   Index res = iu;
   while (res > 0) {
     Scalar s = abs(m_S.coeff(res - 1, res - 1)) + abs(m_S.coeff(res, res));
@@ -315,7 +315,7 @@
 /** \internal Look for single small diagonal element T(res, res) for res between f and l, and return res (or f-1)  */
 template <typename MatrixType>
 inline Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l) {
-  using std::abs;
+  using numext::abs;
   Index res = l;
   while (res >= f) {
     if (abs(m_T.coeff(res, res)) <= NumTraits<Scalar>::epsilon() * m_normOfT) break;
@@ -327,8 +327,8 @@
 /** \internal decouple 2x2 diagonal block in rows i, i+1 if eigenvalues are real */
 template <typename MatrixType>
 inline void RealQZ<MatrixType>::splitOffTwoRows(Index i) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
   const Index dim = m_S.cols();
   if (numext::is_exactly_zero(abs(m_S.coeff(i + 1, i)))) return;
   Index j = findSmallDiagEntry(i, i + 1);
@@ -403,7 +403,7 @@
 /** \internal QR-like iterative step for block f..l */
 template <typename MatrixType>
 inline void RealQZ<MatrixType>::step(Index f, Index l, Index iter) {
-  using std::abs;
+  using numext::abs;
   const Index dim = m_S.cols();
 
   // x, y, z
diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h
index 452b2eb..cd1fe37 100644
--- a/Eigen/src/Eigenvalues/RealSchur.h
+++ b/Eigen/src/Eigenvalues/RealSchur.h
@@ -472,7 +472,7 @@
 template <typename MatrixType>
 template <typename TMatrix>
 inline Index RealSchur<MatrixType>::findSmallSubdiagEntry(TMatrix& matT, Index iu, const Scalar& considerAsZero) {
-  using std::abs;
+  using numext::abs;
   Index res = iu;
   while (res > 0) {
     Scalar s = abs(matT.coeff(res - 1, res - 1)) + abs(matT.coeff(res, res));
@@ -500,8 +500,8 @@
 template <typename TMatrix>
 EIGEN_REALSCHUR_SPLIT_INLINE void RealSchur<MatrixType>::splitOffTwoRows(TMatrix& matT, Index iu, bool computeU,
                                                                          const Scalar& exshift) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
   const Index size = matT.cols();
 
   // The eigenvalues of the 2x2 matrix [a b; c d] are
@@ -536,8 +536,8 @@
 template <typename TMatrix>
 inline void RealSchur<MatrixType>::computeShift(TMatrix& matT, Index iu, Index iter, Scalar& exshift,
                                                 Vector3s& shiftInfo) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
   shiftInfo.coeffRef(0) = matT.coeff(iu, iu);
   shiftInfo.coeffRef(1) = matT.coeff(iu - 1, iu - 1);
   shiftInfo.coeffRef(2) = matT.coeff(iu, iu - 1) * matT.coeff(iu - 1, iu);
@@ -574,7 +574,7 @@
 template <typename TMatrix>
 inline void RealSchur<MatrixType>::initFrancisQRStep(TMatrix& matT, Index il, Index iu, const Vector3s& shiftInfo,
                                                      Index& im, Vector3s& firstHouseholderVector) {
-  using std::abs;
+  using numext::abs;
   Vector3s& v = firstHouseholderVector;  // alias to save typing
 
   for (im = iu - 2; im >= il; --im) {
diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
index de6a142..81f84ef 100644
--- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
+++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
@@ -732,10 +732,10 @@
    * For numerical stability m.trace() should be near zero and to avoid over- or underflow m should be normalized.
    */
   EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
-    EIGEN_USING_STD(sqrt)
-    EIGEN_USING_STD(atan2)
-    EIGEN_USING_STD(cos)
-    EIGEN_USING_STD(sin)
+    using numext::atan2;
+    using numext::cos;
+    using numext::sin;
+    using numext::sqrt;
     const Scalar s_inv3 = Scalar(1) / Scalar(3);
     const Scalar s_sqrt3 = sqrt(Scalar(3));
 
@@ -772,8 +772,8 @@
 
   EIGEN_DEVICE_FUNC static inline bool extract_kernel(PlainMatrixType& mat, Ref<VectorType> res,
                                                       Ref<VectorType> representative) {
-    EIGEN_USING_STD(abs);
-    EIGEN_USING_STD(sqrt);
+    using numext::abs;
+    using numext::sqrt;
     Index i0;
     // Find non-zero column i0 (by construction, there must exist a non zero coefficient on the diagonal):
     mat.diagonal().cwiseAbs().maxCoeff(&i0);
@@ -860,7 +860,7 @@
   using PlainMatrixType = typename SolverType::PlainMatrixType;
 
   EIGEN_DEVICE_FUNC static inline void computeRoots(const MatrixType& m, VectorType& roots) {
-    EIGEN_USING_STD(sqrt);
+    using numext::sqrt;
     const Scalar t0 = Scalar(0.5) * sqrt(numext::abs2(m(0, 0) - m(1, 1)) + Scalar(4) * numext::abs2(m(1, 0)));
     const Scalar t1 = Scalar(0.5) * (m(0, 0) + m(1, 1));
     roots(0) = t1 - t0;
@@ -870,8 +870,8 @@
   EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static void run(PlainMatrixType& scaledMat, VectorType& eivals,
                                                         EigenvectorsType& eivecs, bool computeEigenvectors,
                                                         const Scalar&) {
-    EIGEN_USING_STD(sqrt);
-    EIGEN_USING_STD(abs);
+    using numext::abs;
+    using numext::sqrt;
 
     // Compute the eigenvalues
     computeRoots(scaledMat, eivals);
diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h
index ba640c6..a7527d3 100644
--- a/Eigen/src/Eigenvalues/Tridiagonalization.h
+++ b/Eigen/src/Eigenvalues/Tridiagonalization.h
@@ -626,7 +626,7 @@
   template <typename DiagonalType, typename SubDiagonalType, typename CoeffVectorType, typename WorkSpaceType>
   static EIGEN_DEVICE_FUNC void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, CoeffVectorType&,
                                     WorkSpaceType&, bool extractQ) {
-    using std::sqrt;
+    using numext::sqrt;
     const RealScalar tol = (std::numeric_limits<RealScalar>::min)();
     diag[0] = mat(0, 0);
     RealScalar v1norm2 = numext::abs2(mat(2, 0));
diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h
index 210c0f9..6957c34 100644
--- a/Eigen/src/Geometry/AlignedBox.h
+++ b/Eigen/src/Geometry/AlignedBox.h
@@ -317,7 +317,8 @@
    */
   template <typename Derived>
   EIGEN_DEVICE_FUNC inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const {
-    EIGEN_USING_STD(sqrt) return sqrt(NonInteger(squaredExteriorDistance(p)));
+    using numext::sqrt;
+    return sqrt(NonInteger(squaredExteriorDistance(p)));
   }
 
   /** \returns the distance between the boxes \a b and \c *this,
@@ -325,7 +326,8 @@
    * \sa squaredExteriorDistance(const AlignedBox&), exteriorDistance(const MatrixBase&)
    */
   EIGEN_DEVICE_FUNC inline NonInteger exteriorDistance(const AlignedBox& b) const {
-    EIGEN_USING_STD(sqrt) return sqrt(NonInteger(squaredExteriorDistance(b)));
+    using numext::sqrt;
+    return sqrt(NonInteger(squaredExteriorDistance(b)));
   }
 
   /**
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h
index 7bd7a6a..9409678 100644
--- a/Eigen/src/Geometry/AngleAxis.h
+++ b/Eigen/src/Geometry/AngleAxis.h
@@ -135,8 +135,8 @@
    * without constructing the full rotation matrix. */
   template <typename OtherVectorType>
   EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const OtherVectorType& v) const {
-    EIGEN_USING_STD(sin)
-    EIGEN_USING_STD(cos)
+    using numext::cos;
+    using numext::sin;
     EIGEN_INTERNAL_ASSERT_SAME_SIZE(v, m_axis);
 
     // Rodrigues' rotation formula: v' = v*cos(θ) + (k×v)*sin(θ) + k*(k·v)*(1-cos(θ))
@@ -192,8 +192,8 @@
 template <typename Scalar>
 template <typename QuatDerived>
 EIGEN_DEVICE_FUNC AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived>& q) {
-  EIGEN_USING_STD(atan2)
-  EIGEN_USING_STD(abs)
+  using numext::abs;
+  using numext::atan2;
   Scalar n = q.vec().norm();
   if (n < NumTraits<Scalar>::epsilon()) n = q.vec().stableNorm();
 
@@ -248,8 +248,8 @@
  */
 template <typename Scalar>
 typename AngleAxis<Scalar>::Matrix3 EIGEN_DEVICE_FUNC AngleAxis<Scalar>::toRotationMatrix(void) const {
-  EIGEN_USING_STD(sin)
-  EIGEN_USING_STD(cos)
+  using numext::cos;
+  using numext::sin;
   Matrix3 res;
   Vector3 sin_axis = sin(m_angle) * m_axis;
   Scalar c = cos(m_angle);
diff --git a/Eigen/src/Geometry/ParametrizedLine.h b/Eigen/src/Geometry/ParametrizedLine.h
index 8c59ffb..642c179 100644
--- a/Eigen/src/Geometry/ParametrizedLine.h
+++ b/Eigen/src/Geometry/ParametrizedLine.h
@@ -88,7 +88,8 @@
    * \sa squaredDistance()
    */
   EIGEN_DEVICE_FUNC RealScalar distance(const VectorType& p) const {
-    EIGEN_USING_STD(sqrt) return sqrt(squaredDistance(p));
+    using numext::sqrt;
+    return sqrt(squaredDistance(p));
   }
 
   /** \returns the projection of a point \a p onto the line \c *this. */
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h
index 4efc0e7..1f21d98 100644
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -621,8 +621,8 @@
  */
 template <class Derived>
 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa) {
-  EIGEN_USING_STD(cos)
-  EIGEN_USING_STD(sin)
+  using numext::cos;
+  using numext::sin;
   Scalar ha = Scalar(0.5) * aa.angle();  // Scalar(0.5) to suppress precision loss warnings
   this->w() = cos(ha);
   this->vec() = sin(ha) * aa.axis();
@@ -694,7 +694,7 @@
 template <typename Derived1, typename Derived2>
 EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a,
                                                                              const MatrixBase<Derived2>& b) {
-  EIGEN_USING_STD(sqrt)
+  using numext::sqrt;
   Vector3 v0 = a.normalized();
   Vector3 v1 = b.normalized();
   Scalar c = v1.dot(v0);
@@ -731,8 +731,8 @@
 template <typename OtherDerived>
 EIGEN_DEVICE_FUNC inline Derived& QuaternionBase<Derived>::setFromScaledAxis(
     const MatrixBase<OtherDerived>& scaled_axis) {
-  EIGEN_USING_STD(sin)
-  EIGEN_USING_STD(cos)
+  using numext::cos;
+  using numext::sin;
   EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived, 3)
 
   // Materialise the input once so the caller's expression (e.g. omega*dt) is not
@@ -771,7 +771,6 @@
  */
 template <class Derived>
 EIGEN_DEVICE_FUNC inline typename QuaternionBase<Derived>::Vector3 QuaternionBase<Derived>::toScaledAxis() const {
-  EIGEN_USING_STD(atan2)
   eigen_assert(internal::isApprox(this->squaredNorm(), Scalar(1), Scalar(8) * NumTraits<Scalar>::dummy_precision()) &&
                "QuaternionBase::toScaledAxis(): the quaternion must be approximately a unit quaternion");
 
@@ -783,7 +782,7 @@
   // |w| in atan2 prevents -0.0 from flipping the sign; recover it via the comparison below
   // (false for both +0.0 and -0.0).
   // Cannot overflow: for unit q, atan2(s, |c|) is O(s) as s -> 0, so k stays in [2, pi].
-  Scalar k = Scalar(2) * atan2(sin_half_angle, numext::abs(this->w())) / sin_half_angle;
+  Scalar k = Scalar(2) * numext::atan2(sin_half_angle, numext::abs(this->w())) / sin_half_angle;
   if (this->w() < Scalar(0)) k = -k;
   return k * this->vec();
 }
@@ -794,9 +793,9 @@
  */
 template <typename Scalar, int Options>
 EIGEN_DEVICE_FUNC Quaternion<Scalar, Options> Quaternion<Scalar, Options>::UnitRandom() {
-  EIGEN_USING_STD(sqrt)
-  EIGEN_USING_STD(sin)
-  EIGEN_USING_STD(cos)
+  using numext::cos;
+  using numext::sin;
+  using numext::sqrt;
   const Scalar u1 = internal::random<Scalar>(0, 1), u2 = internal::random<Scalar>(0, 2 * EIGEN_PI),
                u3 = internal::random<Scalar>(0, 2 * EIGEN_PI);
   const Scalar a = sqrt(Scalar(1) - u1), b = sqrt(u1);
@@ -914,9 +913,8 @@
 template <class OtherDerived>
 EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar QuaternionBase<Derived>::angularDistance(
     const QuaternionBase<OtherDerived>& other) const {
-  EIGEN_USING_STD(atan2)
   Quaternion<Scalar> d = (*this) * other.conjugate();
-  return Scalar(2) * atan2(d.vec().norm(), numext::abs(d.w()));
+  return Scalar(2) * numext::atan2(d.vec().norm(), numext::abs(d.w()));
 }
 
 /** \returns the spherical linear interpolation between the two quaternions
@@ -929,8 +927,8 @@
 template <class OtherDerived>
 EIGEN_DEVICE_FUNC Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::slerp(
     const Scalar& t, const QuaternionBase<OtherDerived>& other) const {
-  EIGEN_USING_STD(acos)
-  EIGEN_USING_STD(sin)
+  using numext::acos;
+  using numext::sin;
   const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
   Scalar d = this->dot(other);
   Scalar absD = numext::abs(d);
diff --git a/Eigen/src/Geometry/Rotation2D.h b/Eigen/src/Geometry/Rotation2D.h
index 31107b0..9a48321 100644
--- a/Eigen/src/Geometry/Rotation2D.h
+++ b/Eigen/src/Geometry/Rotation2D.h
@@ -179,10 +179,9 @@
 template <typename Scalar>
 template <typename Derived>
 EIGEN_DEVICE_FUNC Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat) {
-  EIGEN_USING_STD(atan2)
   EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 2 && Derived::ColsAtCompileTime == 2,
                       YOU_MADE_A_PROGRAMMING_MISTAKE)
-  m_angle = atan2(mat.coeff(1, 0), mat.coeff(0, 0));
+  m_angle = numext::atan2(Scalar(mat.coeff(1, 0)), Scalar(mat.coeff(0, 0)));
   return *this;
 }
 
@@ -190,8 +189,8 @@
  */
 template <typename Scalar>
 typename Rotation2D<Scalar>::Matrix2 EIGEN_DEVICE_FUNC Rotation2D<Scalar>::toRotationMatrix(void) const {
-  EIGEN_USING_STD(sin)
-  EIGEN_USING_STD(cos)
+  using numext::cos;
+  using numext::sin;
   Scalar sinA = sin(m_angle);
   Scalar cosA = cos(m_angle);
   return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
diff --git a/Eigen/src/IterativeLinearSolvers/GMRES.h b/Eigen/src/IterativeLinearSolvers/GMRES.h
index caecf5b..733a51f 100644
--- a/Eigen/src/IterativeLinearSolvers/GMRES.h
+++ b/Eigen/src/IterativeLinearSolvers/GMRES.h
@@ -60,8 +60,8 @@
 template <typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>
 bool gmres(const MatrixType& mat, const Rhs& rhs, Dest& x, const Preconditioner& precond, Index& iters,
            const Index& restart_, typename Dest::RealScalar& tol_error) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
 
   using RealScalar = typename Dest::RealScalar;
   using Scalar = typename Dest::Scalar;
diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h b/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h
index aa06c70..796b243 100644
--- a/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h
+++ b/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h
@@ -204,7 +204,7 @@
 template <typename Scalar, int UpLo_, typename OrderingType>
 template <typename MatrixType_>
 void IncompleteCholesky<Scalar, UpLo_, OrderingType>::factorize(const MatrixType_& mat) {
-  using std::sqrt;
+  using numext::sqrt;
   eigen_assert(m_analysisIsOk && "analyzePattern() should be called first");
 
   // Dropping strategy : Keep only the p largest elements per column, where p is the number of elements in the column of
diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
index 11fed19..fa91c72 100644
--- a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
+++ b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
@@ -31,7 +31,7 @@
 template <typename VectorV, typename VectorI>
 Index QuickSplit(VectorV& row, VectorI& ind, Index ncut) {
   using RealScalar = typename VectorV::RealScalar;
-  using std::abs;
+  using numext::abs;
   using std::swap;
   Index mid;
   Index n = row.size(); /* length of the vector */
@@ -429,8 +429,8 @@
 template <typename MatrixType_>
 void IncompleteLUT<Scalar, StorageIndex>::factorize(const MatrixType_& amat) {
   using internal::convert_index;
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
   using std::swap;
 
   EIGEN_INTERNAL_ASSERT_SQUARE_MSG(amat, "The factorization should be done on a square matrix");
diff --git a/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h
index 1e39928..6199689 100644
--- a/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h
+++ b/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h
@@ -31,7 +31,7 @@
 EIGEN_DONT_INLINE void least_square_conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
                                                        const Preconditioner& precond, Index& iters,
                                                        typename Dest::RealScalar& tol_error) {
-  using std::sqrt;
+  using numext::sqrt;
   using RealScalar = typename Dest::RealScalar;
   using Scalar = typename Dest::Scalar;
   using VectorType = Matrix<Scalar, Dynamic, 1>;
diff --git a/Eigen/src/IterativeLinearSolvers/MINRES.h b/Eigen/src/IterativeLinearSolvers/MINRES.h
index da132b3..832c0fc 100644
--- a/Eigen/src/IterativeLinearSolvers/MINRES.h
+++ b/Eigen/src/IterativeLinearSolvers/MINRES.h
@@ -32,7 +32,7 @@
 template <typename MatrixType, typename Rhs, typename Dest, typename Preconditioner>
 EIGEN_DONT_INLINE void minres(const MatrixType& mat, const Rhs& rhs, Dest& x, const Preconditioner& precond,
                               Index& iters, typename Dest::RealScalar& tol_error) {
-  using std::sqrt;
+  using numext::sqrt;
   using RealScalar = typename Dest::RealScalar;
   using Scalar = typename Dest::Scalar;
   using VectorType = Matrix<Scalar, Dynamic, 1>;
diff --git a/Eigen/src/IterativeLinearSolvers/Scaling.h b/Eigen/src/IterativeLinearSolvers/Scaling.h
index f190c9f..d6602a8 100644
--- a/Eigen/src/IterativeLinearSolvers/Scaling.h
+++ b/Eigen/src/IterativeLinearSolvers/Scaling.h
@@ -70,7 +70,7 @@
    * \sa LeftScaling() RightScaling()
    */
   void compute(const MatrixType& mat) {
-    using std::abs;
+    using numext::abs;
     int m = mat.rows();
     int n = mat.cols();
     eigen_assert((m > 0 && m == n) && "Please give a non - empty matrix");
diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h
index f8c94a6..773e7e5 100644
--- a/Eigen/src/Jacobi/Jacobi.h
+++ b/Eigen/src/Jacobi/Jacobi.h
@@ -93,8 +93,8 @@
  */
 template <typename Scalar>
 EIGEN_DEVICE_FUNC bool JacobiRotation<Scalar>::makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+  using numext::sqrt;
 
   const RealScalar abs_y = abs(y);
   const RealScalar deno = RealScalar(2) * abs_y;
@@ -169,9 +169,9 @@
 // specialization for complexes
 template <typename Scalar>
 EIGEN_DEVICE_FUNC void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r, std::true_type) {
+  using numext::abs;
   using numext::conj;
-  using std::abs;
-  using std::sqrt;
+  using numext::sqrt;
 
   if (q == Scalar(0)) {
     m_c = numext::real(p) < 0 ? Scalar(-1) : Scalar(1);
@@ -224,8 +224,13 @@
 template <typename Scalar>
 EIGEN_DEVICE_FUNC void JacobiRotation<Scalar>::makeGivens(const Scalar& p, const Scalar& q, Scalar* r,
                                                           std::false_type) {
-  using std::abs;
-  using std::sqrt;
+  using numext::abs;
+#if defined(EIGEN_SYCL_DEVICE_ONLY)
+  using numext::sqrt;
+#else
+  // GCC does not fold the SSE numext::sqrt intrinsic for the constant range thresholds below.
+  EIGEN_USING_STD(sqrt);
+#endif
   if (numext::is_exactly_zero_no_flush(q)) {
     // DAZ can hide the sign; MSVC's non-intrinsic abs(float) can flush the
     // result through a float->double->float conversion even with FTZ alone.
@@ -266,6 +271,7 @@
   const Scalar mn = numext::mini(abs_p, abs_q);
 
   if (EIGEN_PREDICT_TRUE(mx < rtmax && mn > rtmin)) {
+    using numext::sqrt;
     // Safe range: existing direct formulas are stable.
     if (abs_p > abs_q) {
       Scalar t = q / p;
diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h
index bf7a9a0..d18f8f5 100644
--- a/Eigen/src/LU/FullPivLU.h
+++ b/Eigen/src/LU/FullPivLU.h
@@ -336,7 +336,7 @@
 
   /** \returns the absolute value of the i-th pivot coefficient (for RankRevealingBase). */
   RealScalar pivotCoeff(Index i) const {
-    using std::abs;
+    using numext::abs;
     return abs(m_lu.coeff(i, i));
   }
 
diff --git a/Eigen/src/LU/InverseImpl.h b/Eigen/src/LU/InverseImpl.h
index aa4e05d..b04dc3b 100644
--- a/Eigen/src/LU/InverseImpl.h
+++ b/Eigen/src/LU/InverseImpl.h
@@ -53,7 +53,7 @@
                                            const typename MatrixType::RealScalar& absDeterminantThreshold,
                                            ResultType& result, typename ResultType::Scalar& determinant,
                                            bool& invertible) {
-    using std::abs;
+    using numext::abs;
     determinant = matrix.coeff(0, 0);
     invertible = abs(determinant) > absDeterminantThreshold;
     if (invertible) result.coeffRef(0, 0) = typename ResultType::Scalar(1) / determinant;
@@ -90,7 +90,7 @@
                                            const typename MatrixType::RealScalar& absDeterminantThreshold,
                                            ResultType& inverse, typename ResultType::Scalar& determinant,
                                            bool& invertible) {
-    using std::abs;
+    using numext::abs;
     using Scalar = typename ResultType::Scalar;
     determinant = matrix.determinant();
     invertible = abs(determinant) > absDeterminantThreshold;
@@ -212,7 +212,7 @@
                                            const typename MatrixType::RealScalar& absDeterminantThreshold,
                                            ResultType& inverse, typename ResultType::Scalar& determinant,
                                            bool& invertible) {
-    using std::abs;
+    using numext::abs;
     determinant = matrix.determinant();
     invertible = abs(determinant) > absDeterminantThreshold;
     if (invertible && extract_data(matrix) != extract_data(inverse)) {
diff --git a/Eigen/src/OrderingMethods/Amd.h b/Eigen/src/OrderingMethods/Amd.h
index 3027186..c1cefc6 100644
--- a/Eigen/src/OrderingMethods/Amd.h
+++ b/Eigen/src/OrderingMethods/Amd.h
@@ -80,7 +80,7 @@
 template <typename Scalar, typename StorageIndex>
 void minimum_degree_ordering(SparseMatrix<Scalar, ColMajor, StorageIndex>& C,
                              PermutationMatrix<Dynamic, Dynamic, StorageIndex>& perm) {
-  using std::sqrt;
+  using numext::sqrt;
 
   StorageIndex d, dk, dext, lemax = 0, e, elenk, eln, i, j, k, k1, k2, k3, jlast, ln, dense, nzmax, mindeg = 0, nvi,
                             nvj, nvk, mark, wnvi, ok, nel = 0, p, p1, p2, p3, p4, pj, pk, pk1, pk2, pn, q, t, h;
diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h
index dca45f7..187b13d 100644
--- a/Eigen/src/QR/ColPivHouseholderQR.h
+++ b/Eigen/src/QR/ColPivHouseholderQR.h
@@ -265,7 +265,7 @@
 
   /** \returns the absolute value of the i-th pivot coefficient (for RankRevealingBase). */
   RealScalar pivotCoeff(Index i) const {
-    using std::abs;
+    using numext::abs;
     return abs(m_qr.coeff(i, i));
   }
 
@@ -336,7 +336,7 @@
 
 template <typename MatrixType, typename PermutationIndex>
 typename MatrixType::RealScalar ColPivHouseholderQR<MatrixType, PermutationIndex>::absDeterminant() const {
-  using std::abs;
+  using numext::abs;
   eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized.");
   EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr, "You can't take the determinant of a non-square matrix!");
   return isInjective() ? abs(m_qr.diagonal().prod()) : RealScalar(0);
@@ -377,7 +377,7 @@
 void ColPivHouseholderQR<MatrixType, PermutationIndex>::computeInPlace() {
   eigen_assert(m_qr.cols() <= NumTraits<PermutationIndex>::highest());
 
-  using std::abs;
+  using numext::abs;
 
   Index rows = m_qr.rows();
   Index cols = m_qr.cols();
diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h
index 3de6e0c..2c6e429 100644
--- a/Eigen/src/QR/FullPivHouseholderQR.h
+++ b/Eigen/src/QR/FullPivHouseholderQR.h
@@ -288,7 +288,7 @@
 
   /** \returns the absolute value of the i-th pivot coefficient (for RankRevealingBase). */
   RealScalar pivotCoeff(Index i) const {
-    using std::abs;
+    using numext::abs;
     return abs(m_qr.coeff(i, i));
   }
 
@@ -346,7 +346,7 @@
 
 template <typename MatrixType, typename PermutationIndex>
 typename MatrixType::RealScalar FullPivHouseholderQR<MatrixType, PermutationIndex>::absDeterminant() const {
-  using std::abs;
+  using numext::abs;
   eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
   EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr, "You can't take the determinant of a non-square matrix!");
   return isInjective() ? abs(m_qr.diagonal().prod()) : RealScalar(0);
@@ -386,7 +386,7 @@
 template <typename MatrixType, typename PermutationIndex>
 void FullPivHouseholderQR<MatrixType, PermutationIndex>::computeInPlace() {
   eigen_assert(m_qr.cols() <= NumTraits<PermutationIndex>::highest());
-  using std::abs;
+  using numext::abs;
   Index rows = m_qr.rows();
   Index cols = m_qr.cols();
   Index size = (std::min)(rows, cols);
diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h
index 4a48441..e8f2260 100644
--- a/Eigen/src/QR/HouseholderQR.h
+++ b/Eigen/src/QR/HouseholderQR.h
@@ -346,7 +346,7 @@
 
 template <typename MatrixType>
 typename MatrixType::RealScalar HouseholderQR<MatrixType>::absDeterminant() const {
-  using std::abs;
+  using numext::abs;
   eigen_assert(m_isInitialized && "HouseholderQR is not initialized.");
   EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr, "You can't take the determinant of a non-square matrix!");
   return abs(m_qr.diagonal().prod());
diff --git a/Eigen/src/QR/RandColPivHouseholderQR.h b/Eigen/src/QR/RandColPivHouseholderQR.h
index ea4f3b3..d5d42cd 100644
--- a/Eigen/src/QR/RandColPivHouseholderQR.h
+++ b/Eigen/src/QR/RandColPivHouseholderQR.h
@@ -57,7 +57,7 @@
 template <typename RealScalar, typename Scalar, typename RecomputeFn>
 EIGEN_STRONG_INLINE void lawn176_norm_downdate(RealScalar& norm_updated, RealScalar& norm_direct, Scalar pivot_entry,
                                                RealScalar downdate_threshold, RecomputeFn&& tail_norm_fn) {
-  using std::abs;
+  using numext::abs;
   if (numext::is_exactly_zero(norm_updated)) return;
   RealScalar t = abs(pivot_entry) / norm_updated;
   t = (RealScalar(1) + t) * (RealScalar(1) - t);
@@ -291,7 +291,7 @@
   typename MatrixType::Scalar signDeterminant() const;
 
   RealScalar pivotCoeff(Index i) const {
-    using std::abs;
+    using numext::abs;
     return abs(m_qr.coeff(i, i));
   }
 
@@ -406,7 +406,7 @@
 
 template <typename MatrixType, typename PermutationIndex>
 typename MatrixType::RealScalar RandColPivHouseholderQR<MatrixType, PermutationIndex>::absDeterminant() const {
-  using std::abs;
+  using numext::abs;
   eigen_assert(m_isInitialized && "RandColPivHouseholderQR is not initialized.");
   EIGEN_INTERNAL_ASSERT_SQUARE_MSG(m_qr, "You can't take the determinant of a non-square matrix!");
   return isInjective() ? abs(m_qr.diagonal().prod()) : RealScalar(0);
@@ -440,7 +440,7 @@
 template <typename MatrixType, typename PermutationIndex>
 Index RandColPivHouseholderQR<MatrixType, PermutationIndex>::unblocked_pivoted_qr(Index row0, Index col0, Index ncols,
                                                                                   RealScalar threshold_helper) {
-  using std::abs;
+  using numext::abs;
   const Index rows = m_qr.rows();
   const Index col_end = col0 + ncols;
   const Index sub_rows = rows - row0;
@@ -494,7 +494,7 @@
 
 template <typename MatrixType, typename PermutationIndex>
 void RandColPivHouseholderQR<MatrixType, PermutationIndex>::finalize_rank(RealScalar threshold_helper) {
-  using std::abs;
+  using numext::abs;
   const Index rows = m_qr.rows();
   const Index size = (std::min)(rows, m_qr.cols());
   // m_maxpivot is already up-to-date: the blocked path tracks it per
@@ -675,7 +675,7 @@
     // rank() applies to the final diagonal.
     Index panel_rank = b;
     {
-      using std::abs;
+      using numext::abs;
       const RealScalar relative_cutoff = this->m_maxpivot * NumTraits<RealScalar>::epsilon() * RealScalar(4 * size);
       for (Index i = 0; i < b; ++i) {
         RealScalar a = abs(m_qr.coeff(k + i, k + i));
diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h
index 3f0b0f0..b3ec836 100644
--- a/Eigen/src/SVD/BDCSVD.h
+++ b/Eigen/src/SVD/BDCSVD.h
@@ -362,7 +362,7 @@
 template <typename Derived>
 EIGEN_DONT_INLINE BDCSVD<MatrixType, Options>& BDCSVD<MatrixType, Options>::compute_impl(
     const MatrixBase<Derived>& matrix, unsigned int computationOptions, internal::false_type) {
-  using std::abs;
+  using numext::abs;
 
   allocate(matrix.rows(), matrix.cols(), computationOptions);
 
@@ -509,7 +509,7 @@
   EIGEN_STATIC_ASSERT((NumTraits<typename DerivedE::Scalar>::IsComplex == 0),
                       THIS_FUNCTION_IS_NOT_FOR_COMPLEX_VALUED_MATRICES);
 
-  using std::abs;
+  using numext::abs;
   const Index n = diagonal.size();
   eigen_assert((n == 0 || superdiagonal.size() == n - 1) && "superdiagonal must have size diagonal.size() - 1");
 
diff --git a/Eigen/src/SVD/BDCSVDImpl.h b/Eigen/src/SVD/BDCSVDImpl.h
index c302eb9..51596c5 100644
--- a/Eigen/src/SVD/BDCSVDImpl.h
+++ b/Eigen/src/SVD/BDCSVDImpl.h
@@ -348,7 +348,7 @@
 template <typename RealScalar_>
 void bdcsvd_impl<RealScalar_>::computeSVDofM(Index firstCol, Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V) {
   const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();
-  using std::abs;
+  using numext::abs;
   ArrayRef col0 = m_computed.col(firstCol).segment(firstCol, n);
   m_workspace.head(n) = m_computed.block(firstCol, firstCol, n, n).diagonal();
   ArrayRef diag = m_workspace.head(n);
@@ -448,7 +448,7 @@
   // See Ren-Cang Li, "Solving Secular Equations Stably and Efficiently",
   // LAPACK Working Note 89 (1994), and LAPACK's xLASD4/xLASD5 for the
   // stability rationale behind pole-relative shifts and safeguarded steps.
-  using std::abs;
+  using numext::abs;
   using std::swap;
 
   Index n = col0.size();
@@ -637,7 +637,7 @@
 void bdcsvd_impl<RealScalar_>::perturbCol0(const ArrayRef& col0, const ArrayRef& diag, const IndicesRef& perm,
                                            const VectorType& singVals, const ArrayRef& shifts, const ArrayRef& mus,
                                            ArrayRef zhat) {
-  using std::abs;
+  using numext::abs;
   Index n = col0.size();
   Index m = perm.size();
   if (m == 0) {
@@ -784,7 +784,7 @@
 template <typename RealScalar_>
 void bdcsvd_impl<RealScalar_>::deflation(Index firstCol, Index lastCol, Index k, Index firstRowW, Index firstColW,
                                          Index shift) {
-  using std::abs;
+  using numext::abs;
   const Index length = lastCol + 1 - firstCol;
 
   Block<MatrixXr, Dynamic, 1> col0(m_computed, firstCol + shift, firstCol + shift, length, 1);
diff --git a/Eigen/src/SVD/SVDBase.h b/Eigen/src/SVD/SVDBase.h
index 724c6d3..595dc68 100644
--- a/Eigen/src/SVD/SVDBase.h
+++ b/Eigen/src/SVD/SVDBase.h
@@ -218,7 +218,7 @@
    *       setThreshold(const RealScalar&).
    */
   inline Index rank() const {
-    using std::abs;
+    using numext::abs;
     _check_compute_assertions();
     if (m_singularValues.size() == 0) return 0;
     RealScalar premultiplied_threshold =
diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
index 779a5d1..5ffb09e 100644
--- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
+++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h
@@ -321,7 +321,7 @@
 template <typename Derived>
 template <bool DoLDLT, bool NonHermitian, bool UsePackets>
 void SimplicialCholeskyBase<Derived>::factorize_preordered_impl(const CholMatrixType& ap) {
-  using std::sqrt;
+  using numext::sqrt;
   const StorageIndex size = StorageIndex(ap.rows());
 
   eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
diff --git a/Eigen/src/SparseCore/AmbiVector.h b/Eigen/src/SparseCore/AmbiVector.h
index 9c20262..9a6461a 100644
--- a/Eigen/src/SparseCore/AmbiVector.h
+++ b/Eigen/src/SparseCore/AmbiVector.h
@@ -321,7 +321,7 @@
    * are skipped.
    */
   explicit Iterator(const AmbiVector& vec, const RealScalar& epsilon = 0) : m_vector(vec) {
-    using std::abs;
+    using numext::abs;
     m_epsilon = epsilon;
     m_isDense = m_vector.m_mode == IsDense;
     if (m_isDense) {
@@ -350,7 +350,7 @@
   operator bool() const { return m_cachedIndex >= 0; }
 
   Iterator& operator++() {
-    using std::abs;
+    using numext::abs;
     if (m_isDense) {
       do {
         ++m_cachedIndex;
diff --git a/Eigen/src/SparseCore/SparseDot.h b/Eigen/src/SparseCore/SparseDot.h
index bcd4916..4ee00fd 100644
--- a/Eigen/src/SparseCore/SparseDot.h
+++ b/Eigen/src/SparseCore/SparseDot.h
@@ -86,7 +86,7 @@
 
 template <typename Derived>
 inline typename NumTraits<typename internal::traits<Derived>::Scalar>::Real SparseMatrixBase<Derived>::norm() const {
-  using std::sqrt;
+  using numext::sqrt;
   return sqrt(squaredNorm());
 }
 
diff --git a/Eigen/src/SparseCore/SparseProduct.h b/Eigen/src/SparseCore/SparseProduct.h
index 2ad7708..4983d81 100644
--- a/Eigen/src/SparseCore/SparseProduct.h
+++ b/Eigen/src/SparseCore/SparseProduct.h
@@ -151,7 +151,7 @@
   using Base = evaluator<PlainObject>;
 
   explicit unary_evaluator(const XprType& xpr) : m_result(xpr.rows(), xpr.cols()) {
-    using std::abs;
+    using numext::abs;
     internal::construct_at<Base>(this, m_result);
     using LhsNested = typename nested_eval<Lhs, Dynamic>::type;
     using RhsNested = typename nested_eval<Rhs, Dynamic>::type;
diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h
index 7316cf6..425a81f 100644
--- a/Eigen/src/SparseLU/SparseLU.h
+++ b/Eigen/src/SparseLU/SparseLU.h
@@ -370,7 +370,7 @@
    * \sa logAbsDeterminant(), signDeterminant()
    */
   Scalar absDeterminant() const {
-    using std::abs;
+    using numext::abs;
     eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
     // Initialize with the determinant of the row matrix
     Scalar det = Scalar(1.);
@@ -398,8 +398,8 @@
    * \sa absDeterminant(), signDeterminant()
    */
   Scalar logAbsDeterminant() const {
-    using std::abs;
-    using std::log;
+    using numext::abs;
+    using numext::log;
 
     eigen_assert(m_factorizationIsOk && "The matrix should be factorized first.");
     Scalar det = Scalar(0.);
diff --git a/Eigen/src/SparseLU/SparseLU_pivotL.h b/Eigen/src/SparseLU/SparseLU_pivotL.h
index e781801..8efb3bd 100644
--- a/Eigen/src/SparseLU/SparseLU_pivotL.h
+++ b/Eigen/src/SparseLU/SparseLU_pivotL.h
@@ -81,7 +81,7 @@
   RealScalar rtemp;
   Index isub, icol, itemp, k;
   for (isub = nsupc; isub < nsupr; ++isub) {
-    using std::abs;
+    using numext::abs;
     rtemp = abs(lu_col_ptr[isub]);
     if (rtemp > pivmax) {
       pivmax = rtemp;
@@ -106,7 +106,7 @@
     // Test if the diagonal element can be used as a pivot (given the threshold value)
     if (diag >= 0) {
       // Diagonal element exists
-      using std::abs;
+      using numext::abs;
       rtemp = abs(lu_col_ptr[diag]);
       if (rtemp != RealScalar(0.0) && rtemp >= thresh) pivptr = diag;
     }
diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h
index 9940138..4705f88 100644
--- a/Eigen/src/SparseQR/SparseQR.h
+++ b/Eigen/src/SparseQR/SparseQR.h
@@ -389,7 +389,7 @@
  */
 template <typename MatrixType, typename OrderingType>
 void SparseQR<MatrixType, OrderingType>::factorize(const MatrixType& mat) {
-  using std::abs;
+  using numext::abs;
 
   eigen_assert(m_analysisIsok && "analyzePattern() should be called before this step");
 
@@ -579,7 +579,7 @@
         beta = numext::real(c0);
         tval(Qidx(0)) = Scalar(1);
       } else {
-        using std::sqrt;
+        using numext::sqrt;
         beta = sqrt(numext::abs2(c0) + sqrNorm);
         if (numext::real(c0) >= RealScalar(0)) beta = -beta;
         tval(Qidx(0)) = Scalar(1);
@@ -609,7 +609,7 @@
     // *examined* (and never rejects a pivot that lacks a replacement). A threshold at
     // the residual's noise floor would otherwise make the pivoting decision -- and
     // hence the result -- depend on floating-point contraction.
-    using std::sqrt;
+    using numext::sqrt;
     const RealScalar weakPivotTolerance = sqrt(NumTraits<RealScalar>::epsilon());
     const RealScalar maxReplaceablePivotThreshold = max2Norm * weakPivotTolerance;
     if (nonzeroCol < diagSize && canRejectColumn && m_useDefaultThreshold && absBeta >= pivotThreshold &&
diff --git a/contrib/test/autodiff.cpp b/contrib/test/autodiff.cpp
index 2deb4ed..e7e9b42 100644
--- a/contrib/test/autodiff.cpp
+++ b/contrib/test/autodiff.cpp
@@ -9,6 +9,7 @@
 // SPDX-License-Identifier: MPL-2.0
 
 #include "main.h"
+#include <Eigen/Geometry>
 #include <Eigen/Jacobi>
 #include <Eigen/QR>
 #include <Eigen/SVD>
@@ -507,6 +508,43 @@
   }
 }
 
+template <typename Derivatives>
+void test_autodiff_hypot() {
+  using AD = AutoDiffScalar<Derivatives>;
+  for (int swapped = 0; swapped < 2; ++swapped) {
+    AD x(swapped ? 4.0 : 3.0), y(swapped ? 3.0 : 4.0);
+    x.derivatives() = Vector2d::UnitX();
+    y.derivatives() = Vector2d::UnitY();
+    const AD result = numext::hypot(x, y);
+    const double tolerance = 8 * NumTraits<double>::epsilon();
+    VERIFY(numext::abs(result.value() - 5.0) <= tolerance * 5.0);
+    VERIFY(numext::abs(result.derivatives()(0) - x.value() / 5.0) <= tolerance);
+    VERIFY(numext::abs(result.derivatives()(1) - y.value() / 5.0) <= tolerance);
+  }
+}
+
+template <typename Derivatives>
+void test_autodiff_geometry_atan2() {
+  using AD = AutoDiffScalar<Derivatives>;
+  using Vec3 = Matrix<AD, 3, 1>;
+  AD angle(0.6);
+  angle.derivatives() = Vector2d(1, 2);
+  const Quaternion<AD> rotation(AngleAxis<AD>(angle, Vec3::UnitZ()));
+  const AD distance = rotation.angularDistance(Quaternion<AD>::Identity());
+  const Vec3 axis = rotation.toScaledAxis();
+  const Matrix<AD, 2, 2> matrix = Rotation2D<AD>(angle).toRotationMatrix();
+  const AD recovered = Rotation2D<AD>(matrix).angle();
+  const double tolerance = 64 * NumTraits<double>::epsilon();
+  for (const AD* result : {&distance, &axis(2), &recovered}) {
+    VERIFY(numext::abs(result->value() - angle.value()) <= tolerance);
+    VERIFY((result->derivatives() - angle.derivatives()).cwiseAbs().maxCoeff() <= tolerance);
+  }
+  for (Index i = 0; i < 2; ++i) {
+    VERIFY_IS_EQUAL(axis(i).value(), 0.0);
+    VERIFY(axis(i).derivatives().isZero());
+  }
+}
+
 EIGEN_DECLARE_TEST(autodiff) {
   for (int i = 0; i < g_repeat; i++) {
     CALL_SUBTEST_1(test_autodiff_scalar<float>());
@@ -526,6 +564,10 @@
   CALL_SUBTEST_5(test_autodiff_selfadjoint_l1norm());
   CALL_SUBTEST_5(test_autodiff_padded_block_derivatives());
   CALL_SUBTEST_5(test_autodiff_atan2_constant());
+  CALL_SUBTEST_5(test_autodiff_hypot<Vector2d>());
+  CALL_SUBTEST_5(test_autodiff_hypot<VectorXd>());
+  CALL_SUBTEST_5(test_autodiff_geometry_atan2<Vector2d>());
+  CALL_SUBTEST_5(test_autodiff_geometry_atan2<VectorXd>());
   CALL_SUBTEST_6(test_autodiff_makegivens<Vector2d>());
   CALL_SUBTEST_6(test_autodiff_makegivens<VectorXd>());
   CALL_SUBTEST_7(test_autodiff_householder_qr<Vector4d>());
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 39b12ac..190aadc 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -683,6 +683,7 @@
   include(SyclConfigureTesting)
 
   ei_add_test(sycl_basic)
+  ei_add_test(sycl_math)
   ei_add_test(sycl_include_order)
   set(EIGEN_SYCL OFF)
 endif()
diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp
index b00bae6..a56978f 100644
--- a/test/geo_transformations.cpp
+++ b/test/geo_transformations.cpp
@@ -671,6 +671,11 @@
   Rotation2D<double> r2d1d = r2d1.template cast<double>();
   VERIFY_IS_APPROX(r2d1d.template cast<Scalar>(), r2d1);
 
+  Matrix2i quarter_turn;
+  quarter_turn << 0, -1, 1, 0;
+  const Scalar quarter_turn_angle = Rotation2D<Scalar>(quarter_turn).angle();
+  VERIFY(numext::abs(quarter_turn_angle - Scalar(EIGEN_PI) / Scalar(2)) <= Scalar(4) * NumTraits<Scalar>::epsilon());
+
   for (int k = 0; k < 100; ++k) {
     Scalar angle = internal::random<Scalar>(-100, 100);
     Rotation2D<Scalar> rot2(angle);
diff --git a/test/numext.cpp b/test/numext.cpp
index 2267446..d7ad1e4 100644
--- a/test/numext.cpp
+++ b/test/numext.cpp
@@ -23,6 +23,37 @@
 inline Scalar log10(Scalar x) { return {std::log10(x.value)}; }
 }  // namespace log10_adl_test
 
+namespace numext_dispatch_test {
+// Only numext supplies math for this scalar; generic packet fallbacks must not bypass it.
+struct Scalar {
+  double value;
+};
+}  // namespace numext_dispatch_test
+
+namespace Eigen {
+namespace numext {
+template <>
+inline numext_dispatch_test::Scalar sin(const numext_dispatch_test::Scalar& x) {
+  return {std::sin(x.value)};
+}
+template <>
+inline numext_dispatch_test::Scalar acosh(const numext_dispatch_test::Scalar& x) {
+  return {std::acosh(x.value)};
+}
+template <>
+inline numext_dispatch_test::Scalar atanh(const numext_dispatch_test::Scalar& x) {
+  return {std::atanh(x.value)};
+}
+}  // namespace numext
+}  // namespace Eigen
+
+void check_generic_packet_numext_dispatch() {
+  const numext_dispatch_test::Scalar x{0.25}, y{2.0};
+  VERIFY_IS_EQUAL(internal::psin(x).value, std::sin(x.value));
+  VERIFY_IS_EQUAL(internal::pacosh(y).value, std::acosh(y.value));
+  VERIFY_IS_EQUAL(internal::patanh(x).value, std::atanh(x.value));
+}
+
 template <typename T, typename U>
 bool check_if_equal_or_nans(const T& actual, const U& expected) {
   return (numext::equal_strict(actual, expected) || ((numext::isnan)(actual) && (numext::isnan)(expected)));
@@ -1127,7 +1158,26 @@
   }
 }
 
+template <typename Scalar>
+void check_low_precision_math_rounding() {
+  for (unsigned int bits = 0; bits < 65536; ++bits) {
+    const Scalar x = numext::bit_cast<Scalar>(numext::uint16_t(bits));
+    const Scalar actual[] = {numext::tanh(x), numext::sqrt(x), numext::log2(x)};
+    const Scalar expected[] = {Scalar(std::tanh(float(x))), Scalar(std::sqrt(float(x))), Scalar(std::log2(float(x)))};
+    for (int operation = 0; operation < 3; ++operation) {
+      if ((numext::isnan)(expected[operation])) {
+        VERIFY((numext::isnan)(actual[operation]));
+      } else {
+        VERIFY_IS_EQUAL(numext::bit_cast<numext::uint16_t>(actual[operation]),
+                        numext::bit_cast<numext::uint16_t>(expected[operation]));
+      }
+    }
+  }
+}
+
 void check_scalar_tanh_saturation() {
+  check_low_precision_math_rounding<half>();
+  check_low_precision_math_rounding<bfloat16>();
   VERIFY_IS_EQUAL(internal::ptanh_float(20.0f), 1.0f);
   VERIFY_IS_EQUAL(internal::ptanh_float(-20.0f), -1.0f);
   VERIFY_IS_EQUAL(internal::ptanh_double(20.0), 1.0);
@@ -1311,6 +1361,7 @@
     CALL_SUBTEST(check_shift<uint64_t>());
 
     CALL_SUBTEST(check_scalar_tanh_saturation());
+    CALL_SUBTEST(check_generic_packet_numext_dispatch());
     VERIFY_IS_EQUAL(numext::log10(log10_adl_test::Scalar{10.0}).value, 1.0);
     VERIFY_IS_APPROX(numext::log10(std::complex<double>(2.0, 3.0)), std::log10(std::complex<double>(2.0, 3.0)));
   }
diff --git a/test/sycl_math.cpp b/test/sycl_math.cpp
new file mode 100644
index 0000000..5854ab8
--- /dev/null
+++ b/test/sycl_math.cpp
@@ -0,0 +1,122 @@
+// SPDX-FileCopyrightText: The Eigen Authors
+// SPDX-License-Identifier: MPL-2.0
+
+#define EIGEN_USE_SYCL
+#define EIGEN_TEST_NO_LONGDOUBLE
+#include "main.h"
+#include <Eigen/Geometry>
+
+template <typename Scalar>
+void sycl_scalar_math(sycl::queue& queue) {
+  constexpr int kOutputs = 38;
+  std::vector<Scalar> result(4 * kOutputs);
+  {
+    sycl::buffer<Scalar, 1> buffer(result.data(), sycl::range<1>(result.size()));
+    queue.submit([&](sycl::handler& handler) {
+      auto output = buffer.template get_access<sycl::access::mode::write>(handler);
+      handler.parallel_for(sycl::range<1>(4), [=](sycl::id<1> id) {
+        const Scalar x = Scalar(id[0] + 1) / Scalar(4);
+        const int offset = int(id[0]) * kOutputs;
+        output[offset + 0] = internal::psin(x);
+        output[offset + 1] = internal::pcos(x);
+        output[offset + 2] = internal::ptan(x);
+        output[offset + 3] = internal::pasin(x);
+        output[offset + 4] = internal::pacos(x);
+        output[offset + 5] = internal::patan(x);
+        output[offset + 6] = internal::psinh(x);
+        output[offset + 7] = internal::pcosh(x);
+        output[offset + 8] = internal::ptanh(x);
+        output[offset + 9] = internal::pasinh(x);
+        output[offset + 10] = internal::pacosh(x + Scalar(1));
+        output[offset + 11] = internal::patanh(x / Scalar(2));
+        output[offset + 12] = numext::log(x);
+        output[offset + 13] = numext::log2(x);
+        output[offset + 14] = numext::log10(x);
+        output[offset + 15] = numext::exp(x);
+        output[offset + 16] = Array<Scalar, 1, 1>::Constant(x).pow(Scalar(1.5))(0);
+        output[offset + 17] = numext::cbrt(x);
+        output[offset + 18] = numext::sqrt(x);
+        output[offset + 19] = numext::hypot(x, Scalar(2));
+        output[offset + 20] = numext::atan2(x, Scalar(2));
+        output[offset + 21] = numext::copysign(x, Scalar(-1));
+        output[offset + 22] = numext::rint(x + Scalar(0.25));
+        const Matrix<Scalar, 3, 1> vector(Scalar(1), x, x / Scalar(2));
+        output[offset + 23] = vector.template lpNorm<3>();
+        output[offset + 24] = vector.norm();
+        const Quaternion<Scalar> rotation(AngleAxis<Scalar>(x, Matrix<Scalar, 3, 1>::UnitZ()));
+        output[offset + 25] = rotation.angularDistance(Quaternion<Scalar>::Identity());
+        output[offset + 26] =
+            rotation.slerp(Scalar(0.5), Quaternion<Scalar>::Identity()).angularDistance(Quaternion<Scalar>::Identity());
+        output[offset + 27] = Rotation2D<Scalar>(x).toRotationMatrix()(0, 1);
+        JacobiRotation<Scalar> jacobi;
+        jacobi.makeJacobi(Scalar(2), x, Scalar(3));
+        output[offset + 28] = numext::abs2(jacobi.c()) + numext::abs2(jacobi.s());
+        output[offset + 29] = Rotation2D<Scalar>(Rotation2D<Scalar>(x).toRotationMatrix()).angle();
+        output[offset + 30] = numext::copysign(Scalar(0), Scalar(-1));
+        output[offset + 31] = numext::atan2(Scalar(-0.0), Scalar(-1));
+        output[offset + 32] = Scalar(float(numext::tanh(half(float(x)))));
+        output[offset + 33] = Scalar(float(numext::tanh(bfloat16(float(x)))));
+        output[offset + 34] = Scalar(float(numext::sqrt(half(float(x)))));
+        output[offset + 35] = Scalar(float(numext::sqrt(bfloat16(float(x)))));
+        output[offset + 36] = Scalar(float(numext::log2(half(float(x)))));
+        output[offset + 37] = Scalar(float(numext::log2(bfloat16(float(x)))));
+      });
+    });
+    queue.wait_and_throw();
+  }
+  for (int i = 0; i < 4; ++i) {
+    const Scalar x = Scalar(i + 1) / Scalar(4);
+    const Scalar expected[] = {std::sin(x),
+                               std::cos(x),
+                               std::tan(x),
+                               std::asin(x),
+                               std::acos(x),
+                               std::atan(x),
+                               std::sinh(x),
+                               std::cosh(x),
+                               std::tanh(x),
+                               std::asinh(x),
+                               std::acosh(x + Scalar(1)),
+                               std::atanh(x / Scalar(2)),
+                               std::log(x),
+                               std::log2(x),
+                               std::log10(x),
+                               std::exp(x),
+                               std::pow(x, Scalar(1.5)),
+                               std::cbrt(x),
+                               std::sqrt(x),
+                               std::hypot(x, Scalar(2)),
+                               std::atan2(x, Scalar(2)),
+                               -x,
+                               std::rint(x + Scalar(0.25)),
+                               std::pow(Scalar(1) + x * x * x * Scalar(1.125), Scalar(1) / Scalar(3)),
+                               std::sqrt(Scalar(1) + x * x * Scalar(1.25)),
+                               x,
+                               x / Scalar(2),
+                               -std::sin(x),
+                               Scalar(1),
+                               x};
+    // Each composed rotation/norm uses O(10) operations and a few elementary functions.
+    for (int j = 0; j < 30; ++j) {
+      const Scalar tolerance =
+          Scalar(128) * NumTraits<Scalar>::epsilon() * (std::max)(Scalar(1), std::abs(expected[j]));
+      VERIFY(std::abs(result[i * kOutputs + j] - expected[j]) <= tolerance);
+    }
+    VERIFY_IS_EQUAL(result[i * kOutputs + 30], Scalar(0));
+    VERIFY((numext::signbit)(result[i * kOutputs + 30]));
+    VERIFY(result[i * kOutputs + 31] < Scalar(0));
+    VERIFY(std::abs(result[i * kOutputs + 31] + Scalar(EIGEN_PI)) <= Scalar(4) * NumTraits<Scalar>::epsilon());
+    VERIFY_IS_EQUAL(result[i * kOutputs + 32], Scalar(float(half(std::tanh(float(x))))));
+    VERIFY_IS_EQUAL(result[i * kOutputs + 33], Scalar(float(bfloat16(std::tanh(float(x))))));
+    VERIFY_IS_EQUAL(result[i * kOutputs + 34], Scalar(float(half(std::sqrt(float(x))))));
+    VERIFY_IS_EQUAL(result[i * kOutputs + 35], Scalar(float(bfloat16(std::sqrt(float(x))))));
+    VERIFY_IS_EQUAL(result[i * kOutputs + 36], Scalar(float(half(std::log2(float(x))))));
+    VERIFY_IS_EQUAL(result[i * kOutputs + 37], Scalar(float(bfloat16(std::log2(float(x))))));
+  }
+}
+
+EIGEN_DECLARE_TEST(sycl_math) {
+  sycl::queue queue;
+  CALL_SUBTEST(sycl_scalar_math<float>(queue));
+  if (queue.get_device().has(sycl::aspect::fp64)) CALL_SUBTEST(sycl_scalar_math<double>(queue));
+}