I need help creating Rust
ndarrays with custom begin and end indices. This question is based on my StackOverflow question. Unfortunately, I don't receive answers to it on there.
In short, I'm writing a stencil-based finite difference method. I would like to calculate boundary conditions. To do that I need two planes of field values right next to the boundary. For example, my electric field array for the entire 3D space is:
use ndarray::Array3; ... const NX: usize = 100; const NY: usize = 100; const NZ: usize = 100; let mut ex = Array3::<f32>::zeros((NX, NY, NZ));
This will create an array with indices running from 0 to 99. For the boundary calculation I need two 2D slices of this array (in xy-plane) at coordinates
z=NZ. Ideally, I would need Rust support for the following syntax:
// forgive my use of Fortran-inspired syntax let mut ex_kmax = Array3::<f32>::zeros((NX, NY, NZ-1:NZ)); ... // forgive my use of Fortran-inspired syntax ex_kmax[[:,:,NZ-1:NZ]] = ex[[:,:,NZ-1:NZ]];
This new array is not a reference. It needs to contain a copy of the original
ex values. Is that possible in Rust? How can I achieve that in a native Rust way?