Sorry, my question is after the first small code block, with an additional comment after the second one. The rest is just to see my implementation.
I use calloc to realize negative indexation like
for(int z=-1 ; z < nz+1 ; z++) array[z];
I have no idea to realized those things in 2D/3D/4D with "new" and I used C in the past ...