Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, I have vector A = mx1. I want to sum each elements of vector A by :

1) Define vector B = 1xm.

2) Take : AxB = 1x1. So, this vector will be the value of sum elements of vector A.

But, I don't know how to choose vector B to this trick.

So, my question is : does exist vector B to do my trick, or if not, does exist a way just to do matrix manipulation (sum, multiplication, transpose...), and can do this trick, too. (it means : you not count each elements by hand)

Thanks :)

share|cite|improve this question
If you take $B$ to be all ones, and instead compute $BA$, then you get the sum of elements in $A$. By the dimensions of $A$ and $B$ above the matrix $AB$ will have dimensions $m \times m$. (I have posted this as an answer). – utdiscant Aug 20 '12 at 11:16
up vote 3 down vote accepted

Let $A$ be a column-vector with $m$ elements, and let $B$ be a row-vector with $m$ elements, where each element of $B$ is 1. Then $$BA = \begin{pmatrix} b_1 & b_2 & \ldots & b_m\\ \end{pmatrix} \begin{pmatrix} a_1 \\ a_2 \\ \vdots \\ a_m \end{pmatrix} = \sum_{i=1}^{m} b_ia_i = \sum_{i=1}^{m} 1 \cdot a_i = \sum_{i=1}^{m} a_i$$ where $a_i$ is the $i$'th element of $A$.

The matrix $AB$ has dimension $m \times m$.

share|cite|improve this answer
In short, take the dot product of the given vector with the vector whose entries are all $1$'s. – J. M. Aug 20 '12 at 11:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.