| 87 | } |
| 88 | |
| 89 | void TearDown() override { |
| 90 | KernelMatrix *kernelMatrix = new KernelMatrix(dataSet.instances(), param); |
| 91 | kernelMatrix->get_rows(rows, kernel_rows); |
| 92 | |
| 93 | //test diagonal elements |
| 94 | for (unsigned i = 0; i < kernelMatrix->diag().size(); ++i) { |
| 95 | float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), i, i, param); |
| 96 | float_type gpu_kernel = kernelMatrix->diag().host_data()[i]; |
| 97 | EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << i; |
| 98 | } |
| 99 | |
| 100 | //test get rows with index |
| 101 | for (unsigned i = 0; i < rows.size(); ++i) { |
| 102 | for (unsigned j = 0; j < kernelMatrix->n_instances(); ++j) { |
| 103 | float_type gpu_kernel = kernel_rows.host_data()[i * kernelMatrix->n_instances() + j]; |
| 104 | float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), rows.host_data()[i], j, param); |
| 105 | EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << rows.host_data()[i] << "," << j; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | //test get rows with instances |
| 110 | kernelMatrix->get_rows(instances, kernel_rows); |
| 111 | |
| 112 | for (unsigned i = 0; i < n_rows; ++i) { |
| 113 | for (unsigned j = 0; j < kernelMatrix->n_instances(); ++j) { |
| 114 | float_type gpu_kernel = kernel_rows.host_data()[i * kernelMatrix->n_instances() + j]; |
| 115 | float_type cpu_kernel = get_cpu_kernel(dataSet.instances(), i, j, param); |
| 116 | EXPECT_NEAR(gpu_kernel, cpu_kernel, 1e-4) << i << "," << j; |
| 117 | } |
| 118 | } |
| 119 | delete kernelMatrix; |
| 120 | } |
| 121 | }; |
| 122 | |
| 123 | TEST_F(KernelMatrixTest, test_rbf) { |
nothing calls this directly
no test coverage detected