MathGroup Archive 2004

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

Search the Archive

Re: matrix times a vector

  • To: mathgroup at
  • Subject: [mg49050] Re: matrix times a vector
  • From: Bill Rowe <readnewsciv at>
  • Date: Tue, 29 Jun 2004 04:50:37 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 6/28/04 at 4:13 AM, david.salomon at (David Salomon) wrote:

>The input {{a,b}, {c,d}}.{x,y} generates the output {a x+b y,c x+d

>How can I get the output x{a,b}+y{c,d}  ?

In[1]:=Plus @@ Flatten[MapThread[Times, {{{a, b},{c, d}},{x, y}}]]
Out[1]= a*x + b*x + c*y + d*y

Here I am interpreting your x{a,b}+y{c,d} to be a*x + b*x + c*y + d*y

>This is a special case of lists with two elements. How can I extend
>this computation in an elegant way to lists with N elements?

This will work for any length list. All that is required is the first dimension of your matrix to have the same value as the length of your vector for this particular method to work.
To reply via email subtract one hundred and four

  • Prev by Date: Re: Union - simple question
  • Next by Date: Re: Trigonometric simplification - newbe question
  • Previous by thread: Re: matrix times a vector
  • Next by thread: RE: matrix times a vector