[SciPy-user] Combining Arrays

Alok Singhal as8ca@virginia....
Tue Feb 27 13:21:29 CST 2007


Hi Rich,

On 27/02/07: 11:09, Rich Shepard wrote:
>    I have two arrays: one is the upper triangular half with 1s in the
> diagonal, the other has the values for the lower triangular half. I also
> have an array that specifies how the values in the lower half array are to
> be assigned to rows and columns of the 2D array. However, as this is my
> first use of NumPy, I am stuck at how to put these together to form what I
> need.

[snip]

>    What I need is the array:
> 
> [[ 1.00		2.29	2.12	3.06 	...	]
>   [ 0.44		1.00	2.82	3.23	...	]
>   [ 0.47		0.22	1.00	2.26	...	]
>  		...
>  						]]
> 
>    How do I do this, please?

This works for me:

new = zeros(topArr.shape, dtype=float)
new[udx] = botArr
new = new + topArr

-Alok

-- 
Alok Singhal                               *   *          
Graduate Student, dept. of Astronomy   *           *     *
University of Virginia                                    
http://www.astro.virginia.edu/~as8ca/              *    * 


More information about the SciPy-user mailing list