       Re: How to mutiply a 3x1 and 1x3 vector

• To: mathgroup at smc.vnet.net
• Subject: [mg3091] Re: How to mutiply a 3x1 and 1x3 vector
• From: leszek (Leszek Sczaniecki)
• Date: Wed, 31 Jan 1996 03:03:53 -0500
• Organization: Wolfram Research, Inc.
• Sender: owner-wri-mathgroup at wri.com

```In article <4ekes6\$6gj at dragonfly.wri.com> snichols at onramp.net (Stephen Nichols) writes:
>
> Hi,
>
> I have another question that I thought would be simple to to in Mathematica.
> I have two vectors A={1,2,3} and B={3,4,5}.  How do I multiple them together
> to get a 3x3 matrix.  A . B gives me a scalar result.  Mma seems to always
> treat the first one as a row vector and the second as a column vector.  I
> need it to do the opposite.  Treat the first as a column vector and the second
> as a row vector.  Any ideas?
>
> thanks,
>
>
>

It seem to me that the best way to distinguish between row and column vectors is to write
them explicitly in matrix form.
{{a}, {b}, {c}} is a column vector.
{{x, y, z}} is a row vector.
{{a}, {b}, {c}}.{{x, y, z}} is a 3x3 matrix:
{{x, y, z}}.{{a}, {b}, {c}} is 1x1 matrix (as oppose to a scalar).

In:= vector = {{a}, {b}, {c}}
Out= {{a}, {b}, {c}}

In:= MatrixForm[vector]
Out//MatrixForm= a

b

c

In:= covector = {{x, y, z}}
Out= {{x, y, z}}

In:= MatrixForm[covector]
Out//MatrixForm= x   y   z

In:= vector.covector
Out= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}}

In:= MatrixForm[%]
Out//MatrixForm= a x   a y   a z

b x   b y   b z

c x   c y   c z

In:= covector.vector
Out= {{a x + b y + c z}}

In:= MatrixForm[%]
Out//MatrixForm= a x + b y + c z

There is no problem to transfer lists into vectors or covectors. Here are obvious
micro-utilities.

ToVector[l_List]:= List /@ l
ToCovector[l_List]:= {l}

Greetings,

Leszek

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: [Q] Plot in a Plot
• Next by Date: Re: Two questions regarding command line interface
• Previous by thread: Re: How to mutiply a 3x1 and 1x3 vector
• Next by thread: Re: How to mutiply a 3x1 and 1x3 vector