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

Function TEST

test/approx1.cpp:334–368  ·  view source on GitHub ↗

/////////////////////////////////// CPP //////////////////////////////////

Source from the content-addressed store, hash-verified

332//////////////////////////////////////// CPP //////////////////////////////////
333//
334TEST(Approx1, CPP) {
335 const unsigned resultIdx = 1;
336#define BT dtype_traits<float>::base_type
337 vector<dim4> numDims;
338 vector<vector<BT>> in;
339 vector<vector<float>> tests;
340 readTests<BT, float, float>(string(TEST_DIR "/approx/approx1.test"),
341 numDims, in, tests);
342
343 dim4 idims = numDims[0];
344 dim4 pdims = numDims[1];
345
346 array input(idims, &(in[0].front()));
347 array pos(pdims, &(in[1].front()));
348 const af_interp_type method = AF_INTERP_LINEAR;
349 array output = approx1(input, pos, method, 0);
350
351 // Get result
352 float* outData = new float[tests[resultIdx].size()];
353 output.host((void*)outData);
354
355 // Compare result
356 size_t nElems = tests[resultIdx].size();
357 bool ret = true;
358 for (size_t elIter = 0; elIter < nElems; ++elIter) {
359 ret = (std::abs(tests[resultIdx][elIter] - outData[elIter]) < 0.0005);
360 ASSERT_EQ(true, ret) << tests[resultIdx][elIter] << "\t"
361 << outData[elIter] << "at: " << elIter << endl;
362 }
363
364 // Delete
365 delete[] outData;
366
367#undef BT
368}
369
370TEST(Approx1, CPPNearestBatch) {
371 array input = randu(600, 10);

Callers

nothing calls this directly

Calls 15

randuFunction · 0.85
seqClass · 0.85
roundFunction · 0.85
sinFunction · 0.85
isInfFunction · 0.85
hostMethod · 0.80
absFunction · 0.70
approx1Function · 0.50
iotaFunction · 0.50
dim4Class · 0.50
tileFunction · 0.50
reorderFunction · 0.50

Tested by

no test coverage detected