Matrix Transpose

This is a discussion on Matrix Transpose within the C++ Programming forums, part of the General Programming Boards category; Code: I store matrix entries in std::vector<double>, such that the reading is row by row. This means, for matrix 1 ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    43

    Matrix Transpose

    Code:
    I store matrix entries in std::vector<double>, such that the reading is row by row. 
    This means, for matrix
     1  3  4  8  9  3
     3  6  8  1  1  2
     2  0  9  8  7  6
    
    the std::vector<double> would have entries: {1,3,4,8,9,3,3,6,8,1,1,2,2,0,9,8,7,6}. 
    To transpose the matrix I use the naive approach of iterating through std::vector, calculating for each
    entry its position in a matrix transpose. Recently, I got one suggestion:
    
    "When you have a matrix and a mapping to a one-dimensional vector, transposing is equivalent to a permutation. Now execute this permutation by sorting the elements by requested rank in the permutation result." 
    
    I understand that transposing is equivalent to a permutation, but I dont know how to approach the problem this way.
    Any suggestion on how to do this (or to do matrix transpose is a faster way) is welcome.

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    43
    Any suggestions?

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    Whats wrong with the way you did it to start with? I dont quite get what the issue you are having is? apart from curiosity to know if there is a superfix in a library to do this for you? all i would do is use operations on rows and columns integers to reorder the linear array as required, i dont know if there is anything in the stl that does this for you but if so go look it up.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help to transpose a matrix
    By velo in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2010, 02:34 PM
  2. Sorting Matrix
    By alex 2010 in forum C++ Programming
    Replies: 0
    Last Post: 06-24-2010, 09:40 AM
  3. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  4. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM
  5. Help with matrix transpose
    By sass208 in forum C Programming
    Replies: 6
    Last Post: 12-09-2006, 01:02 AM

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