# Linear Algebra - Multiplying a matrix and vector.

1. Aug 13, 2010

### jinksys

I am reading OpenGL SuperBible 5th Edition and noticed something off.

I just took linear algebra and was always told to make sure that the rows and columns match when multiplying two matrices. The vector should be on the right side of the matrix, correct?

2. Aug 13, 2010

### mathman

Since the matrix is diagonal, it doesn't matter.

3. Aug 13, 2010

### jinksys

How so?

4. Aug 13, 2010

### mxbob468

you are correct. that's a mistake - it should be on the right.

5. Aug 14, 2010

### Petr Mugver

Maybe that book defines matrix multiplication in a different way. But your example doesn't show this that much. Do you have a less simple example?

6. Aug 14, 2010

### slider142

You are correct. The diagram is incorrectly denoting the result of the square matrix premultiplying the column vector.
A matrix can be premultiplied by a row vector to yield another matrix, but there is no formal method of premultiplying a matrix directly by a column vector.

7. Aug 15, 2010

### HallsofIvy

I believe mathman was referring to
$$\begin{bmatrix}a & b & c & d \end{bmatrix}\begin{bmatrix}t & 0 & 0 & 0 \\ 0 & u & 0 & 0 \\ 0 & 0 & v & 0 \\ 0 & 0 & 0 & w\end{bmatrix}$$
and
$$\begin{bmatrix}t & 0 & 0 & 0 \\ 0 & u & 0 & 0 \\ 0 & 0 & v & 0 \\ 0 & 0 & 0 & w\end{bmatrix}\begin{bmatrix}a \\ b\\ c \\ d\end{bmatrix}$$

Of course, that is not what is shown in the first post.

8. Aug 15, 2010

### arildno

Hi, jinksys!

Nice of you to spot that error.

You should learn first the row*column-multiplication-type, although it is perfectly possible to define more general multiplication rules.
(And, this is done, for example by the highly general index-multiplication method)