Matrix vector addition

14.9k Views Asked by At

Given A a 3x3 matrix and B a 3x1 matrix (or column vector), I am asked to calculate A + B. Both are initially filled with one's. To my knowledge the two matrices would have to be of the same n×m dimensionions. However, if I do the addition in Python (using Numpy matrices and the '+' operator) I get a 3x3 matrix filled with two's.

How is this matrix and column vector added? Might I be misunderstanding what Python does?

1

There are 1 best solutions below

1
On BEST ANSWER

Usually, the addition of matrix and vector is not defined. So if you were asked to calculate such thing, you have to make it clear what he/she means.

I think this is what you get (in this example, $M + v$). If you try another combination (like $M + u$ in the example), you'll see what happens. Let $M = (m_1, m_2, m_3)^T$. Then it returns $$ M + v := (m_1 + v, m_2 + v, m_3 + v)^T $$ somehow. So it's a problem of Numpy and I think Stack Overflow is more appropriate place to ask if you want to know why this happens.