//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. // //===----------------------------------------------------------------------===// // // template // complex::type> // pow(const T& x, const complex& y); // template // complex::type> // pow(const complex& x, const U& y); // template // complex::type> // pow(const complex& x, const complex& y); #include #include #include #include "../cases.h" #include "test_macros.h" TEST_DIAG_SUPPRESS_MSVC(4244) // conversion from 'const double' to 'int', possible loss of data template __host__ __device__ void test(T x, const cuda::std::complex& y) { using promote_t = typename cuda::std::common_type::type; static_assert((cuda::std::is_same>::value), ""); assert(cuda::std::pow(x, y) == pow(cuda::std::complex(x, 0), cuda::std::complex(y))); } template __host__ __device__ void test(const cuda::std::complex& x, U y) { using promote_t = typename cuda::std::common_type::type; static_assert((cuda::std::is_same>::value), ""); assert(cuda::std::pow(x, y) == pow(cuda::std::complex(x), cuda::std::complex(y, 0))); } template __host__ __device__ void test(const cuda::std::complex& x, const cuda::std::complex& y) { using promote_t = typename cuda::std::common_type::type; assert(cuda::std::pow(x, y) == pow(cuda::std::complex(x), cuda::std::complex(y))); } template __host__ __device__ void test(typename cuda::std::enable_if::value>::type* = 0, typename cuda::std::enable_if::value>::type* = 0) { test(T(3), cuda::std::complex(4, 5)); test(cuda::std::complex(3, 4), T(5)); } template __host__ __device__ void test(typename cuda::std::enable_if::value>::type* = 0, typename cuda::std::enable_if::value>::type* = 0) { test(T(3), cuda::std::complex(4, 5)); test(cuda::std::complex(3, 4), U(5)); test(cuda::std::complex(3, 4), cuda::std::complex(5, 6)); } int main(int, char**) { test(); test(); test(); test(); test(); test(); test(); test(); // CUDA treats long double as double // test(); // test(); // test(); // test(); // test(); // test(); // test(); #if _LIBCUDACXX_HAS_NVFP16() test<__half, float>(); test<__half, double>(); test(); test(); test(); #endif // _LIBCUDACXX_HAS_NVFP16() #if _LIBCUDACXX_HAS_NVBF16() test<__nv_bfloat16, float>(); test<__nv_bfloat16, double>(); test(); test(); test(); #endif // _LIBCUDACXX_HAS_NVBF16() return 0; }