Matrix transposition using recusrion

天大地大妈咪最大 提交于 2019-12-25 01:45:06

问题


Can you please give me some sort of pseudo code for matrix transposition using recursion? If it is in one function that will be great.

PS: This might not be a question but I couldn't find the information anywhere. If you know of a site about pseudo codes for recursion that will be awesome.


回答1:


For a square MxM matrix:

function transpose (x0, y0, x1, y1)
    if (M > 1)
        transpose (0, 0, M/2, M/2) // A
        transpose (0, M/2, M/2, M) // B
        transpose (M/2, 0, M, M/2) // C
        transpose (M/2, M/2, M, M) // D
        swap blocks B and C
    endif

transpose (0, 0, M, M)


来源:https://stackoverflow.com/questions/13291231/matrix-transposition-using-recusrion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!