title: How can I use numpy to create a diagonal matrix from a 1d array?
body: <p>I am using Python with numpy to do linear algebra.</p>
  
  <p>I performed <code>numpy</code> SVD on a matrix to get the matrices U,i, and V. However the i matrix is expressed as a 1x4 matrix with 1 row. i.e.: <code>[ 12.22151125   4.92815942   2.06380839   0.29766152]</code>.</p>
  
  <p>How can I get numpy to express the i matrix as a diagonal matrix like so:
  <code>[[12.22151125, 0, 0, 0],[0,4.92815942, 0, 0],[0,0,2.06380839,0 ],[0,0,0,0.29766152]]</code></p>
  
  <p>Code I am using: </p>
  
  <pre><code>A = np.matrix([[3, 4, 3, 1],[1,3,2,6],[2,4,1,5],[3,3,5,2]])
  
  U, i, V = np.linalg.svd(A,full_matrices=True)
  </code></pre>
  
  <p>So I want i to be a full diagonal matrix. How an I do this?</p>