# Multiply a matrix by a vector [closed]

I have one 3x2 matrix of coordinates in the following form

       a={{{0, 0, 0}, {1, 0, 1}},
{{0, 1, 0}, {0, 0, 0}},
{{0, 2, 0}, {0, 0, 0}}}


I need to multiply it by another 2x1 matrix of the form

      b={{0},
{2}}


so that the result is a product with coordinates of the form

      a*b={{x,y,z},
{a,b,c},
{p,q,r}}


A mere multiplication a*b or a.b does not help because the dimension of the first matrix is taken as 3x2x3. How do I multiply these?

• Your a matrix has three 2x3 matrices. To multiply by the 2x1 vector b, you'll have to use Transpose. It looks like you'll also have to do that to place it in desired form. This is just one way to do this in Mathematica. – TransferOrbit Sep 20 '15 at 19:22
• Could we have a definition of what sort of matrix multiplication you are thinking about? Presumably you don't mean the ordinary multiplication were an n X r matrix is multiplied by a r X m matrix to produce a n X m matrix. – Hugh Sep 20 '15 at 20:36
• Transpose[a, {1, 3, 2}].b is one way to get an answer with the dimensions you request. – bill s Sep 20 '15 at 22:17
• @Sameeran, you should have a look at the Vectors and Matrices tutorial in the documentation. Your assertion that a is 3x2 when in fact it is 3x2x3 is the crux of the problem. Once you understand what its dimensions are then all else will fall into place. – Edmund Sep 21 '15 at 9:14