Page MenuHomeHEPForge

test_rescanArray_cmh.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

test_rescanArray_cmh.cc

#include "UnitTest++.h"
#include "test_utils.hh"
#include "npstat/nm/rescanArray.hh"
using namespace npstat;
using namespace std;
namespace {
TEST(rescanArray)
{
ArrayShape shape(3);
shape.at(0) = 3;
shape.at(1) = 4;
shape.at(2) = 5;
const unsigned dim = shape.size();
ArrayND<float> a(shape);
const unsigned len = a.length();
for (unsigned i=0; i<len; ++i)
a.linearValue(i) = test_rng();
std::vector<unsigned> idxbuf(shape);
unsigned* index = &idxbuf[0];
for (unsigned factor=2; factor<10; ++factor)
{
ArrayShape fshape(shape);
for (unsigned i=0; i<dim; ++i)
fshape[i] *= factor;
ArrayND<double> b(fshape);
rescanArray(a, &b);
const unsigned long blen = b.length();
for (unsigned long ib=0; ib<blen; ++ib)
{
b.convertLinearIndex(ib, index, dim);
for (unsigned i=0; i<dim; ++i)
index[i] /= factor;
CHECK_EQUAL(static_cast<double>(a.value(index, dim)),
b.linearValue(ib));
}
}
}
}

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 4:46 AM (15 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6548848
Default Alt Text
test_rescanArray_cmh.cc (1 KB)

Event Timeline