本文整理汇总了C++中VectorMatrix::dimZ方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorMatrix::dimZ方法的具体用法?C++ VectorMatrix::dimZ怎么用?C++ VectorMatrix::dimZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorMatrix
的用法示例。
在下文中一共展示了VectorMatrix::dimZ方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gradient_cpu
void gradient_cpu(double delta_x, double delta_y, double delta_z, const double *phi, VectorMatrix &field)
{
const int dim_x = field.dimX();
const int dim_y = field.dimY();
const int dim_z = field.dimZ();
const int phi_sx = 1;
const int phi_sy = (dim_x+1);
const int phi_sz = (dim_x+1)*(dim_y+1);
VectorMatrix::accessor field_acc(field);
for (int z=0; z<dim_z; ++z)
for (int y=0; y<dim_y; ++y)
for (int x=0; x<dim_x; ++x) {
const int i = phi_sx*x + phi_sy*y + phi_sz*z;
const double dx = (+ phi[i+1*phi_sx+0*phi_sy+0*phi_sz] - phi[i+0*phi_sx+0*phi_sy+0*phi_sz]
+ phi[i+1*phi_sx+1*phi_sy+0*phi_sz] - phi[i+0*phi_sx+1*phi_sy+0*phi_sz]
+ phi[i+1*phi_sx+0*phi_sy+1*phi_sz] - phi[i+0*phi_sx+0*phi_sy+1*phi_sz]
+ phi[i+1*phi_sx+1*phi_sy+1*phi_sz] - phi[i+0*phi_sx+1*phi_sy+1*phi_sz]) / (4.0 * delta_x);
const double dy = (+ phi[i+0*phi_sx+1*phi_sy+0*phi_sz] - phi[i+0*phi_sx+0*phi_sy+0*phi_sz]
+ phi[i+1*phi_sx+1*phi_sy+0*phi_sz] - phi[i+1*phi_sx+0*phi_sy+0*phi_sz]
+ phi[i+0*phi_sx+1*phi_sy+1*phi_sz] - phi[i+0*phi_sx+0*phi_sy+1*phi_sz]
+ phi[i+1*phi_sx+1*phi_sy+1*phi_sz] - phi[i+1*phi_sx+0*phi_sy+1*phi_sz]) / (4.0 * delta_y);
const double dz = (+ phi[i+0*phi_sx+0*phi_sy+1*phi_sz] - phi[i+0*phi_sx+0*phi_sy+0*phi_sz]
+ phi[i+1*phi_sx+0*phi_sy+1*phi_sz] - phi[i+1*phi_sx+0*phi_sy+0*phi_sz]
+ phi[i+0*phi_sx+1*phi_sy+1*phi_sz] - phi[i+0*phi_sx+1*phi_sy+0*phi_sz]
+ phi[i+1*phi_sx+1*phi_sy+1*phi_sz] - phi[i+1*phi_sx+1*phi_sy+0*phi_sz]) / (4.0 * delta_z);
field_acc.set(x, y, z, Vector3d(dx, dy, dz));
}
}