Skip to content

Commit

Permalink
Fixed proj(...) so that it compiles under NVCC
Browse files Browse the repository at this point in the history
- Prefaced function calls with KOKKOS_FUNCTION
- Replaced std::numeric_limits<RealType>::infinity() with INFINITY
  (Kokkos::Experimental::infinity_v didn't work either)
- Call the Kokkos versions of isinf(...) and abs(...)
  • Loading branch information
nliber committed Oct 9, 2024
1 parent abfbd05 commit c04be10
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/src/Kokkos_Complex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,23 +795,24 @@ KOKKOS_FUNCTION constexpr double norm(IntegerType i) noexcept {
//! The projection onto the Riemann sphere
// based on libc++ implementation
template <typename RealType>
constexpr complex<RealType> proj(const complex<RealType>& x) noexcept {
return isinf(x.real()) || isinf(x.imag())
KOKKOS_FUNCTION constexpr complex<RealType> proj(
const complex<RealType>& x) noexcept {
return Kokkos::isinf(x.real()) || Kokkos::isinf(x.imag())
? complex<RealType>(
std::numeric_limits<RealType>::infinity(),
INFINITY,
Kokkos::copysign(static_cast<RealType>(0), x.imag()))
: x;
}

template <typename RealType,
typename = std::enable_if_t<std::is_floating_point_v<RealType>>>
constexpr complex<RealType> proj(RealType f) noexcept {
return complex<RealType>(isinf(f) ? std::abs(f) : f);
KOKKOS_FUNCTION constexpr complex<RealType> proj(RealType f) noexcept {
return complex<RealType>(Kokkos::isinf(f) ? Kokkos::abs(f) : f);
}

template <typename IntegerType,
typename = std::enable_if_t<std::is_integral_v<IntegerType>>>
constexpr complex<double> proj(IntegerType i) noexcept {
KOKKOS_FUNCTION constexpr complex<double> proj(IntegerType i) noexcept {
return complex<double>(static_cast<double>(i));
}

Expand Down

0 comments on commit c04be10

Please sign in to comment.