转置矩阵 - 水平到垂直 - OpenGL ES - iPhone
假设我有以下垂直矩阵:
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
我想对其进行翻译,以便它水平排序 - 即:
{0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15}
实现此目的最简单的方法是什么?
编辑
我已经通过手动将每个项目映射到正确的位置来完成此操作,但出于好奇想看看是否有更好的方法。
Say I have the following matrix which is vertical :
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
And I want to translate this so that it is ordered horizontally - i.e :
{0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15}
What would be easiest way to achieve this ?
EDIT
I have already done this by manually mapping each item to the correct position, but wanted to see if there was a better way out of curiosity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,对于每个 0 <= j <我< n(当n^2是矩阵的大小时),您应该交换
[i][j]
和[j][ i]
元素。Well, for every 0 <= j < i < n (when n^2 is the size of the matrix), you should swap the
[i][j]
and[j][i]
elements.