什么是转用C ++矩阵中的最快方法是什么?矩阵、最快、方法

2023-09-11 01:42:55 作者:久留不见

我有一个矩阵(比较大的),我需要转。例如,假设我的矩阵是

I have a matrix (relatively big) that I need to transpose. For example assume that my matrix is

a b c d e f
g h i j k l
m n o p q r 

我想要的结果如下:

I want the result be as follows:

a g m
b h n
c I o
d j p
e k q
f l r

什么是做到这一点的最快方法?

What is the fastest way to do this?

推荐答案

这是要取决于你的应用程序,但一般以最快的方式转矩阵是当你做一个仰望反转的坐标,那么你不必实际移动任何数据。

This is going to depend on your application but in general the fastest way to transpose a matrix would be to invert your coordinates when you do a look up, then you do not have to actually move any data.