当前位置: 首页>>代码示例>>C++>>正文


C++ Array::isStorageContiguous方法代码示例

本文整理汇总了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));
}
开发者ID:Swagataacharya,项目名称:TRIQS,代码行数:10,代码来源:blitz_op.hpp

示例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;}
  }
开发者ID:Swagataacharya,项目名称:TRIQS,代码行数:10,代码来源:blitz_op.hpp

示例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);
}
开发者ID:AtomAleks,项目名称:PyProp,代码行数:20,代码来源:blitzblas_acml.cpp

示例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));
}
开发者ID:Swagataacharya,项目名称:TRIQS,代码行数:12,代码来源:blitz_op.hpp


注:本文中的blitz::Array::isStorageContiguous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。