Proposal: Multidimensional opSlice solution

Norbert Nemec Norbert at Nemec-online.de
Tue Mar 9 05:27:07 PST 2010


Andrei Alexandrescu wrote:
> Norbert Nemec wrote:
>> Multidimensional arrays are the essence of the interfaces of most 
>> numerical libraries. Having several incompatible standards is a major 
>> roadblock for acceptance in the numerical community.
> 
> I'm not so sure about that. I was very enthusiastic about defining an 
> infrastructure of arbitary-dimensional arrays, and did a little research 
> about it. It turns out the applicability of N-dimensional arrays falls 
> off a cliff when N > 3. In turn, this is because high-dimensional space 
> are weird - an N-dimensional space is not just like a 3-dimensional one, 
> only with more dimensions; it's a downright weird beast.

N-dimensional arrays are not tied to N-dimensional spaces.

If you view an array as data on a space-grid, then I agree that high 
dimensionality is awkward. I did work in high-energy physics, where 
four-dimensional space-time grids are commonly used for calculations. 
With the cost scaling in the fourth power of the resolution, this is 
extremely costly. Grid methods for N>4 are indeed rarely used.

Array dimensions, however, do not need to refer to space dimension. I, 
for example, often handle electron spins as additional indices of range 
two. Or number of particles in the system, and index for the various 
configurations of the system that need to be handled. There are 
unlimited possibilities what an index may mean.

Fortran 90 limits the number of dimensions to seven and in our current 
code, we actually were hit by this limit once when adding another 
dimension would actually have been the cleanest solution.

Of course, these are rare cases and probably indicate a questionable 
design to begin with, but as scientific software grows, one often just 
wants to add a new feature in the simplest and cleanest way. Having 
unnecessary limitations can easily get in the way.



More information about the Digitalmars-d mailing list