Probably it's for something like indexing by Fourier wavenumber. You represent a real-valued periodic function as a linear combination of Fourier modes exp(2 pi i k x/L) where k varies from -K to K-1. The primary representation in data is an array of complex coefficients for those modes. It might be convenient to index that array using k over the same range.
Personally, I'm ok with using 0-based or 1-based indices to index into the array and translating into Fourier wavenumber as necessary. In C++ I just have a couple array index -> wavenumber and wavenumber -> array index member functions in my Fourier-expansion classes. John On Sunday, September 27, 2015 at 2:18:08 PM UTC-4, Daniel Carrera wrote: > > I don't know anything about PDEs for plasma physics, but you made me > curious. What do you use negative indices for? Are arrays supposed to wrap > around? > > You can currently use the `end` keyword to write `foo[end-5]`, but I > assume that this is not useful to you. Right? > > > On Sunday, 27 September 2015 16:48:22 UTC+2, Mark Sherlock wrote: >> >> Hi, >> >> I work in computational physics. The main reason we all use Fortran in my >> area is because it allows arrays to have negative indices. This is very >> useful when solving some partial differential equations (in e.g. plasma >> physics, astrophysics, fluid mechanics). >> >> I and my colleagues frequently consider alternative languages but in the >> end never change due to the headaches involved regarding this. Since Julia >> seems to be focused on computational science, >> I am wondering how likely it is that this would ever be implemented, >> and/or how we could encourage the developers to do this? >> >> In all other areas Julia looks fantastic for our needs! >> >
