       Re: Multiplying a vector over multiple vectors

• To: mathgroup at smc.vnet.net
• Subject: [mg91183] Re: Multiplying a vector over multiple vectors
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Fri, 8 Aug 2008 07:17:10 -0400 (EDT)

```On 8/7/08 at 4:42 AM, donabc at comcast.net (Donald DuBois) wrote:

>How does one get a vector to distribute over a list of vectors
>under multiplication?

>For example:

>{{1,2}, {3,4}, {5,6}} times {a,b} should
>equal  (under this operation)

>{{a, 2b}, {3a, 4b}, {5a, 6b}}

>If {a,b} is duplicated three times one can use MapThread as in:

>MapThread[Times, {{{1, 2}, {3, 4}, {5, 6}}, {{a, b}, {a, b}, {a,
>b}}}]

>but duplicating {a,b} using Table is very slow when the vectors are
>large (consisting of thousands of elemets).

In:= {a, b} # & /@ {{1, 2}, {3, 4}, {5, 6}}

Out= {{a, 2 b}, {3 a, 4 b}, {5 a, 6 b}}

Something else that works in this case is

In:= List @@@ ({{1, 2}, {3, 4}, {5, 6}}.{a, b})

Out= {{a, 2 b}, {3 a, 4 b}, {5 a, 6 b}}

However, given Mathematica often reorders sums this approach
probably won't give valid results in general

```

• Prev by Date: Re: Multiplying a vector over multiple vectors
• Next by Date: Re: simple pattern match question
• Previous by thread: Re: Multiplying a vector over multiple vectors
• Next by thread: Re: Multiplying a vector over multiple vectors