Re: making a column into a list
- To: mathgroup at smc.vnet.net
- Subject: [mg22990] Re: [mg22964] making a column into a list
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sun, 9 Apr 2000 01:45:53 -0400 (EDT)
- References: <8cnv2d$5bb@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mark: You report > To get a column from a matrix in list form: > IN> > matrix = {{1, 2}, {1, 2}, {1, 2}} > column = Column[matrix, 1] > OUT> > {{1, 2}, {1, 2}, {1, 2}} > {1, 1, 1} This doesn't work for me with Mathematica 4.0. matrix = {{1, 2}, {1, 2}, {1, 2}} column = Column[matrix, 1] {{1, 2}, {1, 2}, {1, 2}} Column[{{1, 2}, {1, 2}, {1, 2}}, 1] Did you mean TakeColumns from the package? << LinearAlgebra`MatrixManipulation` TakeColumns[matrix, {1}] {{1}, {1}, {1}} ------------------------------------- But in Mathematica 4.0 we can use matrix[[All, {1}]] {{1}, {1}, {1}} And this is much faster: matrix = Table[Random[], {50000}, {10}]; TakeColumns[matrix, {1}]; // Timing {1.37 Second, Null} matrix[[All, {1}]]; // Timing {0.11 Second, Null} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565