找到一个非常大的矩阵的转置 [英] Finding the transpose of a very, very large matrix
问题描述
我有这个巨大的二维数据数组.它以行顺序存储:
A(1,1)A(1,2)A(1,3)..... A(n-2,n)A(n-1,n)A(n,n)>
我想将其重新排列为列顺序
A(1,1)A(2,1)A(3,1)..... A(n,n-2)A(n,n-1)A(n,n)>
数据集非常大-超出了计算机RAM上的容量. (n约为10,000,但每个数据项占用约1K的空间.)
有人知道精巧或有效的算法吗?
创建n
空文件(如果可以的话,为n
元素保留足够的空间).遍历原始矩阵.将元素(i,j)
追加到文件j
.完成此操作后,请附加刚刚编写的文件.
I have this huge 2 dimensional array of data. It is stored in row order:
A(1,1) A(1,2) A(1,3) ..... A(n-2,n) A(n-1,n) A(n,n)
I want to rearrange it into column order
A(1,1) A(2,1) A(3,1) ..... A(n,n-2) A(n,n-1) A(n,n)
The data set is rather large - more than will fit on the RAM on a computer. (n is about 10,000, but each data item takes about 1K of space.)
Does anyone know slick or efficient algorithms to do this?
Create n
empty files (reserve enough space for n
elements, if you can). Iterate through your original matrix. Append element (i,j)
to file j
. Once you are done with that, append the files you just wrote.
这篇关于找到一个非常大的矩阵的转置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!