Reshape arbitrary length vector into square matrix with padding in numpy
<p>I have an arbitrary length vector, and I want to reshape it into a square matrix, something like:</p>

<pre><code>np.arange(6).reshape((3, 3))

[1,2,x]   [1,2,3]    
[3,4,x]   [4,5,6]
[5,6,x]   [x,x,x] 
</code></pre>

<p>The <code>x</code> can be horizontally and/or vertically placed.</p>

<p>Obviously <code>reshape</code> function will only allow parameter like (3,2) in the above example. Is there a way to produce effect of squared shaped matrix.Thanks.</p>