[Numpy-discussion] assigning to submatrix

Perry Greenfield perry at stsci.edu
Tue Jul 29 10:49:10 CDT 2003


> -----Original Message-----
> From: numpy-discussion-admin at lists.sourceforge.net
> [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of John
> Hunter
> Sent: Tuesday, July 29, 2003 12:30 PM
> To: Numerical Python Discussion
> Subject: [Numpy-discussion] assigning to submatrix
> 
> 
> 
> If I have a large matrix, say
> 
>   a = zeros( (20,20) )
> 
> and a small matrix
> 
>   b = ones( 3,4 )
> 
> and a list of row indices and a list of col indices
> 
>   rind = [2,4,9,15]
>   cind = [1,4,12]
> 
> what is the best way to assign the submatrix to a[rind,cind].  I
> understand this is possible in numarray, but is there a good way to do
> it in Numeric?
> 
> In matlab, you could do a(rind, cind)=b;  Is there some reshape, put
> magic I can do to make this efficient in Numeric?
> 
> Thanks,
> John Hunter
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072
> 303_01/01
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
> 




More information about the Numpy-discussion mailing list