C # / C ++: how to visualize muli-dimensional arrays

For example: a two-dimensional array can be visualized as a brick wall with square bricks, where each brick represents a coordinate in our array. A 3-dimensional array can be rendered in the same way as a field or cube.

But here is the hard part, how do you render an array with several (more than 3) dimensions? Or, for this part, how do you visualize an array with not only several dimensions, but also several dimensions in several layers?

For example: how do you render an array, such as: Array [3,3,3,3] [3,3] [3,3,3,3,3] [3]?

+6
c ++ arrays c # jagged-arrays
source share
13 answers

As you imagine, arrays really depend on their practical use. If you use arrays for spatial relationships, then you can get an idea of ​​it as a cube, but also lose the need to imagine more than three dimensions. If you really and really wanted to implement the fourth dimension of time, you can simply imagine your cube as the content changes over time.

Otherwise, you can track tightly related entries. Perhaps each of the first elements is a galaxy, the elements of the second level are star clusters, the elements of the third level are the solar systems, the elements of the fourth level are the planets, the elements of the fifth level are the continents ...

In this case, you can imagine that these are arrays in arrays. If you need a 4-dimensional array, then you can imagine a cube, but each subcube is actually a one-dimensional array.

If you need a 5-dimensional array, then you can imagine a cube, but each subcube is divided into your example of a “brick wall”.

6-dimensional - a cube, each cube of which is its own divisible cube.

It tends to fall apart after 6 measurements. Other than that, there is usually a more practical reason why you need so many measurements. For example, websites like eHarmony map them using regular geometry in 20+ -dimensional spaces. You have one dimension for “humor,” one for “good looks,” one for “love of shopping” ... Then you can take two people and apply the distance formula (the square of each of the size differences, add these differences, the square root ) and determine how compatible these two people are. So, if one person scored “5, 3, 9, 2, 8, 4, 7, 3, 1” on our 9-dimensional personality matrix, and another scored “9, 3, 7, 1, 8, 2, 8 , 4, 7 ", then your compatibility:

sqrt((5-9)^2+(3-3)^2+(9-7)^2+...) 

This can be applied to endless measurements and still work. However, since these measurements are not space related, there is no need to visualize them as such. Instead, in this particular case, we can imagine it as a one-dimensional array with several integer values. How can we simplify this array, of course, consists in the fact that our multidimensional array contains only one "1", and all the rest are "0" (indicating the location of the person in this array).

Deviating from the eHarmony example, point - after a certain number of measurements, you usually have a practical goal for an array that lends itself to a perception method.

+9
source share

Some people can mentally model n-dimensional geometry for n> 3, at least as far as simple shapes go, and some cannot. (I was very surprised when I recently talked with someone whose field was advanced n-dimensional geometry to find out that he cannot visualize a hypercube, although I can only find his math completely outside of me).

This is actually not necessary. Indeed, it is rarely necessary to visualize a two-dimensional array as Cartesian coorrdinates either - when you use a two-dimensional array in practice, you have some kind of goal for each axis, and this goal quickly becomes more important than any visual representation.

If you need to, then consider that a two-dimensional array can also be considered as an ordered set of one-dimensional structures. Similarly, a three-dimensional array can be considered as an ordered set of two-dimensional structures, or a set of sets of 1-dimensional (with these sets of equal size, allowing objects of different sizes to move to gear arrays).

Therefore, a 4-dimensional array can be considered as an ordered set of three-dimensional structures, etc.

+5
source share

Not. It is rare that you even need more than 2 or 3 dimensions. If you need more than this, then perhaps additional dimensions should be modeled as properties of the object instead, in which case you can see them as attributes and not try to imagine some kind of mythical hypercube.

+4
source share

Try to be subtractive. If you need to represent, say, a ten-dimensional array, then start by presenting the set of all n-dimensional real Euclidean vector spaces for all finite non-negative integers n. {R0, R1, R2, ...}

Now imagine that you removed almost all of this, leaving only R10.

Now imagine that you removed almost all of this, so that you only have the whole lattice points in R10.

Now imagine that you removed almost all of this, so that you only have a hyper-rectangular subset of whole lattice points.

