Mathematica 中 Flatten 的倒数? [英] Inverse of Flatten in Mathematica?

查看:26
本文介绍了Mathematica 中 Flatten 的倒数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

f[x_]:=Flatten[x] 的倒数是什么,其中 x 是维度变暗的数组?

What's the inverse of f[x_]:=Flatten[x] where x is Array with dimensions dims?

推荐答案

没有内置函数,但结合 FoldPartition:

There is no built-in function, but it's pretty easy with a combination of Fold and Partition:

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

这篇关于Mathematica 中 Flatten 的倒数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