I want to reshape an array in Julia using the reshape
function but the shape of the new array is stored as a 1-D array itself.
(我想使用reshape
函数在Julia中对数组进行整形,但是新数组的形状本身存储为一维数组。)
reshape
takes tuples as argument but not 1D array. (reshape
将元组作为参数,而不是一维数组。)
For example, I want to be able to do this:
(例如,我希望能够做到这一点:)
reshape([1 2 3 ; 4 5 6],(3,2))
but using [3,2]
instead of (3,2)
as the input to the shape parameter.
(但使用[3,2]
代替(3,2)
作为shape参数的输入。)
Converting array [3,2]
to tuple (3,2)
seems like the obvious thing to do, but if that can't be done, maybe I need to write another reshape
function? (将数组[3,2]
转换为元组(3,2)
似乎是显而易见的事情,但是如果无法完成,也许我需要编写另一个reshape
函数?)
Any advice is appreciated.
(任何建议表示赞赏。)
ask by truedichotomy translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…