本文整理汇总了C++中blitz::Array::isStorageContiguous方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::isStorageContiguous方法的具体用法?C++ Array::isStorageContiguous怎么用?C++ Array::isStorageContiguous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blitz::Array
的用法示例。
在下文中一共展示了Array::isStorageContiguous方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: binary_save
void binary_save(const blitz::Array<T,n> & M,std::string filename)
{
T z;assert(M.isStorageContiguous());
std::stringstream f;M.dumpStructureInformation(f);
std::ofstream out(filename.c_str(),std::ios::binary);
std::string s = f.str();int i=int(s.length())+1;char c='1';
out.write( (char*) &i,sizeof(i));
out.write( (s.c_str()) ,i*sizeof(c));
out.write( (char*)M.dataFirst(),M.numElements()*sizeof(z));
}
示例2: for_cons
inline void for_cons(const blitz::Array<T,n> & M, bool check_order){
need_copy = (!(M.isStorageContiguous()));
if (check_order) for (int i=0; i<n;i++) need_copy = (need_copy || (M.ordering(i)!=i));
#ifdef DEBUG_REF_WARNING
if (need_copy) std::cout<<"WARNING : REF : COPY NEEDED. Performance will be degraded"<<std::endl;
#endif
Mref = (blitz::Array<T,n> *)&M;
// The copy has the same shape but is ordered like a fortran array
if (need_copy) {Mcopy.resize(M.shape());Mcopy=M;}
}
示例3: VectorInnerProduct
double VectorInnerProduct(const blitz::Array<double, Rank> &u, const blitz::Array<double, Rank> &v)
{
if (u.size() != v.size())
{
cout << "Vector u and v is of different size: " << u.size() << " != " << v.size() << endl;
throw std::runtime_error("invalid vector sizes for inner product");
}
if (!u.isStorageContiguous())
{
throw std::runtime_error("Vector u is not contiguous");
}
if (!v.isStorageContiguous())
{
throw std::runtime_error("Vector v is not contiguous");
}
int N = u.size();
int uStride = 1; //u.stride(0);
int vStride = 1; //v.stride(0);
return BLAS_NAME(ddot)(N, (double*)u.data(), uStride, (double*)v.data(), vStride);
}
示例4: binary_load
void binary_load(blitz::Array<T,n> & M,std::string filename)
{
assert(M.isStorageContiguous());T z;
std::ifstream out(filename.c_str(),std::ios::binary);
int i;char c='1';
out.read( (char*) &i,sizeof(i));
char *st = new char[i+1];
out.read( st ,i*sizeof(c)); std::string s(st);
std::stringstream f; M.dumpStructureInformation(f);
if (f.str() != s) FATAL("Can not load binary : array do not conform. Structure (file vs array)"<<s<<"----"<<f.str());
out.read( (char*)M.dataFirst(),M.numElements()*sizeof(z));
}