<cuda/std/complex>
Omissions
When using libcu++ with NVCC,
complexdoes not supportlong doubleorcomplexliterals (_i,_if, and_il). NVCC warns on any usage oflong doublein device code, becauselong doublewill be demoted todoublein device code. This warning can be suppressed silenced with#pragmas, but only globally, not just when usingcomplex. User-defined floating-point literals must be specified in terms oflong double, so they lead to warnings that are unable to be suppressed.
Extensions
Handling of infinities
Our implementation by default recovers infinite values during multiplication and division. This adds a significant runtime overhead, so we allow disabling that canonicalization if it is not desired.
Definition of
LIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONSdisables canonicalization for both multiplication and division.Definition of
LIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_MULTIPLICATIONorLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_DIVISIONdisables canonicalization for multiplication or division individually.Support for half and bfloat16 (since libcu++ 2.4.0)
Our implementation includes support for the
__halftype from<cuda_fp16.h>, when the CUDA toolkit version is at least 12.2, and whenCCCL_DISABLE_FP16_SUPPORTis not defined.This is detected automatically when compiling through NVCC. If you are compiling a host-only translation unit directly with the host compiler, you must define the macro
LIBCUDACXX_ENABLE_HOST_NVFP16prior to including any libcu++ headers, and you must ensure that the<cuda_fp16.h>header that’s found by the compiler comes from a CUDA toolkit version 12.2 or higher.Our implementation includes support for the
__nv_bfloat16type from<cuda_bf16.h>, when the conditions for the support of__halfare fulfilled, and whenCCCL_DISABLE_BF16_SUPPORTandCCCL_DISABLE_FP16_SUPPORTare not defined.C++20 constexpr
<complex>is available in C++14.