本文整理汇总了C++中block::BlockPtr::extract_slice方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockPtr::extract_slice方法的具体用法?C++ BlockPtr::extract_slice怎么用?C++ BlockPtr::extract_slice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block::BlockPtr
的用法示例。
在下文中一共展示了BlockPtr::extract_slice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_block
Block::BlockPtr ContiguousArrayManager::get_block(const BlockId& block_id, int& rank,
Block::BlockPtr& contiguous, sip::offset_array_t& offsets) {
//get contiguous array that contains block block_id, which must exist, and get its selectors and shape
int array_id = block_id.array_id();
rank = sip_tables_.array_rank(array_id);
contiguous = get_array(array_id);
sip::check(contiguous != NULL, "contiguous array not allocated");
const sip::index_selector_t& selector = sip_tables_.selectors(array_id);
BlockShape array_shape = sip_tables_.contiguous_array_shape(array_id); //shape of containing contiguous array
//get offsets of block_id in the containing array
for (int i = 0; i < rank; ++i) {
offsets[i] = sip_tables_.offset_into_contiguous(selector[i],
block_id.index_values(i));
}
//set offsets of unused indices to 0
std::fill(offsets + rank, offsets + MAX_RANK, 0);
//get shape of subblock
BlockShape block_shape = sip_tables_.shape(block_id);
//allocate a new block and copy data from contiguous block
Block::BlockPtr block = new Block(block_shape);
contiguous->extract_slice(rank, offsets, block);
return block;
}