Thread: arrays problem

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    3

    arrays problem

    i need to resample a 2d array in blocks of 8 X 8.
    to be more elaborate


    @ Zuk
    i am sorry i made mistake.. it looks like this now ..

    Code:
     let 
    a[40][40];
    then i want to get 
    b{ [5][5], [5][5],. . . . .,[5][5] ,
         [5][5], [5][5],. . . . .,[5][5] ,
          .
          .
          .
         [5][5], [5][5],. . . . .,[5][5] }
    
    ie (eight rows and columns  of [5][5] ) ie =64
    
    first  [5][5] array should  contain  a[0][0] to a[5][5] 
    elements of the array a[40][40].
    second [5][5]  array should  contain  a[6][6] to a[10][10]elements of the array a[40][40]. 
    and so on
    @ SlyMaelstrom:
    you are right , i mean this : 40* 40 equlas (5*5)*(8*8)
    the matrix b will be a matrix of 8 by 8 blocks while each block is 5 X 5.

    can any body please sort out the problem ..
    thanks
    Last edited by swapnil_sandy; 11-30-2005 at 03:41 PM. Reason: mistake in the problem statement

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Guess you have to know yourself from where to where you want to put your elements. I can just say it will be hard to put 64 elements ( [0][0]..[7][7] ) into an array with 25 elements.
    Kurt

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    It's also worth mentioning that:

    40 x 40 does not equal 5 x 5 x 8.

    If you want to break down a 40 by 40 array into 5 by 5 arrays, you'll need 64 of them.
    Last edited by SlyMaelstrom; 11-30-2005 at 12:48 PM.
    Sent from my iPadŽ

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    the matrix b will be a matrix of 8 by 8 blocks while each block is 5 X 5.
    You sound like you're trying to make an array of arrays.
    That's usually not a good idea. You could theoretically do this with a four dimensional array or a three dimensional array. Something like:

    int Array[5][5][8][8];

    This would (I'll try to make this easy to visualize) create something that could be seen as 8 3D boxes with the dimensions of 5x5x8 units. Or in otherwords... the 3D array of:

    int Array[5][5][64];

    Now to convert a [40][40] array into that is just a matter of knowing how you want to break the array down. Anyway I look at this, it doesn't seem like something I'd ever want or need to do.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with a problem regarding dynamic memory and arrays
    By Michty in forum C++ Programming
    Replies: 5
    Last Post: 07-26-2006, 01:26 PM
  2. assignment of arrays problem
    By HumbuckeR in forum C++ Programming
    Replies: 4
    Last Post: 04-13-2006, 04:25 PM
  3. Problem with arrays
    By dogbert234 in forum C++ Programming
    Replies: 2
    Last Post: 03-25-2006, 03:06 AM
  4. Problem with character arrays in classes
    By spoketoosoon in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2004, 03:57 AM
  5. Replies: 5
    Last Post: 12-03-2003, 05:47 PM