What defines the dimensionality of an array

arrayinformation theorytheory

I know that when we speak about an array having 1, 2, or 4 dimensions, we mean arrays like this:

1: [0]
2: [0,0]
3: [0,0,0]
4: [0,0,0,0]
...

Is the first 'axis' of an array the only thing that defines its dimensionality? Can an array with 4 dimensions be represented these ways?

[0, [0,0,0]]
[[0,0], [0,0]]

or does this fall under some other definition of dimensionality?

Another option is that a 4-dimensional array would be of the form

[ [[ [0,..],[0,..] ], [ [0,..],[0,..] ]], [[ [0,..],[0,..] ], [ [0,..],[0,..] ]], [[ [0,..],[0,..] ], [ [0,..],[0,..] ]], [[ [0,..],[0,..] ], [ [0,..],[0,..] ]] ]

e.g.

[ 
  [
    [ [0,..],[0,..] ], 
    [ [0,..],[0,..] ]
  ], 
  [
    [ [0,..],[0,..] ], 
    [ [0,..],[0,..] ]
  ], 
  [
    [ [0,..],[0,..] ], 
    [ [0,..],[0,..] ]
  ], 
  [
    [ [0,..],[0,..] ], 
    [ [0,..],[0,..] ]
  ]
]

Is this just a nomenclature nuance that I'm bringing up? Is this definition relative to the field in which we are discussing (computation vs. physical systems)?


(the thoughts came from this question.)

Best Answer

Dimensionality comes from ... dimensions!

A one-dimensional array is like one of those daily pill containers:

pill container

It's a vector, with a single index, and you can select one specific element at a time by specifying where along the line it lies.

A two-dimensional array is like a chessboard:

enter image description here

It's a matrix, with two indices, and you can select one specific element at a time by specifying where the two lines intersect. In chess notation, "a1" is the bottom left cell in the image, "h8" the top right, in most languages that would be [0,0] and [7,7] or [0][0] and [7][7].

A three-dimensional array is like a Rubik's cube (except that you can access more than just the surface elements):

enter image description here

It's a cube, with three indices, and you can select one specific element at a time by specifying where the three lines intersect.

A four-dimensional array is like ... well ... nothing real. But mathematicians have been modeling higher-dimensional structures for a long time, and some even have names. You'll have to just extend your mind to grasp them. But the computer equivalent is an even-more-natural extension,