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

Consider having vector

$$v = \begin{pmatrix} v_1\\ v_2\\ \vdots\\ v_n \end{pmatrix}$$

Consider the final result:

$$ V = \begin{pmatrix} v_1 & 0 & \dots & 0\\ 0 & v_2 & \dots & 0\\ \vdots & \vdots & \ddots & \vdots\\ 0 & 0 & \dots & v_n\\ \end{pmatrix} $$

How to get matrix $V$ operating on $v$ with matricial operations?


share|cite|improve this question
$\sum_i v^Te_i\cdot e_ie_i^T$ with the $i$-th standard basis vector denoted by $e_i$. – martini May 15 '12 at 6:56
What are 'matricial operations'? – copper.hat May 15 '12 at 7:00
I mean just products and sums... – Andry May 15 '12 at 7:02

You can see that the basis vectors must be involved in this conversion, because the result depends on the basis we use. For example, $v=(1,\dots,1)^T$ will produce the identity matrix, but not if we operate in a different basis. This is why there cannot be a natural coordinate-free transformation of $v$ into $V$.

In the formula given by martini, $V=\sum_{i=1}^n (v^T e_i)(e_ie_i^T)$, the product $e_ie_i^T$ is the matrix with $(i,i)$ entry $1$ and other entries $0$. Multiplication by the scalar $v^T e_i = v_i$ turns $1$ into $v_i$. Summation over $i$ completes the construction.

By the way, Matlab has built-in diag(v) for this purpose.

share|cite|improve this answer

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.