本文整理汇总了C++中DataArray::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataArray::getData方法的具体用法?C++ DataArray::getData怎么用?C++ DataArray::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataArray
的用法示例。
在下文中一共展示了DataArray::getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
void SortTimeFunction::f() {
const int n = m_copy.size();
const int elementSize = m_copy.getElementSize();
DataArray data = m_copy;
switch(elementSize) {
case 1 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<BYTE>( m_compareCount)); break;
case 2 : m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned short>(m_compareCount)); break;
default: m_sortMethod->getMethod()(data.getData(), n, elementSize, CountComparator<unsigned int >(m_compareCount)); break;
}
}
示例2: testData
void BaseTestDataArray::testData() {
typedef boost::multi_array<double, 3> array_type;
typedef array_type::index index;
array_type A(boost::extents[3][4][2]);
int values = 0;
for(index i = 0; i != 3; ++i)
for(index j = 0; j != 4; ++j)
for(index k = 0; k != 2; ++k)
A[i][j][k] = values++;
CPPUNIT_ASSERT_EQUAL(array1.dataType(), nix::DataType::Double);
CPPUNIT_ASSERT_EQUAL(array1.dataExtent(), nix::NDSize({0, 0, 0}));
CPPUNIT_ASSERT(array1.getDimension(1) == false);
array1.setData(A);
array_type B(boost::extents[1][1][1]);
array1.getData(B);
int verify = 0;
int errors = 0;
for(index i = 0; i != 3; ++i) {
for(index j = 0; j != 4; ++j) {
for(index k = 0; k != 2; ++k) {
int v = verify++;
errors += B[i][j][k] != v;
}
}
}
CPPUNIT_ASSERT_EQUAL(errors, 0);
DataArray direct = block.createDataArray("da_direct", "double", A);
array_type Adirect(boost::extents[3][4][2]);
direct.getData(Adirect);
errors = 0;
verify = 0;
for(index i = 0; i != 3; ++i) {
for(index j = 0; j != 4; ++j) {
for(index k = 0; k != 2; ++k) {
int v = verify++;
errors += Adirect[i][j][k] != v;
}
}
}
CPPUNIT_ASSERT_EQUAL(0, errors);
//test createDataArray overload that takes data but specify an storage datat type
DataArray directFloat = block.createDataArray("da_direct_int", "int", A, DataType::Int32);
CPPUNIT_ASSERT_EQUAL(DataType::Int32, directFloat.dataType());
boost::multi_array<int, 3> AdirectFloat(boost::extents[3][4][2]);
direct.getData(AdirectFloat);
errors = 0;
verify = 0;
for(index i = 0; i != 3; ++i) {
for(index j = 0; j != 4; ++j) {
for(index k = 0; k != 2; ++k) {
int v = verify++;
errors += AdirectFloat[i][j][k] != v;
}
}
}
CPPUNIT_ASSERT_EQUAL(0, errors);
typedef boost::multi_array<double, 2> array2D_type;
typedef array_type::index index;
array2D_type C(boost::extents[5][5]);
for(index i = 0; i != 5; ++i)
for(index j = 0; j != 5; ++j)
C[i][j] = 42.0;
CPPUNIT_ASSERT_EQUAL(array2.dataExtent(), nix::NDSize({20, 20}));
array2.setData(C, nix::NDSize({0, 0}));
array2.dataExtent(nix::NDSize({40, 40}));
CPPUNIT_ASSERT_EQUAL(array2.dataExtent(), nix::NDSize({40, 40}));
array2D_type D(boost::extents[5][5]);
for(index i = 0; i != 5; ++i)
for(index j = 0; j != 5; ++j)
D[i][j] = 42.0;
array2.setData(D, nix::NDSize({ 20, 20 }));
array2D_type E(boost::extents[1][1]);
array2.getData(E, nix::NDSize({ 5, 5 }), nix::NDSize({ 20, 20 }));
for(index i = 0; i != 5; ++i)
for(index j = 0; j != 5; ++j)
CPPUNIT_ASSERT_DOUBLES_EQUAL(D[i][j], E[i][j],
std::numeric_limits<double>::epsilon());
//.........这里部分代码省略.........
示例3: getOffsetAndCount
void getOffsetAndCount(const MultiTag &tag, const DataArray &array, size_t index, NDSize &offsets, NDSize &counts) {
DataArray positions = tag.positions();
DataArray extents = tag.extents();
NDSize position_size, extent_size;
size_t dimension_count = array.dimensionCount();
if (positions) {
position_size = positions.dataExtent();
}
if (extents) {
extent_size = extents.dataExtent();
}
if (!positions || index >= position_size[0]) {
throw nix::OutOfBounds("Index out of bounds of positions!", 0);
}
if (extents && index >= extent_size[0]) {
throw nix::OutOfBounds("Index out of bounds of positions or extents!", 0);
}
if (position_size.size() == 1 && dimension_count != 1) {
throw nix::IncompatibleDimensions("Number of dimensions in positions does not match dimensionality of data",
"util::getOffsetAndCount");
}
if (position_size.size() > 1 && position_size[1] > dimension_count) {
throw nix::IncompatibleDimensions("Number of dimensions in positions does not match dimensionality of data",
"util::getOffsetAndCount");
}
if (extents && extent_size.size() > 1 && extent_size[1] > dimension_count) {
throw nix::IncompatibleDimensions("Number of dimensions in extents does not match dimensionality of data",
"util::getOffsetAndCount");
}
NDSize temp_offset = NDSize{static_cast<NDSize::value_type>(index), static_cast<NDSize::value_type>(0)};
NDSize temp_count{static_cast<NDSize::value_type>(1), static_cast<NDSize::value_type>(dimension_count)};
vector<double> offset;
positions.getData(offset, temp_count, temp_offset);
NDSize data_offset(dimension_count, static_cast<size_t>(0));
NDSize data_count(dimension_count, static_cast<size_t>(1));
vector<string> units = tag.units();
for (size_t i = 0; i < offset.size(); ++i) {
Dimension dimension = array.getDimension(i+1);
string unit = "none";
if (i <= units.size() && units.size() > 0) {
unit = units[i];
}
data_offset[i] = positionToIndex(offset[i], unit, dimension);
}
if (extents) {
vector<double> extent;
extents.getData(extent, temp_count, temp_offset);
for (size_t i = 0; i < extent.size(); ++i) {
Dimension dimension = array.getDimension(i+1);
string unit = "none";
if (i <= units.size() && units.size() > 0) {
unit = units[i];
}
ndsize_t c = positionToIndex(offset[i] + extent[i], unit, dimension) - data_offset[i];
data_count[i] = (c > 1) ? c : 1;
}
}
offsets = data_offset;
counts = data_count;
}