Skip to content

Commit

Permalink
Clean up complex.inl (#1655)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZelboK committed Jul 19, 2024
1 parent 97e699f commit 2ff83a2
Showing 1 changed file with 1 addition and 64 deletions.
65 changes: 1 addition & 64 deletions thrust/thrust/detail/complex/complex.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 NVIDIA Corporation
* Copyright 2008-2024 NVIDIA Corporation
* Copyright 2013 Filipe RNC Maia
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -26,97 +26,44 @@ THRUST_NAMESPACE_BEGIN

/* --- Constructors --- */

#if THRUST_CPP_DIALECT < 2011
template <typename T>
_CCCL_HOST_DEVICE complex<T>::complex()
{
real(T());
imag(T());
}
#endif

template <typename T>
_CCCL_HOST_DEVICE complex<T>::complex(const T& re)
#if THRUST_CPP_DIALECT >= 2011
// Initialize the storage in the member initializer list using C++ unicorn
// initialization. This allows `complex<T const>` to work.
: data{re, T()}
{}
#else
{
real(re);
imag(T());
}
#endif

template <typename T>
_CCCL_HOST_DEVICE complex<T>::complex(const T& re, const T& im)
#if THRUST_CPP_DIALECT >= 2011
// Initialize the storage in the member initializer list using C++ unicorn
// initialization. This allows `complex<T const>` to work.
: data{re, im}
{}
#else
{
real(re);
imag(im);
}
#endif

#if THRUST_CPP_DIALECT < 2011
template <typename T>
_CCCL_HOST_DEVICE complex<T>::complex(const complex<T>& z)
{
real(z.real());
imag(z.imag());
}
#endif

template <typename T>
template <typename U>
_CCCL_HOST_DEVICE complex<T>::complex(const complex<U>& z)
#if THRUST_CPP_DIALECT >= 2011
// Initialize the storage in the member initializer list using C++ unicorn
// initialization. This allows `complex<T const>` to work.
// We do a functional-style cast here to suppress conversion warnings.
: data{T(z.real()), T(z.imag())}
{}
#else
{
real(T(z.real()));
imag(T(z.imag()));
}
#endif

template <typename T>
_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>::complex(const std::complex<T>& z)
#if THRUST_CPP_DIALECT >= 2011
// Initialize the storage in the member initializer list using C++ unicorn
// initialization. This allows `complex<T const>` to work.
: data{THRUST_STD_COMPLEX_REAL(z), THRUST_STD_COMPLEX_IMAG(z)}
{}
#else
{
real(THRUST_STD_COMPLEX_REAL(z));
imag(THRUST_STD_COMPLEX_IMAG(z));
}
#endif

template <typename T>
template <typename U>
_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>::complex(const std::complex<U>& z)
#if THRUST_CPP_DIALECT >= 2011
// Initialize the storage in the member initializer list using C++ unicorn
// initialization. This allows `complex<T const>` to work.
// We do a functional-style cast here to suppress conversion warnings.
: data{T(THRUST_STD_COMPLEX_REAL(z)), T(THRUST_STD_COMPLEX_IMAG(z))}
{}
#else
{
real(T(THRUST_STD_COMPLEX_REAL(z)));
imag(T(THRUST_STD_COMPLEX_IMAG(z)));
}
#endif

/* --- Assignment Operators --- */

Expand All @@ -128,16 +75,6 @@ _CCCL_HOST_DEVICE complex<T>& complex<T>::operator=(const T& re)
return *this;
}

#if THRUST_CPP_DIALECT < 2011
template <typename T>
_CCCL_HOST_DEVICE complex<T>& complex<T>::operator=(const complex<T>& z)
{
real(z.real());
imag(z.imag());
return *this;
}
#endif

template <typename T>
template <typename U>
_CCCL_HOST_DEVICE complex<T>& complex<T>::operator=(const complex<U>& z)
Expand Down

0 comments on commit 2ff83a2

Please sign in to comment.