Commit 5bdc386d authored by Rasmus Munk Larsen's avatar Rasmus Munk Larsen
Browse files

Use numext:: math in library headers

parent 59208527
Loading
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -400,15 +400,15 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS
    pstoreu(sincos_vals, sFinalRes);
    for (int k = 0; k < PacketSize; ++k) {
      double val = x_cpy[k];
      if (std::abs(val) > huge_th && (numext::isfinite)(val)) {
      if (numext::abs(val) > huge_th && (numext::isfinite)(val)) {
        if (Func == TrigFunction::Sin) {
          sincos_vals[k] = std::sin(val);
          sincos_vals[k] = numext::sin(val);
        } else if (Func == TrigFunction::Cos) {
          sincos_vals[k] = std::cos(val);
          sincos_vals[k] = numext::cos(val);
        } else if (Func == TrigFunction::Tan) {
          sincos_vals[k] = std::tan(val);
          sincos_vals[k] = numext::tan(val);
        } else if (Func == TrigFunction::SinCos) {
          sincos_vals[k] = k % 2 == 0 ? std::sin(val) : std::cos(val);
          sincos_vals[k] = k % 2 == 0 ? numext::sin(val) : numext::cos(val);
        }
      }
    }
+3 −1
Original line number Diff line number Diff line
@@ -3316,7 +3316,9 @@ EIGEN_STRONG_INLINE Packet2l pabs(const Packet2l& a) {
#if EIGEN_ARCH_ARM64
  return vabsq_s64(a);
#else
  return vcombine_s64(vdup_n_s64((std::abs)(vgetq_lane_s64(a, 0))), vdup_n_s64((std::abs)(vgetq_lane_s64(a, 1))));
  // Parenthesized to keep a function-like abs macro from expanding: macro
  // expansion ignores the namespace qualification.
  return vcombine_s64(vdup_n_s64((numext::abs)(vgetq_lane_s64(a, 0))), vdup_n_s64((numext::abs)(vgetq_lane_s64(a, 1))));
#endif
}
template <>
+8 −8
Original line number Diff line number Diff line
@@ -1937,35 +1937,35 @@ EIGEN_STRONG_INLINE void ptranspose(PacketBlock<Packet16b, 16>& kernel) {
#if defined(EIGEN_VECTORIZE_FMA)
template <>
EIGEN_STRONG_INLINE float pmadd(const float& a, const float& b, const float& c) {
  return std::fmaf(a, b, c);
  return numext::fma(a, b, c);
}
template <>
EIGEN_STRONG_INLINE double pmadd(const double& a, const double& b, const double& c) {
  return std::fma(a, b, c);
  return numext::fma(a, b, c);
}
template <>
EIGEN_STRONG_INLINE float pmsub(const float& a, const float& b, const float& c) {
  return std::fmaf(a, b, -c);
  return numext::fma(a, b, -c);
}
template <>
EIGEN_STRONG_INLINE double pmsub(const double& a, const double& b, const double& c) {
  return std::fma(a, b, -c);
  return numext::fma(a, b, -c);
}
template <>
EIGEN_STRONG_INLINE float pnmadd(const float& a, const float& b, const float& c) {
  return std::fmaf(-a, b, c);
  return numext::fma(-a, b, c);
}
template <>
EIGEN_STRONG_INLINE double pnmadd(const double& a, const double& b, const double& c) {
  return std::fma(-a, b, c);
  return numext::fma(-a, b, c);
}
template <>
EIGEN_STRONG_INLINE float pnmsub(const float& a, const float& b, const float& c) {
  return std::fmaf(-a, b, -c);
  return numext::fma(-a, b, -c);
}
template <>
EIGEN_STRONG_INLINE double pnmsub(const double& a, const double& b, const double& c) {
  return std::fma(-a, b, -c);
  return numext::fma(-a, b, -c);
}
#endif

+5 −5
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ void ComplexQZ<MatrixType_>::do_QZ_step(Index p, Index q) {
        .rightCols((std::min)(m_n, m_n - k + 1))
        .applyHouseholderOnTheLeft(ess, tau, m_ws.data());
    m_T.template middleRows<3>(k).rightCols(m_n - k).applyHouseholderOnTheLeft(ess, tau, m_ws.data());
    if (m_computeQZ) m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(ess, std::conj(tau), m_ws.data());
    if (m_computeQZ) m_Q.template middleCols<3>(k).applyHouseholderOnTheRight(ess, numext::conj(tau), m_ws.data());

    // Compute Matrix Zk1 s.t. (b(k+2,k) ... b(k+2, k+2)) Zk1 = (0,0,*)
    Vec3 bprime = (m_T.template block<1, 3>(k + 2, k) * S3).adjoint();
@@ -468,12 +468,12 @@ void ComplexQZ<MatrixType_>::do_QZ_step(Index p, Index q) {
    m_S.template middleCols<3>(k).topRows((std::min)(k + 4, m_n)).applyOnTheRight(S3);
    m_S.template middleCols<3>(k)
        .topRows((std::min)(k + 4, m_n))
        .applyHouseholderOnTheRight(ess, std::conj(tau), m_ws.data());
        .applyHouseholderOnTheRight(ess, numext::conj(tau), m_ws.data());
    m_S.template middleCols<3>(k).topRows((std::min)(k + 4, m_n)).applyOnTheRight(S3.transpose());
    m_T.template middleCols<3>(k).topRows((std::min)(k + 3, m_n)).applyOnTheRight(S3);
    m_T.template middleCols<3>(k)
        .topRows((std::min)(k + 3, m_n))
        .applyHouseholderOnTheRight(ess, std::conj(tau), m_ws.data());
        .applyHouseholderOnTheRight(ess, numext::conj(tau), m_ws.data());
    m_T.template middleCols<3>(k).topRows((std::min)(k + 3, m_n)).applyOnTheRight(S3.transpose());
    if (m_computeQZ) {
      m_Z.template middleRows<3>(k).applyOnTheLeft(S3.transpose());
@@ -581,7 +581,7 @@ void ComplexQZ<MatrixType_>::push_down_zero_ST(Index k, Index l) {

    // Delete the non-desired non-zero at _S(j, j-2)
    if (j > 1) {
      J.makeGivens(std::conj(m_S(j, j - 1)), std::conj(m_S(j, j - 2)));
      J.makeGivens(numext::conj(m_S(j, j - 1)), numext::conj(m_S(j, j - 2)));
      m_S.applyOnTheRight(j - 1, j - 2, J);
      m_S(j, j - 2) = Scalar(0);
      m_T.applyOnTheRight(j - 1, j - 2, J);
@@ -591,7 +591,7 @@ void ComplexQZ<MatrixType_>::push_down_zero_ST(Index k, Index l) {

  // Assume we have the desired structure now, up to the non-zero entry at
  // _S(l, l-1) which we will delete through a last right-jacobi-rotation
  J.makeGivens(std::conj(m_S(l, l)), std::conj(m_S(l, l - 1)));
  J.makeGivens(numext::conj(m_S(l, l)), numext::conj(m_S(l, l - 1)));
  m_S.topRows(l + 1).applyOnTheRight(l, l - 1, J);

  if (!is_negligible(m_S(l, l - 1), m_normOfS * NumTraits<Scalar>::epsilon())) {
+2 −2
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ Index DGMRES<MatrixType_, Preconditioner_>::dgmresCycle(const MatrixType& mat, c
    m_H.col(it).applyOnTheLeft(it, it + 1, gr[it].adjoint());
    g.applyOnTheLeft(it, it + 1, gr[it].adjoint());

    beta = std::abs(g(it + 1));
    beta = numext::abs(g(it + 1));
    m_error = beta / normRhs;
    it++;
    nbIts++;
@@ -426,7 +426,7 @@ Index DGMRES<MatrixType_, Preconditioner_>::dgmresComputeDeflationData(const Mat

  // Reorder the absolute values of Schur values
  DenseRealVector modulEig(it);
  for (Index j = 0; j < it; ++j) modulEig(j) = std::abs(eig(j));
  for (Index j = 0; j < it; ++j) modulEig(j) = numext::abs(eig(j));
  perm.setLinSpaced(it, 0, internal::convert_index<StorageIndex>(it - 1));
  internal::sortWithPermutation(modulEig, perm, neig);

Loading