Update complex tests with thrust master branch
MODIFY
testing/complex.cu
testing/complex.cu
@@ -30,16 +30,16 @@ struct TestComplexConstructors
a = thrust::complex<T>();
ASSERT_ALMOST_EQUAL(a,std::complex<T>(0));
- a = thrust::complex<T>(thrust::complex<float>(data[0],data[1]));
+ a = thrust::complex<T>(thrust::complex<float>(static_cast<float>(data[0]),static_cast<float>(data[1])));
ASSERT_ALMOST_EQUAL(a,b);
- a = thrust::complex<T>(thrust::complex<double>(data[0],data[1]));
+ a = thrust::complex<T>(thrust::complex<double>(static_cast<double>(data[0]),static_cast<double>(data[1])));
ASSERT_ALMOST_EQUAL(a,b);
- a = thrust::complex<T>(std::complex<float>(data[0],data[1]));
+ a = thrust::complex<T>(std::complex<float>(static_cast<float>(data[0]),static_cast<float>(data[1])));
ASSERT_ALMOST_EQUAL(a,b);
- a = thrust::complex<T>(std::complex<double>(data[0],data[1]));
+ a = thrust::complex<T>(std::complex<double>(static_cast<double>(data[0]),static_cast<double>(data[1])));
ASSERT_ALMOST_EQUAL(a,b);
}
};
@@ -284,3 +284,27 @@ struct TestComplexStreamOperators
};
SimpleUnitTest<TestComplexStreamOperators, FloatingPointTypes> TestComplexStreamOperatorsInstance;
+
+#if THRUST_CPP_DIALECT >= 2011
+template<typename T>
+struct TestComplexStdComplexDeviceInterop
+{
+ void operator()()
+ {
+ thrust::host_vector<T> data = unittest::random_samples<T>(6);
+ std::vector<std::complex<T> > vec(10);
+ vec[0] = std::complex<T>(data[0], data[1]);
+ vec[1] = std::complex<T>(data[2], data[3]);
+ vec[2] = std::complex<T>(data[4], data[5]);
+
+ thrust::device_vector<thrust::complex<T> > device_vec = vec;
+ ASSERT_ALMOST_EQUAL(vec[0].real(), thrust::complex<T>(device_vec[0]).real());
+ ASSERT_ALMOST_EQUAL(vec[0].imag(), thrust::complex<T>(device_vec[0]).imag());
+ ASSERT_ALMOST_EQUAL(vec[1].real(), thrust::complex<T>(device_vec[1]).real());
+ ASSERT_ALMOST_EQUAL(vec[1].imag(), thrust::complex<T>(device_vec[1]).imag());
+ ASSERT_ALMOST_EQUAL(vec[2].real(), thrust::complex<T>(device_vec[2]).real());
+ ASSERT_ALMOST_EQUAL(vec[2].imag(), thrust::complex<T>(device_vec[2]).imag());
+ }
+};
+SimpleUnitTest<TestComplexStdComplexDeviceInterop, FloatingPointTypes> TestComplexStdComplexDeviceInteropInstance;
+#endif

Update complex tests with thrust master branch