Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Purely Couriosty Question...4 dimensional array

Options
  • 18-02-2003 11:29pm
    #1
    Closed Accounts Posts: 2,155 ✭✭✭


    OK firstly I'm in 3rd year of Applied Computing and have covered all of the C++ of the course since last year....

    After plenty of drink and CS in my house in Waterford, myself and my friend started into a chat about college work...which led to a chat about some of the more horrible aspects of programming...

    ...In first year of the course we had to do a stock delivery system, when many members of our class were still grappling with the idea of an array the class were presented with a 2 dimensional array...gasps were heard form the class, derogetory comments too...the concept was easily taken on board after a few attempts at the assignment and the class got over this mile stone...but a few members of the class decided to incorporate another dimension onto the assignment as in we had a dimension for the amount of stock for an item and we had another dimension for what paticular item we had selected and the last dimension was to be time, eg the stock level for item X during this month...we had discovered and utilised the 3rd dimension.....spiffy.....

    ...after the nostalgia Daithi wrote down on a piece of paper

    array[x][y][z][time]

    I looked at...seeing that Daithi had some understanding of Einstien's work on relativity...I looked at him at him and said "yeah i understand that - time being the 4th Dimension"...now Daithi is a practical person and asked me to draw out how it works

    eep!


    I can understand/get my head around relativity and most of what Stepehn Hawking throws at his publishers but ask me to draw out and explain a 4D array...my mind melted...

    why not

    array[a][c][d][e]?

    the compter supports it


    The question is...practically show me what a 4 Dimensional array looks like with out tearing down the boundrys of space and time?

    *i'll even applaud TypeDef...if he answers the question properly.. :p


