n dimensional arrays

This is a discussion on n dimensional arrays within the A Brief History of Cprogramming.com forums, part of the Community Boards category; has anyone used a n dimensional array where n is greater than 3. I have never seen a use for ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    n dimensional arrays

    has anyone used a n dimensional array where n is greater than 3. I have never seen a use for it. And how does everyone here picture that many dimensions. I think of it as a point with depth. I dont' know how to think of it past 4 though.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    The best picture I've seen of high dimensional arrays is to use a tree like view where each dimension is another branch level.

    Ok this is a really bad attempt but its kinda like this:
    Code:
    arr[2][2][2][2]
    
    arr___arr[0]___arr[0][0]___arr[0][0][0]___arr[0][0][0][0]
        |        |           |              |_arr[0][0][0][1]
        |        |           |
        |        |           |_arr[0][0][1]___arr[0][0][1][0]
        |        |                          |_arr[0][0][1][1]
        |        |
        |        |_arr[0][1]___arr[0][1][0]___arr[0][1][0][0]
        |                    |              |_arr[0][1][0][1]
        |                    |
        |                    |_arr[0][1][1]___arr[0][1][1][0]
        |                                   |_arr[0][1][1][1]
        |
        |_arr[1]___arr[1][0]___arr[1][0][0]___arr[1][0][0][0]
                 |           |              |_arr[1][0][0][1]
                 |           |
                 |           |_arr[1][0][1]___arr[1][0][1][0]
                 |                          |_arr[1][0][1][1]
                 |
                 |_arr[1][1]___arr[1][1][0]___arr[1][1][0][0]
                             |              |_arr[1][1][0][1]
                             |
                             |_arr[1][1][1]___arr[1][1][1][0]
                                            |_arr[1][1][1][1]
    Hope that helps you
    Last edited by Thantos; 04-18-2004 at 02:45 PM. Reason: Adding in an example

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    403
    I once read that an array w/ dimensions > 2 should be avoided, and an array w/ dimensions > 3 is an example of bad coding. I dont think I agree that it's really bad coding, but then again.. I've never seen a use for it.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Personally I hate it when someone says XYZ IS an example of bad coding since sometimes it can be the best solution.

    Take the example of a video store which wants to keep the info of each video that is in a particular slot, on a particular shelf, on a particular unit, in a particular row. While there are many ways to orginize the data one really simple way is to use a four dimensional array. store[number of rows][number of units per row][number of shelves per unit][number of slots per shelf]

    Personally I try to avoid true 2d or more arrays whenever possible and use array's of pointers in their stead.

  5. #5
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,420
    In lots of data analysis you use >3 dimensions, i guess arrays might be used in programs that perform said analysis. I don't imagine it persay except by analogy of 2 dimensions to 3 dimensions.
    Entia non sunt multiplicanda praeter necessitatem

  6. #6
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Mathematically, I use greater than 3 dimensions with some frequency, but I usually just simulate the appropriate behavior in another structure (which usually uses a 1d array for its implementation).
    Last edited by Zach L.; 04-20-2004 at 08:33 AM.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I have used 7 dimensions in a Fortran program some years ago where it was the best solution to my problem, (fluid dynamics application). I have heard of a researcher in Geophyisical Moddelling who used 66 dimensions also under Fortran.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 03:49 PM
  2. Dynamic two dimensional arrays
    By ThWolf in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 02:28 PM
  3. Two dimensional arrays
    By Masschino in forum C Programming
    Replies: 9
    Last Post: 05-18-2004, 08:17 PM
  4. two dimensional arrays
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 05-01-2002, 08:12 PM
  5. Two dimensional arrays
    By Jax in forum C Programming
    Replies: 1
    Last Post: 11-07-2001, 11:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21