      for (SizeT l = 0; l < nz; ++l) {
        for (SizeT k = 0; k < ny; ++k) {
          z = zz[l];
          if (z < 0) z = 0; if (z > n3 - 1) z = n3 - 1;
          iz = floor(z);
          zi[0] = iz;
          zi[1] = iz + 1;
          //make in range
          if (zi[1] < 0) zi[1] = 0; else if (zi[1] > n3 - 1) zi[1] = n3 - 1;
          dz = (z - zi[0]);
          umdz = 1 - dz;

          y = yy[k];
          if (y < 0) y = 0; if (y > n2 - 1) y = n2 - 1;
          iy = floor(y);
          yi[0] = iy;
          yi[1] = iy + 1;
          //make in range
          if (yi[1] < 0) yi[1] = 0; else if (yi[1] > n2 - 1) yi[1] = n2 - 1;
          dy = (y - yi[0]);
          umdy = 1 - dy;

          for (SizeT j = 0; j < nx; ++j) { //nb output points
            vres = &(res[ncontiguous * ( l*nx*ny + k * nx + j) ]);
            x = xx[j];
            if (x < 0) x = 0; if (x > n1 - 1) x = n1 - 1;
            ix = floor(x);
            xi[0] = ix;
            xi[1] = ix + 1;
            //make in range
            if (xi[1] < 0) xi[1] = 0; else if (xi[1] > n1 - 1) xi[1] = n1 - 1;
            dx = (x - xi[0]);
            umdx = 1 - dx;

            vx0y0z0 = &(array[ncontiguous * (zi[0] * n1n2 + yi[0] * n1 + xi[0])]);
            vx1y0z0 = &(array[ncontiguous * (zi[0] * n1n2 + yi[0] * n1 + xi[1])]);
            vx0y1z0 = &(array[ncontiguous * (zi[0] * n1n2 + yi[1] * n1 + xi[0])]);
            vx1y1z0 = &(array[ncontiguous * (zi[0] * n1n2 + yi[1] * n1 + xi[1])]);
            vx0y0z1 = &(array[ncontiguous * (zi[1] * n1n2 + yi[0] * n1 + xi[0])]);
            vx1y0z1 = &(array[ncontiguous * (zi[1] * n1n2 + yi[0] * n1 + xi[1])]);
            vx0y1z1 = &(array[ncontiguous * (zi[1] * n1n2 + yi[1] * n1 + xi[0])]);
            vx1y1z1 = &(array[ncontiguous * (zi[1] * n1n2 + yi[1] * n1 + xi[1])]);
            for (SizeT i = 0; i < ncontiguous; ++i) {
              double y0z0 = umdx * vx0y0z0[i] + dx * vx1y0z0[i];
              double y1z0 = umdx * vx0y1z0[i] + dx * vx1y1z0[i];
              double y0z1 = umdx * vx0y0z1[i] + dx * vx1y0z1[i];
              double y1z1 = umdx * vx0y1z1[i] + dx * vx1y1z1[i];
              double z0 = umdy * y0z0 + dy*y1z0;
              double z1 = umdy * y0z1 + dy*y1z1;
              vres[i] = umdz * z0 + dz*z1;
            }
          }
        }
      }