【问题标题】:Inverse of Flatten in Mathematica?Mathematica中展平的逆?
【发布时间】:2013-12-14 06:36:06
【问题描述】:

f[x_]:=Flatten[x] 的倒数是什么,其中 x 是尺寸为暗淡的数组?

【问题讨论】:

    标签: wolfram-mathematica


    【解决方案1】:

    没有内置函数,但结合FoldPartition 非常简单:

    In[47]:= x1 = RandomReal[{0, 1}, {3, 4, 5}];
    
    In[48]:= dims = Dimensions[x1]
    
    Out[48]= {3, 4, 5}
    
    In[49]:= x2 = Fold[Partition, Flatten[x1], Most[Reverse[dims]]];
    
    In[50]:= x1 == x2
    
    Out[50]= True
    

    【讨论】:

      【解决方案2】:

      您可能想要Partition[] 或其亲属之一。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-25
        • 1970-01-01
        • 2019-11-30
        • 1970-01-01
        • 1970-01-01
        • 2011-12-06
        相关资源
        最近更新 更多