Comments

  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Registered Users Posts: 2,281 ✭✭✭DeadBankClerk


    Imagine a 3d array as a load of snapshots of three dimensional space.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    temperture one I find easy to grasp (or did when I first heard it).

    Thought time was the 5th dimension though? Didn't one of the dimensions collapse in on itself?


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    There is a big difference between an n-dimensional system that you use to model something (like the use of temperature above) and the assertion that space and time is a concrete example of a 4-dimensional system (or that they are 4-dimensions of a 10 or 11 dimensional system).

    Visualising dimensions beyond 3 is tricky. It is a good mental exercise, though only somewhat applicable to programming. As DeadBankClerk suggests you can often get by by imagining an array of snapshots of 3 dimensional structures (or a 2d array of such snapshots for 5d space, and so on).

    Here is an interesting mental puzzle which relates to the skill of imagining 4d+ space:

    There are an infinte number of regular 2d shapes (equilateral triangle, square, regular pentagon, and so on).

    There are 5 regular 3d shapes (regular tetrahedron, cube, regular octahedron, regular dodecahedron, regular icosahedron).

    There are 4 regular 4d shapes, and 3 regular n-dimensional shapes for n>4. Try to work out what these are.

    (Incidentally, I've been told that there are more regular 4d shapes than that, but that the others are trickier to work out the theory of, never mind visualise).


  • Registered Users Posts: 1,391 ✭✭✭fatherdougalmag


    The question is...practically show me what a 4 Dimensional array looks like with out tearing down the boundrys of space and time?

    'Looks like' or how it's represented in memory. Fortunately, computer memory is linear/scalar. Arrays are just a particular view of memory which suits particular applications. At the end of the day, that's just for us mere mortals. But for computers, the array (no matter how many dimensions) is mapped to a linear address space by multiplying the array indexes. Trace through an app to see exactly how the compiler maps arrays. It takes the glamour out of it a bit.

    As for representing a 4-d array (shape), that's a different kettle of geometry. As far as I know, physicists are well beyond the 4th dimension. Last I heard they were up to 7.


  • Advertisement
  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    I would suggest that rather than trying to picture what a 4-dimensional array "looks like", you think of what a 4-dimensional array would be used for and how that is envisaged - lets call it your subject.

    Then think of the 4-d array you are using as a representation of this subject, rather than as an entity in its own right which needs to have a concrete shape....if you get my drift.

    I can give several examples of 4-dimensional subjects which you can draw, but none are a representation of a 4-d array. Rather, a 4-d array is capable of being a representation of any of them.

    Head hurting yet?

    jc


  • Closed Accounts Posts: 110 ✭✭Korg


    Slightly off topic but i thought it was interesting, can't remember the name of the book it's from.

    Generally people cant really visualise 3d objects let alone a 4 dimensional one, which can come as a surprise because we think we can. Imagine a 2d object, a square, no problem. Now imagine how that square would look like to a 2 dimensional being on the same plane as the square. Like us in 3d he'd be fairly sure he's seeing a 2d object but he's not. He might try visualise it as a sequence of 1d snapshots or something, but he'd never visualise the square the way we 3d people can, in it's entirety. The same goes for us with 3d objects.

    I'm sure there's some crazy people out there who can tho.


  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Closed Accounts Posts: 110 ✭✭Korg


    nope, but that's probably where the idea came from!, will make a good read, cheers


  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Advertisement
  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    An array, any array, in the sense of a computer is simply an abstraction for a chunk of memory.

    The 'dimensions' of that arrary are a convienance so that in practical terms

    char * n;

    n=(char*)malloc(20); is an analagous proposition to

    char n[20];

    and is analagous to

    char n[4][5];

    all memory chunks of 20 bytes

    much like opcodes and assembler, the assembler directives are simply a convienance for the programmer, opcodes would be faster, but, exponentially more difficult to code in.

    do I get a prize?


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Originally posted by Typedef
    char n[20];

    and is analagous to

    char n[4][5];

    all memory chunks of 20 bytes

    much like opcodes and assembler, the assembler directives are simply a convienance for the programmer, opcodes would be faster

    Yes. Just like opcodes and assembler there is a myth one is faster than the other, although the code produced is exactly the same.


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Hmm... even an assembler will abstract code you write... where writing directly what you want to do would be faster... in opcode.

    For example printf("Something") is written faster... much faster in assembler using write() directly.

    I don't think that's myth, truth be told.


  • Closed Accounts Posts: 2,155 ✭✭✭ykt0di9url7bc3


    Originally posted by Typedef

    The 'dimensions' of that arrary are a convienance so that in practical terms

    do I get a prize?

    Oh yeah the compiler can take n - dimensional arrays without any complication....its just memory...i have seen only one program to use a 4-D array....I just had a problem thinking about the model rationally in my head, as a 3-D array is easy to see the interaction between the elements but try to visualise the element relationship in a 4-D array had me a little baffled, again the computer has no problem with it and it was until gerry in IRC and DBC's post that showed me that i had to forget geometry for a while and concentrate on what was happening the true mathematics of the situation....
    Imagine a 4d array as a load of snapshots of three dimensional space.

    thanks guys...and i'll be reading flatland soon!


  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Originally posted by Typedef
    For example printf("Something") is written faster... much faster in assembler using write() directly.

    So opcodes doing a fast thing is faster than assembly doing a slow thing...

    There is a difference between abstractions provided by other code and abstractions provided by a compiler or assembler.

    The difference between char n[4][5] and char n[20] is (like the difference between push and 0x6A) provided by the compiler. A release build should have no difference (except that more natural idioms often have a better chance of being optimised well).


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by daveirl
    Out of interest will you give me an example. I don't see how I can draw in anything but 3 dimensions.

    OK. Consider a cubic space - in fact - its a space bounded by a cube. Lets call this simple space our universe. Every point in this space can be identified using your standard x, y, z co-ords, or any other 3-d coord method. Its easy to draw too, using standard isometric representation :)

    Now...Imagine that this cube actually sits on a rail - connected at some poing (centre of "bottom" face for argument's sake. It can move left/right along this rail. Now, to completely and accurately define a point within this universe, we need to define both the point on the rail, and the same 3-d coords we did previously.

    Again, this is easy to draw, because it involves the addition of a single line on top of our additional diagram :)

    Yes, its a bit of a cheat, but its a very good way to visualise a 4-d space, especially when you start adding objects into the empty space, and considering their behaviour under 4 dimensions.

    It wont take much though to see that my "track" is equally interpretable as a temporal dimension as well as a physical one.

    Hope that helps?

    jc


  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Yes, but multi-dimensional arrays are simply a representation of one-dimensional information in the first place - the memory addresses they are stored in are linear.

    If what you are asking for is a "trick" to draw a "true" 4-dimensional space, there isnt really one, not in the sense that we can draw "pseudo" 3-d on a 2-d canvas.

    I suppose you could do the same trick if you had a 3-d canvas - using colour, for example, to represent a 4-th dimension on a 3-d object. However, its still just "a trick".

    Then again...drawing 3-d objects on a 2-d canvas is just a trick too.

    jc


  • Registered Users Posts: 897 ✭✭✭Greenbean


    It might be worth looking up "hyper-cubes", 4 dimensional ones and look up some theory on Parallel processing. Alot of those cpu clusters work with log2 numbers of cpus using a hyper cubes as the network topology. I know its a tad off-topic but hey, you can represent 4dimensional objects in graphical form (even if only 2d).

    Draw an n dimensional hyper cube where n = 0;

    .


    To draw an n dimensional hyper cube where n = 1;

    Take two n-1 hyper cubes and lay them side by side.

    . .

    Then connect them:

    ._______.


    To draw an n dimensional hyper cube where n = 2;

    Take two n-1 hyper cubes and lay them side by side.

    ._______.



    ._______.

    Then connect them:

    ._______.
    | |
    | |
    | |
    ._______.

    To draw an n dimensional hyper cube where n = 3;

    Take two n-1 hyper cubes and lay them side by side.

    ._______. ._______.
    | | | |
    | | | |
    | | | |
    ._______. ._______.

    Then connect them:

    erm.. you know, connect the corners, make a cube.

    To draw an n dimensional hyper cube where n =4;

    http://dogfeathers.com/java/hyprcube.html

    :)

    Same idea.. that makes it look awfully complicated.. But just lay out 2 cubes beside each other and connect up the verts with their corresponding verts on the other cube.

    Its all very interesting when you do it this way cause you can accurately measure the amount of connections needed per dimension, each new dimension (n) requires (n-1)^2 connections. Propagating messages through the network can be done in fancy ways, ie every node can broadcast to every other node in a measurable amount of finite steps (can't remember but its something like n steps for n dimensions). A mathematicians wetdream.


  • Closed Accounts Posts: 413 ✭✭sobriquet


    The book alluded to above may be Hyperspace, by Michio Kaku.

    Very good book.


  • Advertisement
  • Closed Accounts Posts: 14,483 ✭✭✭✭daveirl


    This post has been deleted.


  • Closed Accounts Posts: 63 ✭✭D nominater


    what are the standard universe dimensions from 5 onwards?


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Yes, but multi-dimensional arrays are simply a representation of one-dimensional information in the first place - the memory addresses they are stored in are linear.

    Exactly, it's all just a chunk of memory.

    How programmer x chooses to reference that memory after allocation is semantic, essentially.


Advertisement