[Date Index]
[Thread Index]
[Author Index]
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[1]:= vector = {{a}, {b}, {c}}
Out[1]= {{a}, {b}, {c}}
In[2]:= MatrixForm[vector]
Out[2]//MatrixForm= a
b
c
In[3]:= covector = {{x, y, z}}
Out[3]= {{x, y, z}}
In[4]:= MatrixForm[covector]
Out[4]//MatrixForm= x y z
In[5]:= vector.covector
Out[5]= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}}
In[6]:= MatrixForm[%]
Out[6]//MatrixForm= a x a y a z
b x b y b z
c x c y c z
In[7]:= covector.vector
Out[7]= {{a x + b y + c z}}
In[8]:= MatrixForm[%]
Out[8]//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**
| |