[Numpy-discussion] convert any non square matrix in to square matrix using numpy
Tony Yu
tsyu80 at gmail.com
Mon Jun 18 13:04:44 EDT 2012
On Mon, Jun 18, 2012 at 11:55 AM, bob tnur <bobtnur78 at gmail.com> wrote:
> Hi,
> how I can convert (by adding zero) of any non-square numpy matrix in to
> square matrix using numpy? then how to find the minimum number in each row
> except the zeros added(for making square matrix)? ;)
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
Hi Bob,
I'm not quite sure what you're looking for (esp. the second question), but
maybe something like the following?
#~~~ example code
import numpy as np
nonsquare = np.random.random(size=(3, 5))
M, N = nonsquare.shape
width = max(M, N)
square = np.zeros((width, width))
square[:M, :N] = nonsquare
min_rows = np.min(nonsquare, axis=1)
#~~~
-Tony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120618/56a15a5f/attachment.html>
More information about the NumPy-Discussion
mailing list