I\'m trying to use thrust::transform to operate on vectors of type thrust:complex without success. The following example blows up during c
The error message is quite descriptive:
thrust::abs is a function which expects exactly one parameter, see thrust/detail/complex/arithmetic.h#L143:
template
__host__ __device__
inline ValueType abs(const complex& z){
return hypot(z.real(),z.imag());
}
For your use case, you need to wrap that function by a functor:
struct complex_abs_functor
{
template
__host__ __device__
ValueType operator()(const thrust::complex& z)
{
return thrust::abs(z);
}
};
Finally, employ that functor here:
thrust::transform(d_vec1.begin(),
d_vec1.end(),
d_vec2.begin(),
complex_abs_functor());