编写一个有效的代码,用于多维数组的行方式重塑

时间:2015-01-27 14:03:25

标签: c arrays multidimensional-array reshape

我正在将我的matlab代码转换为C代码。我需要为"重塑"写一个函数。类似于" reshape" function in matlab的多维数组,在" row-wise"方式。

虽然我可以写自己,但我认为我的方法效率非常低,因为我不是专家的C / C ++程序员。所以,我想知道是否someone already have some efficient code并且愿意分享。

我正在寻找与Armadillo库(C ++库)类似的东西

.reshape(n_rows, n_cols, dim=0)   // For column-wise reshaping
.reshape(n_rows, n_cols, dim=1)   // For row-wise reshaping

是否有人知道 C中的某些lib做类似的

通常in Matlab I do the following operation以行方式转换my 3D array and 4D array to equivalent 1D array

%Creating y_exp_1D_NoReg: 1D equivelent of 3D data
Temp = reshape(y_exp_3D,[sizeH*sizeV, LenTE]);
yexp1D_1 = (reshape(Temp',[sizeH*sizeV*LenTE, 1]));  



%Creating y_exp_1D_NoReg: 1D equivelent of 4D data
Temp = reshape(y_exp_4D,[sizeZ*sizeH*sizeV,LenTE]);
yexp1D_2 = (reshape(Temp',[sizeZ*sizeH*sizeV*LenTE, 1]));  

另外,对于我的C代码,我一直在使用以下库:LapackBlasTAUCS

我可以在这里找到一个例子link;但这是在C#中,因此对我无法使用。

0 个答案:

没有答案