本文整理汇总了C++中nd::array::get_flags方法的典型用法代码示例。如果您正苦于以下问题:C++ array::get_flags方法的具体用法?C++ array::get_flags怎么用?C++ array::get_flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nd::array
的用法示例。
在下文中一共展示了array::get_flags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: array
static nd::array view_as_bytes(const nd::array &arr, const ndt::type &tp)
{
if (arr.get_type().get_flags() & type_flag_destructor) {
// Can't view arrays of object type
return nd::array();
}
// Get the essential components of the array to analyze
memory_block_ptr data_ref = arr.get_data_memblock();
char *data_ptr = arr.get_ndo()->data.ptr;
ndt::type data_tp = arr.get_type();
const char *data_meta = arr.get_arrmeta();
intptr_t data_dim_size = -1, data_stride = 0;
// Repeatedly refine the data
while (data_tp.get_type_id() != uninitialized_type_id) {
refine_bytes_view(data_ref, data_ptr, data_tp, data_meta, data_dim_size, data_stride);
}
// Check that it worked, and that the resulting data pointer is aligned
if (data_dim_size < 0 ||
!offset_is_aligned(reinterpret_cast<size_t>(data_ptr), tp.extended<ndt::bytes_type>()->get_target_alignment())) {
// This signals we could not view the data as a
// contiguous chunk of bytes
return nd::array();
}
char *result_data_ptr = NULL;
nd::array result(make_array_memory_block(tp.extended()->get_arrmeta_size(), tp.get_data_size(),
tp.get_data_alignment(), &result_data_ptr));
// Set the bytes extents
((char **)result_data_ptr)[0] = data_ptr;
((char **)result_data_ptr)[1] = data_ptr + data_dim_size;
// Set the array arrmeta
array_preamble *ndo = result.get_ndo();
ndo->m_type = ndt::type(tp).release();
ndo->data.ptr = result_data_ptr;
ndo->data.ref = NULL;
ndo->m_flags = arr.get_flags();
// Set the bytes arrmeta
bytes_type_arrmeta *ndo_meta = reinterpret_cast<bytes_type_arrmeta *>(result.get_arrmeta());
ndo_meta->blockref = data_ref.release();
return result;
}