本文整理汇总了C++中nd::array::get_shape方法的典型用法代码示例。如果您正苦于以下问题:C++ array::get_shape方法的具体用法?C++ array::get_shape怎么用?C++ array::get_shape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nd::array
的用法示例。
在下文中一共展示了array::get_shape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcast_error_message
inline string broadcast_error_message(const nd::array& dst, const nd::array& src)
{
vector<intptr_t> dst_shape = dst.get_shape(), src_shape = src.get_shape();
stringstream ss;
ss << "cannot broadcast dynd array with type ";
ss << src.get_type() << " and shape ";
print_shape(ss, src_shape);
ss << " to type " << dst.get_type() << " and shape ";
print_shape(ss, dst_shape);
return ss.str();
}
示例2: view
nd::array nd::view(const nd::array &arr, const ndt::type &tp)
{
if (arr.get_type() == tp) {
// If the types match exactly, simply return 'arr'
return arr;
} else if (tp.get_type_id() == bytes_type_id) {
// If it's a request to view the data as raw bytes
nd::array result = view_as_bytes(arr, tp);
if (!result.is_null()) {
return result;
}
} else if (arr.get_type().get_type_id() == bytes_type_id) {
// If it's a request to view raw bytes as something else
nd::array result = view_from_bytes(arr, tp);
if (!result.is_null()) {
return result;
}
} else if (arr.get_ndim() == tp.get_ndim()) {
// If the type is symbolic, e.g. has a "Fixed" symbolic dimension,
// first substitute in the shape from the array
if (tp.is_symbolic()) {
dimvector shape(arr.get_ndim());
arr.get_shape(shape.get());
return view_concrete(arr, substitute_shape(tp, arr.get_ndim(), shape.get()));
} else {
return view_concrete(arr, tp);
}
}
stringstream ss;
ss << "Unable to view nd::array of type " << arr.get_type();
ss << " as type " << tp;
throw type_error(ss.str());
}