Re: unpartition
- To: mathgroup at smc.vnet.net
- Subject: [mg45950] Re: [mg45899] unpartition
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 30 Jan 2004 04:16:51 -0500 (EST)
- References: <200401291034.FAA09698@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 29 Jan 2004, at 11:34, Steven Burger wrote: > How do you unpartition a matrix? > > For example: Starting with, > > Partition[Table[4*(i - 1) + j, {i, 4}, {j, 4}],{2,2}] > > > how do you go back to, > > Table[4*(i - 1) + j, {i, 4}, {j, 4}] > > > There is no "Unpartition" function (there are just too many possible way to unpartition a list) so you vae to compose something yourself. Here is one attempt (same example as yours!) ll=Partition[Range[16],4] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}} Map[Flatten,Flatten[Transpose[ll,{1,3,2}],1]] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}} Another way that comes to my mind is based on the function AppendRows form the LinearAlgebra`MatrixManipulation` package: << LinearAlgebra`MatrixManipulation` Flatten[Apply[AppendRows,ll,1],1] {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}} There are certainly a vast number of other ways and there may be among them a much simpler one. Andrzej Kozlowski Chiba, Japan http://www.mimuw.edu.pl/~akoz/
- References:
- unpartition
- From: steven.burger@duke.edu (Steven Burger)
- unpartition