#include #include "CudaMatrix.h" #include "Matrix.h" #include "TestUtility.h" #include "Function1D.h" #include "Function1D.cuh" class Function1D_Cuda_Test:public ::testing::Test { protected: static void SetUpFunction1DCudaTester(){ } static void TearDownTestCase(){ } void SetUp(){ } void TearDown(){ } }; TEST_F(Function1D_Cuda_Test, complex) { Aurora::Matrix hostMatrix = Aurora::Matrix::fromRawData(new float[8]{1,2,3,4,5,6,7,8}, 2,2,2); Aurora::CudaMatrix deviceMatrix = hostMatrix.toDeviceMatrix(); auto result1 = Aurora::complex(hostMatrix); auto result2 = Aurora::complex(deviceMatrix).toHostMatrix(); EXPECT_EQ(result2.getDataSize(), 8); EXPECT_EQ(result2.getValueType(), Aurora::Complex); for(size_t i=0; i::infinity(); float* data = new float[9]{infinite,3,n,2,2,1,4,4,7}; auto matrix = Aurora::Matrix::fromRawData(data, 9,1,1).toDeviceMatrix(); auto r = Aurora::isnan(matrix); EXPECT_FLOAT_EQ(r.getValue(0),0); EXPECT_FLOAT_EQ(r.getValue(1),0); EXPECT_FLOAT_EQ(r.getValue(2),1); r = Aurora::isfinite(matrix); EXPECT_FLOAT_EQ(r.getValue(0),0); EXPECT_FLOAT_EQ(r.getValue(1),1); EXPECT_FLOAT_EQ(r.getValue(2),0); Aurora::nantoval(matrix,1); EXPECT_FLOAT_EQ(matrix.getValue(2),1); float* data2 = new float[1]{n}; auto matrix2 = Aurora::Matrix::fromRawData(data2, 1,1,1).toDeviceMatrix(); r = Aurora::isnan(matrix2); EXPECT_FLOAT_EQ(r.getValue(0),1); r = Aurora::isfinite(matrix2); EXPECT_FLOAT_EQ(r.getValue(0),0); Aurora::nantoval(matrix2,1); EXPECT_FLOAT_EQ(matrix2.getValue(0),1); } TEST_F(Function1D_Cuda_Test, isnanOrfinite) { float *input = new float[18]{10,2,1,3,4,4,16,3,1,2,15,-2,1,-3,4,-4,1,-3}; auto ma = Aurora::Matrix::fromRawData(input,18,1,1).toDeviceMatrix(); Aurora::padding(ma,20,1); EXPECT_FLOAT_AE(ma.getValue(19),1); EXPECT_FLOAT_AE(ma.getValue(20),1); Aurora::padding(ma,10,-1); EXPECT_FLOAT_AE(ma.getValue(10),-1); } TEST_F(Function1D_Cuda_Test, padding) { float *input = new float[18]{10,2,1,3,4,4,16,3,1,2,15,-2,1,-3,4,-4,1,-3}; auto ma = Aurora::Matrix::fromRawData(input,18,1,1).toDeviceMatrix(); Aurora::padding(ma,20,1); EXPECT_FLOAT_AE(ma.getValue(19),1); EXPECT_FLOAT_AE(ma.getValue(20),1); Aurora::padding(ma,10,-1); EXPECT_FLOAT_AE(ma.getValue(10),-1); } TEST_F(Function1D_Cuda_Test, not) { Aurora::Matrix hostMatrix = Aurora::Matrix::fromRawData(new float[8]{-1.1,2.2,-3.3,0,-5.5,6.6,0.7,-0.8}, 2,4); Aurora::CudaMatrix deviceMatrix = hostMatrix.toDeviceMatrix(); auto result1 = Aurora::auroraNot(hostMatrix); auto result2 = Aurora::auroraNot(deviceMatrix); EXPECT_EQ(result2.getDataSize(), result1.getDataSize()); EXPECT_EQ(result2.getValueType(), result1.getValueType()); for(size_t i=0; i