# How to multiply a 3x3 matrix with a 1x3 matrix?

I have 2 matrices and have been trying to multiply them but to no avail. Then I found this online site and trying feeding it the values but yet no success.

- R' . T


is what i would like to do but R is a 3x3 (3 rows, 3 cols) matrix and T is a 1 x 3 matrix (1 row, 3 cols).

Any idea how to go ahead with this?

-

You can only multiply an $n\times m$ matrix by a $p\times q$ matrix, in that order, if $m=p$. That is, only if the number of columns of the first factor is equal to the number of rows of the second factor. So you cannot multiply a $3\times 3$ matrix by a $1\times 3$ matrix; on the other hand, you can multiply a $1\times 3$ matrix by a $3\times 3$ matrix (so you can do $TR$); or you can multiply the $3\times 3$ matrix by the transpose of $T$, which would be $3\times 1$.

You can try extending $T$ into a $3\times 3$ by adding two rows of zeros (that is what the site you linked to does), but then you are not really multiplying $R$ by $T$. All you are doing is multiplying the first column of $R$ by the first entry of $T$, the second column of $R$ by the second entry of $T$, and the third column of $R$ by the third entry of $T$.

So the real question is: where did the matrices come from and why are you trying to multiply them in that order? Perhaps it turns out you shouldn't be doing that product at all...

-
The original formula is Xc = R . Xw + T and now I am trying to solve for Xw with Xc = (0, 0, 0) –  Kevin Boyd Nov 23 '10 at 19:57
@Kevin Boyd: Sigh: What is $X$? What is $c$? What is $R$? What is $T$? Where do they come from? What do they represent? Is $w$ a vector? If so, it must be a column vector, not a row vector (or the transpose of a row vector). –  Arturo Magidin Nov 23 '10 at 19:59
This is the formula for camera calibration Xc co-ordinates(x, y, z) in the camera reference plane and Xw co-ordinates (x, y, z) in the world reference. R is the Rotation matrix and T is the translation matrix. –  Kevin Boyd Nov 23 '10 at 20:03
@Kevin Boyd: Then your $Xc$ and $Xw$ must be column vectors, not row vectors: that is, they are $3\times 1$ vectors, not $1\times 3$. Just identify the vector $(x,y,z)$ with the corresponding column vector $(x,y,z)^t$. They amount to the same thing, but now you can do the product. –  Arturo Magidin Nov 23 '10 at 20:16
@ Arturo Magidin: This might work out, do you mean to say that T is a 3x1 matrix. Also what is (x,y,z) raised to t –  Kevin Boyd Nov 24 '10 at 4:50

The usual matrix multiplication is only defined for multiplying an $m\times n$ matrix with an $n\times R$ matrix. So the number of columns of the first matrix must be equal to the number of rows of the second for matrix multiplication to be defined. This is not satisfied by the matrices you have. So you cannot multiply them in that order. You can, however, multiply $T$ with $R$ i.e. the product $TR$ is defined but not $RT$.

-
is there way to convert the 1x3 matrix to 3x3? –  Kevin Boyd Nov 23 '10 at 19:52
@Kevin Boyd: You can pre-multiply it by its transpose, or by any $3\times 1$ matrix. But really: the best solution is for you to say where these matrices come from and what you are trying to achieve. Perhaps you are just trying to do the wrong operation (or the right operation in the wrong order). –  Arturo Magidin Nov 23 '10 at 19:56

Suppose you have two matrices A and B. Let A be a 3x3 matrix and B be a 1x3 matrix.

As stated above, you can only multiply matrix C (mxn) by matrix D (pxq) if n=p. That is, the number of columns in C = the number of rows in D.

We see that for your problem, we have the following information, $m=n=q=3$ and $p=1$.

Thus we have that $n \neq p$.

If you insist on multiplying these two matrices together, you could always take the transpose of matrix B, denoted $B^{T}$. (For information about transposed matrices, see [1].)

$B^{T}$ would be a 3x1 matrix. So you could in fact do $AB^{T}$.

For more on matrix multiplication in general, see [2]. I hope this is helpful!

[1] Weisstein, Eric W. "Transpose." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Transpose.html

[2] Weisstein, Eric W. "Matrix Multiplication." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/MatrixMultiplication.html

-

From what I can see, perhaps you have the R and Xw matrix switched around. If you had Xw*R, then I think it would be okay. Did you derive this formula or did you find it somewhere?

-
I got the formula from several places. One of them is from en.wikipedia.org/wiki/Camera_resectioning –  Kevin Boyd Nov 24 '10 at 4:53