本文整理汇总了C++中ArrayInfo::strides方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayInfo::strides方法的具体用法?C++ ArrayInfo::strides怎么用?C++ ArrayInfo::strides使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayInfo
的用法示例。
在下文中一共展示了ArrayInfo::strides方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
static void print(af_array arr)
{
const ArrayInfo info = getInfo(arr);
T *data = new T[info.elements()];
af_array arrT;
AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3));
//FIXME: Use alternative function to avoid copies if possible
AF_CHECK(af_get_data_ptr(data, arrT));
const ArrayInfo infoT = getInfo(arrT);
AF_CHECK(af_destroy_array(arrT));
std::ios_base::fmtflags backup = std::cout.flags();
std::cout << "[" << info.dims() << "]\n";
#ifndef NDEBUG
std::cout <<" Offsets: ["<<info.offsets()<<"]"<<std::endl;
std::cout <<" Strides: ["<<info.strides()<<"]"<<std::endl;
#endif
printer(std::cout, data, infoT, infoT.ndims() - 1);
delete[] data;
std::cout.flags(backup);
}
示例2: print
static void print(const char *exp, af_array arr, const int precision, std::ostream &os = std::cout, bool transpose = true)
{
if(exp == NULL) {
os << "No Name Array" << std::endl;
} else {
os << exp << std::endl;
}
const ArrayInfo info = getInfo(arr);
vector<T> data(info.elements());
af_array arrT;
if(transpose) {
AF_CHECK(af_reorder(&arrT, arr, 1, 0, 2, 3));
} else {
arrT = arr;
}
//FIXME: Use alternative function to avoid copies if possible
AF_CHECK(af_get_data_ptr(&data.front(), arrT));
const ArrayInfo infoT = getInfo(arrT);
if(transpose) {
AF_CHECK(af_release_array(arrT));
}
std::ios_base::fmtflags backup = os.flags();
os << "[" << info.dims() << "]\n";
#ifndef NDEBUG
os <<" Offsets: [" << info.offsets() << "]" << std::endl;
os <<" Strides: [" << info.strides() << "]" << std::endl;
#endif
printer(os, &data.front(), infoT, infoT.ndims() - 1, precision);
os.flags(backup);
}
示例3: printer
static void printer(ostream &out, const T* ptr, const ArrayInfo &info, unsigned dim)
{
dim_type stride = info.strides()[dim];
dim_type d = info.dims()[dim];
ToNum<T> toNum;
if(dim == 0) {
for(dim_type i = 0, j = 0; i < d; i++, j+=stride) {
out<< std::fixed <<
std::setw(10) <<
std::setprecision(4) << toNum(ptr[j]) << " ";
}
out << endl;
}
else {
for(dim_type i = 0; i < d; i++) {
printer(out, ptr, info, dim - 1);
ptr += stride;
}
out << endl;
}
}