Thread: Transposing a matrix made from a 1d array

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    4

    Transposing a matrix made from a 1d array

    As the title says, Im trying to transpose an arbitrary matrix made from a 1d array. I can't even figure out how to start on this. I know that I need to use for loops. Is this even possible?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Of course!

    You might want to start with declaring an array, eh?

    For loops are very appropriate. Show some spunk and give it a shot, and upload your code when you get stuck. We can't help people to learn if they won't try. Programming requires study and practice.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I didn't know transposes have any effect on arrays of ranks less than 2. In other words, it must be at least 2-dimensional or greater. I'm talking about row/column/plane etc. transposes.

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    4
    I figured out how to do it. Its just something like this:

    for loop for row
    for loop for col
    New position of array is row + (col*3)

    It may help someone

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Probably more like row * WIDTH + col.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 1d to 2d array
    By helloamuro in forum C Programming
    Replies: 6
    Last Post: 04-23-2008, 06:14 PM
  2. Weird errors.
    By Desolation in forum C++ Programming
    Replies: 20
    Last Post: 05-09-2007, 01:10 PM
  3. Help with matrix transpose
    By sass208 in forum C Programming
    Replies: 6
    Last Post: 12-09-2006, 02:02 AM
  4. Very handy matrix functions - part 1
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 05-20-2004, 10:38 AM