Re: RE: column * row ??
- To: mathgroup at smc.vnet.net
- Subject: [mg28845] Re: [mg28812] RE: [mg28791] column * row ??
- From: Raul Martinez <rmartinez at vrinc.com>
- Date: Tue, 15 May 2001 00:59:19 -0400 (EDT)
- Organization: Vista Research Inc
- References: <200105140533.BAA29490@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John, David,
Here's another Mathematica way to do it.
colvec = {a1, a2, a3};
rowvec = {b1, b2, b3};
Outer[Times, colvec, rowvec].
Raul Martinez
David Park wrote:
> John,
>
> colvec = {a1, a2, a3};
> rowvec = {b1, b2, b3};
>
> Transpose[{colvec}].{rowvec}
> {{a1 b1, a1 b2, a1 b3}, {a2 b1, a2 b2, a2 b3}, {a3 b1, a3 b2, a3 b3}}
>
> But probably the more Mathematica way of doing it would be...
>
> Outer[#1 #2 &, colvec, rowvec]
> {{a1 b1, a1 b2, a1 b3}, {a2 b1, a2 b2, a2 b3}, {a3 b1, a3 b2, a3 b3}}
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> > From: J.R. Chaffer [mailto:jrchaff at mcn.net]
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> >
> > Hi there,
> >
> > Can someone tell me a way to mimic the building of
> > an N x N matrix by multiplying a column vector
> > on left times a row vector on right ? (both vectors
> > of length N) - I mean in Mathematica, of course.
> >
> > i.e, want the result,
> >
> > (colvec){a1,a2, .. aN} * (rowvec){b1,b2,..bN} =
> >
> > result is matrix:
> >
> > {{a1*b1 a1*b2 ..... a1*bN},
> > {a2*b1 a2*b2 ..... a2*bN},
> > ... ... ... ,
> > {aN*b1 aN*b2 ..... aN*bN}}
> >
> >
> > When I try this in Mathematica all I can figure out
> > how to produce is the standard dot-product. If I
> > try the 'transposed' lists/matrices, I get an error,
> > even tho the product is defined by basic rules of
> > matrix multiplication.
> >
> > Thanks,
> >
> > John Chaffer
> >
- References:
- RE: column * row ??
- From: "David Park" <djmp@earthlink.net>
- RE: column * row ??