Re: Rearranging a tensor
- To: mathgroup at smc.vnet.net
- Subject: [mg22471] Re: [mg22433] Rearranging a tensor
- From: "Chuck Culpepper" <cculpepper at fibertek.com>
- Date: Sat, 4 Mar 2000 02:26:38 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Try the following: In[256]:= Partition[Flatten[Transpose[c, {1, 3, 2, 4}]], 6] Out[256]= {{1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {3, 3, 3, 4, 4, 4}, {3, 3, 3, 4, 4, 4}, {3, 3, 3, 4, 4, 4}} Chuck Culpepper Fibertek, Inc. ----- Original Message ----- From: DIAMOND Mark <noname at noname.com> To: mathgroup at smc.vnet.net Subject: [mg22471] [mg22433] Rearranging a tensor > I have > > In[1]:= a={{1,2},{3,4}}; > > In[2]:= b=Table[1,{3},{3}]; > > In[3]:= c=Outer[Times,a,b] > > Out[3]= {{{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, > > > {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}}, > > > {{{3, 3, 3}, {3, 3, 3}, {3, 3, 3}}, {{4, 4, 4}, {4, 4, 4}, {4, 4, 4}}}} > > In[4]:= c//MatrixForm > > Out[4]//MatrixForm= > 1 1 1 2 2 2 > 1 1 1 2 2 2 > 1 1 1 2 2 2 > > 3 3 3 4 4 4 > 3 3 3 4 4 4 > 3 3 3 4 4 4 > > I would now like to rearrange c so that it is of the form > {1,1,1,2,2,2},{1,1,1,2,2,2},{1,1,1,2,2,2},{3,3,3,4,4,4},{ 3,3,3,4,4,4},{3,3 > ,3,4,4,4}} > > There must be a *simple* way to do this but I cannot see it. Help would be > appreciated. > > Cheers, > > Mark R Diamond > Vision Research Laboratory > The University of Western Australia > no spam email: markd at psy dot uwa dot edu dot au > > > >