MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / fftTest

Function fftTest

test/fft.cpp:125–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124template<typename inType, typename outType, bool isInverse>
125void fftTest(string pTestFile, dim_t pad0 = 0, dim_t pad1 = 0, dim_t pad2 = 0) {
126 SUPPORTED_TYPE_CHECK(inType);
127 SUPPORTED_TYPE_CHECK(outType);
128
129 vector<dim4> numDims;
130 vector<vector<inType>> in;
131 vector<vector<outType>> tests;
132
133 readTestsFromFile<inType, outType>(pTestFile, numDims, in, tests);
134
135 dim4 dims = numDims[0];
136 af_array outArray = 0;
137 af_array inArray = 0;
138
139 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
140 dims.get(),
141 (af_dtype)dtype_traits<inType>::af_type));
142
143 if (isInverse) {
144 switch (dims.ndims()) {
145 case 1:
146 ASSERT_SUCCESS(af_ifft(&outArray, inArray, 1.0, pad0));
147 break;
148 case 2:
149 ASSERT_SUCCESS(af_ifft2(&outArray, inArray, 1.0, pad0, pad1));
150 break;
151 case 3:
152 ASSERT_SUCCESS(
153 af_ifft3(&outArray, inArray, 1.0, pad0, pad1, pad2));
154 break;
155 default:
156 throw std::runtime_error(
157 "This error shouldn't happen, pls check");
158 }
159 } else {
160 switch (dims.ndims()) {
161 case 1:
162 ASSERT_SUCCESS(af_fft(&outArray, inArray, 1.0, pad0));
163 break;
164 case 2:
165 ASSERT_SUCCESS(af_fft2(&outArray, inArray, 1.0, pad0, pad1));
166 break;
167 case 3:
168 ASSERT_SUCCESS(
169 af_fft3(&outArray, inArray, 1.0, pad0, pad1, pad2));
170 break;
171 default:
172 throw std::runtime_error(
173 "This error shouldn't happen, pls check");
174 }
175 }
176
177 size_t out_size = tests[0].size();
178 outType *outData = new outType[out_size];
179 ASSERT_SUCCESS(af_get_data_ptr((void *)outData, outArray));
180
181 vector<outType> goldBar(tests[0].begin(), tests[0].end());
182

Callers

nothing calls this directly

Calls 12

absFunction · 0.70
af_create_arrayFunction · 0.50
af_ifftFunction · 0.50
af_ifft2Function · 0.50
af_ifft3Function · 0.50
af_fftFunction · 0.50
af_fft2Function · 0.50
af_fft3Function · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected