Talk:Multi-dimensional array

From Rosetta Code
Revision as of 07:15, 25 October 2016 by rosettacode>Arbautjc

limits of indices/dimensions

What is the maximum number of dimensions?

Generic, four and more.

Perhaps a mention of the range of indices?

2,3,4,5 or 5,4,3,2 items in each dimension for this example.

Are negative indices allowed?

If you have to build it then in general do enough for the task and no more (unless that little extra makes other things simpler).

Do the indices have to be numeric?

Integer.

Can a range be specified?

declare   array(1900:2050)

or somesuch syntax.

If you have it, flaunt it! but don't create it for the task.

What are the limits for the index (number)?

x = array(777888999)
Enough to do the example would suffice.

-- Gerard Schildberger (talk) 07:12, 10 January 2015 (UTC)

My answers are interspersed with your questions above. The general idea is that if you have to create multidimensional array handling for your language then you should create the minimum to accomplish the task.
If there is an idiomatic method of dealing with multi-dimensional arrays in the language then that should be used over any new creation; and if there is in-built support for multi-dimensional arrays then use that over all.
The idea is really to show how good language programmers would agree to implement the task given prior community history and language features rather than inventing something new, but if this is new to the language community then ... --Paddy3118 (talk) 08:47, 10 January 2015 (UTC)

Column-major order in Fortran

I removed something a bit silly in the page. It should probably be discussed here before attempting to give a personal opinion.

First, it's silly to compare Fortran to Algol and wonder why Fortran does not follow the Algol convention: Fortran predates Algol by several years. It's also silly to mention that MATMUL follow this "convention". It has nothing to do with that. MATMUL multiplies matrices, period. Matrices are stored in column-major order, but they could be stored in any way (diagonal order, or any fancy order), that would not change MATMUL's "interpretation": a matrix is a matrix.

There was apparently a misconception in the comment: one must not confuse array storage order with array indexing. Maybe the use of some programming languages has given the author of this comment the habit to think that arrays are naturally stored in row-major order, but this is indeed a convention. Some languages follow another convention. Some libraries use still other storage mechanisms to save place (for sparse arrays, triangular arrays, band arrays...). Still, array indexing will probably always be done like in mathematics, that is, A(i,j) is element at row i and column j, whatever the storage peculiarities may be.

Arbautjc (talk) 07:15, 25 October 2016 (UTC)