本文整理汇总了C++中blitz::Array::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::data方法的具体用法?C++ Array::data怎么用?C++ Array::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blitz::Array
的用法示例。
在下文中一共展示了Array::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
void GmresWrapper<Rank>::ApplyOperator(blitz::Array<cplx, 1> &input, blitz::Array<cplx, 1> &output)
{
if (Psi == 0)
{
throw std::runtime_error("Psi is 0");
}
if (TempPsi == 0)
{
throw std::runtime_error("TempPsi is 0");
}
//Map the 1d vectors to a a blitz array of correct shape
DataVector shape = Psi->GetData().shape();
DataVector stride = Psi->GetData().stride();
DataArray inData(input.data(), shape, stride, blitz::neverDeleteData);
DataArray inData2(input.data(), shape, stride, blitz::neverDeleteData);
DataArray outData(output.data(), shape, stride, blitz::neverDeleteData);
DataArray outData2(output.data(), shape, stride, blitz::neverDeleteData);
outData = 0;
//Set psi and tempPsi to point to correct vectorsbuffers
DataArray oldData = Psi->GetData();
DataArray oldTempData = TempPsi->GetData();
Psi->SetData(inData);
TempPsi->SetData(outData);
OperatorCallback(Psi, TempPsi);
//Restore the former buffers
Psi->SetData(oldData);
TempPsi->SetData(oldTempData);
}
示例2: netcdf_write_blitz
void netcdf_write_blitz(NcVar *nc_var, blitz::Array<T, rank> const &val)
{
long counts[rank];
for (int i=0; i<rank; ++i) counts[i] = val.extent(i);
//printf("netcdf_write_blitz: %p %p\n", nc_var, val.data());
nc_var->put(val.data(), counts);
}
示例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);
}