       Re: Convert nxn matrix to a column vector with (n^2) elements

• To: mathgroup at smc.vnet.net
• Subject: [mg83731] Re: Convert nxn matrix to a column vector with (n^2) elements
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Thu, 29 Nov 2007 06:26:05 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <fiji4u\$ijb\$1@smc.vnet.net>

```Tara.Ann.Lorenz at gmail.com wrote:

> Any ideas how to convert an nxn matrix to a column vector with n^2
> elements?

Beware that Mathematica does not have any special construct to
distinguish row vectors from column vectors. A vector can be represented
by a one dimensional list made of numeric or/and symbolic elements.
Depending on the context and the operation in use, Mathematica
interprets the vector as a column or a row vector. (More generally,
vectors are tensors of rank 1.)

Having said that, I believe that what you are looking for is a command
of  the form Flatten@Transpose@m (m being your square matrix) as
illustrated in the following example:

Mathematica 6.0 for Microsoft Windows (32-bit)

In:= m = Array[a, {2, 2}]

Out= {{a[1, 1], a[1, 2]}, {a[2, 1], a[2, 2]}}

In:= %//MatrixForm

Out//MatrixForm= a[1, 1]   a[1, 2]

a[2, 1]   a[2, 2]

In:= Flatten@Transpose@m

Out= {a[1, 1], a[2, 1], a[1, 2], a[2, 2]}

In:= %//MatrixForm

Out//MatrixForm= a[1, 1]

a[2, 1]

a[1, 2]

a[2, 2]

In:= Flatten@m

Out= {a[1, 1], a[1, 2], a[2, 1], a[2, 2]}

In:= %//MatrixForm

Out//MatrixForm= a[1, 1]

a[1, 2]

a[2, 1]

a[2, 2]

Regards,
--
Jean-Marc

```

• Prev by Date: Re: Re: PlotLabel - SubscriptBox - Vers. 6: FontColor not
• Next by Date: Re: Controlling evaluation
• Previous by thread: Re: Convert nxn matrix to a column vector with (n^2) elements
• Next by thread: Epilog with 3 dimensional graphics primitives