And everything is ready; what a good visualization of a 10 dimensional array. This is very small when you think of it as a subset of the set of all possible n-dimensional vector spaces.

If you are interested in the topic of high-dimensional spaces, you can read my gentle introduction to some interesting facts about search algorithms in large-space databases:

http://blogs.msdn.com/b/ericlippert/archive/tags/high+dimensional+spaces/

+3
source share

There are many great ways to visualize multidimensional data. One of my favorites is Alfred Inselberg Parallel Coordinates , which represents each dimension as a vertical axis, and each data point as a thread connecting them all:

alt text

Another great visualization is Ramana Rao Tabletop Lens (pdf) :

alt text

This represents each dimension as a column, as in a spreadsheet, but graphically, not numerically. It is especially good to show correlation between measurements; As you sort by one dimension, it’s easy to see how the dimensions of the dimensions relate next to each other.

+2
source share

In three dimensions, your options are just a tree structure or flat pattern.

+1
source share

In the same way, you visualize 4 spatial dimensions : “slice”, overlay, or project onto what you already understand and can visualize.

+1
source share

Think of each additional dimension as a “closing box”. Think of a 2D array as an array of 1D arrays, a three-dimensional array as an array of 2D arrays, etc.

Here are some examples ...

1D 1x2 array:

 [ 1, 2 ] 

2D 2x2 array:

 { [ 1, 2 ], [ 3, 4 ] } { [ 5, 6 ], [ 7, 8 ] } 

3D 2x2x2 array:

 ( { [ 1, 2 ], [ 3, 4 ] }, { [ 5, 6 ], [ 7, 8 ] } ) ( { [ 9, 0 ], [ 1, 2 ] }, { [ 3, 4 ], [ 5, 6 ] } ) 
+1
source share

Visualize the 4D array as a 1D array of cubes. 5D array as a 2D array of cubes. And the 6D array is like a three-dimensional array of cubes, or a cube of cubes. 7D array as 1D array of cubes cubes, etc.

0
source share

Ignoring whether these measurements are raw, why not just imagine a 4D array as a 1D array (string) of “cubes”. (i.e. 1D array, where each element points to a 3D cube). This can be scaled as needed (i.e.: a 2D surface where each element points to a cube). This, of course, is not how the hypercube will "look", but it is not required.

0
source share

tabs :)

3D data tabs give you 4 dimensions, tab tabs give you dimension.

not necessarily the best way to visualize it. Also not suitable for rotation in any of the sizes.

but then it depends on what you are trying to visualize

RGB, for example, can be turned into a two-dimensional map, and then projected onto a cube, giving you 4d information

0
source share

I don't want to give up the farm here, but this is an example of how I look at multidimensional arrays in PHP.

$ card [number] [x] [y] [g] [ID] [photopath] [flag1] [flag2]

I imagine that it will look like a dot in 3D space, then I just add the sorting attributes. Here, imagine that you are playing Doom 3. Each map is divided into rooms that have pixels with x, y, and z coordinates. Each of these points can have an object identifier associated with it (monster, element, etc.). I have added more attributes for my application, but this is basically it. A point in an array need not be geometrically accurate; it can make any sense. Whether this is similar to what other people do, I do not know. I know that using the gd-graphics library will make a good visualizer for multidimensional arrays on the fly, but I didn’t get to this project the last time I worked for this client.

0
source share

You can visualize a financial report as an array into which data from several objects in the form of spreadsheets comes:

  • a single table of sales data will be a 2D array (for example, sales for each month in the quarter for the profit center);
  • several tabs in the book (one for each child) will be a three-dimensional array;

Then, for the purposes of global consolidation, the Controller can receive a book from each Region - this will be the 4th dimension. The fifth dimension can be “time” if you need to manipulate sales data over time (for example, to identify trends).

In theory, you can store long-term sales data for several regions in a single 5D array variable.

As mentioned above, you must first have an application, and then the logical data structure will help determine the appropriate physical form. Any set of attributes that can be modeled relationally can be placed into an array as usual.

Tony

0
source share

All Articles