3 #include <Eigen/CXX11/Tensor> 14 single_voxel_patch = tensor.extract_volume_patches(1, 1, 1);
23 single_voxel_patch_row_major = tensor_row_major.extract_volume_patches(1, 1, 1);
31 for (
int i = 0;
i < tensor.
size(); ++
i) {
42 const int patch_z = 2;
43 const int patch_y = 3;
44 const int patch_x = 5;
52 entire_volume_patch = tensor.extract_volume_patches(patch_z, patch_y, patch_x);
61 entire_volume_patch_row_major = tensor_row_major.extract_volume_patches(patch_z, patch_y, patch_x);
63 VERIFY_IS_EQUAL(entire_volume_patch_row_major.dimension(1), patch_z * patch_y * patch_x);
69 const int dz = patch_z - 1;
70 const int dy = patch_y - 1;
71 const int dx = patch_x - 1;
73 const int forward_pad_z = dz / 2;
74 const int forward_pad_y = dy / 2;
75 const int forward_pad_x = dx / 2;
77 for (
int pz = 0; pz < patch_z; pz++) {
78 for (
int py = 0;
py < patch_y;
py++) {
79 for (
int px = 0;
px < patch_x;
px++) {
80 const int patchId = pz + patch_z * (
py +
px * patch_y);
81 for (
int z = 0;
z < patch_z;
z++) {
82 for (
int y = 0;
y < patch_y;
y++) {
83 for (
int x = 0;
x < patch_x;
x++) {
87 float expected_row_major = 0.0f;
88 const int eff_z =
z - forward_pad_z + pz;
89 const int eff_y =
y - forward_pad_y +
py;
90 const int eff_x =
x - forward_pad_x +
px;
91 if (eff_z >= 0 && eff_y >= 0 && eff_x >= 0 &&
92 eff_z < patch_z && eff_y < patch_y && eff_x < patch_x) {
93 expected = tensor(
d, eff_z, eff_y, eff_x,
b);
94 expected_row_major = tensor_row_major(
b, eff_x, eff_y, eff_z,
d);
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_single_voxel_patch()
static void test_entire_volume_patch()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorLayoutSwapOp< const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > swap_layout() const
#define VERIFY_IS_EQUAL(a, b)
int RealScalar int RealScalar * py
RealScalar RealScalar * px
EIGEN_DECLARE_TEST(cxx11_tensor_volume_patch)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar * data()
#define CALL_SUBTEST(FUNC)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x