21

In answering a question about double[,], I added a screenshot of LINQPad's output for that data structure:

double[,]

However, I got to wondering what a double[,,] looks like, and LINQPad won't visualize it for me. Additionally, I don't understand the format of the data which goes into it:

   int[,,] foo = new int[,,]
   { 
     { 
        { 2, 3}, 
        { 3, 4}
     },
     { 
        { 3, 4},
        { 1, 5} 
     }
   };

Can anyone visualize this for me?

Community
  • 1
  • 1
Bobson
  • 13,498
  • 5
  • 55
  • 80
  • I think the most direct way to visualize it would be with a 3D cube. I don't know if anyone wants to suggest a complicated 2D model...? – Katana314 Jul 22 '13 at 19:35
  • @Katana314, see http://stackoverflow.com/a/18304657/129164 for what I think would technically be considered a *1D* model. – devuxer Aug 19 '13 at 17:09

7 Answers7

19

You can think of this has having a set of tables stacked on top of each other. So you would need to specify a triplet to retrieve the item, which would specify which table, column, and row to get the value from.

Here's what a 3x3x3 array can be visualized as:

enter image description here

Nathan Dace
  • 1,545
  • 9
  • 21
  • And each box holds one number of the input? **Edit:** Based on @Servy's comment on his answer, I know the answer to my question is "Yes". – Bobson Jul 22 '13 at 19:45
  • Correct. Each box is an array location, which would then hold a value (a double if you used your example). – Nathan Dace Jul 22 '13 at 19:47
  • 3
    Please visualize `double[,,,,,,]` as well ;-) – Jeppe Stig Nielsen Jul 22 '13 at 22:25
  • @JeppeStigNielsen: `double[,,,]` can be visualized as a group of the 3D tables PocketDews drew for us. `double[,,,,]` can be visualized as a group of those groups. `double[,,,,,]` can be seen as a group of *those* groups (perhaps organized as a cube made up of PocketDew's cubes). `double[,,,,,,]` can be visualized as a group of *those* groups - and so on, indefinitely. – Kevin Jul 22 '13 at 23:04
  • 1
    Nothing easier to visualize than a 7-dimensional structure! – Janis F Jul 23 '13 at 06:25
9

It's a Rectangular Cuboid.

It's a three dimensional solid with 6 faces, all being rectangles.

You can further imagine that cuboid being broken up into a number of cubes, and each of those cubes having a single value.

Servy
  • 202,030
  • 26
  • 332
  • 449
  • So where is the pair `{2, 3}` (for instance)? A pair of adjoining cubes? The line between two corners? – Bobson Jul 22 '13 at 19:41
  • @Bobson In your example you have 8 different values, which is a 2x2x2 cube. `{ 2, 3}, { 3, 4}` represents the bottom half of the cube, and `{ 2, 3}` represents to adjoining cubes (making up 1/4 of the entire cube). – Servy Jul 22 '13 at 19:44
  • 1
    Ah, that makes sense now. – Bobson Jul 22 '13 at 19:45
8

It's a 3D array. So you have to do a 3D representation to visualize it.

You can think of creating a cube (or more correctly a Rectangular cuboid) with multiple Lego bricks where each brick contains 1 integer.

Cédric Bignon
  • 12,892
  • 3
  • 39
  • 51
3

That would be a cuboid (3-dimensional Array)- this goes as deep as you like (dimension wise), but visualization becomes really hard after the 3rd dimension.

You could imagine it as a stack of tables of the given kind; that analogy works recursively.

Janis F
  • 2,637
  • 1
  • 25
  • 36
3

It's 3D array (array of 2D arrays) as others said. You can use this extension for visualization.

Vano Maisuradze
  • 5,829
  • 6
  • 45
  • 73
1

It's also quite possible to represent an n-dimensional array in a "pivoted" format, such as this:

enter image description here

This is one of the easier formats to generate and read for an array with more than two dimensions.

devuxer
  • 41,681
  • 47
  • 180
  • 292
0

Multidimensional Array look like a cube with 6side and have 3 property width ,height,and depth , when u detrminet depth u put the page of 2dimension array in real when 2d array have depth more than 1 we create 3d array . look this Article For know in depth this concept. and this article for use in Programming

soheil bijavar
  • 1,213
  • 2
  • 10
  • 18