MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Multiplying a vector over multiple vectors


testmatrix = {{1, 2}, {3, 4}, {5, 6}};

{a, b} # & /@ testmatrix
{{a, 2 b}, {3 a, 4 b}, {5 a, 6 b}}

First@Outer[Times, {a, b}, testmatrix]
{{a, 2 a}, {3 a, 4 a}, {5 a, 6 a}}


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Donald DuBois" <donabc at comcast.net> wrote in message 
news:g7ed6u$2pm$1 at smc.vnet.net...
> 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).
>
> Thanks in advance for any help you can give me.
>
> Don
> 



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