On Sun, Nov 25, 2012 at 9:47 PM, Tom Bennett wrote:
> Thanks for the quick response.
>
> Ah, I see. There is a difference between A[:,:1] and A[:,0]. The former
> returns an Mx1 2D array whereas the latter returns an M element 1D array. I
> was using A[:,0] in the code but A[:,:1] in the example.
Thanks for the quick response.
Ah, I see. There is a difference between A[:,:1] and A[:,0]. The former
returns an Mx1 2D array whereas the latter returns an M element 1D array. I
was using A[:,0] in the code but A[:,:1] in the example.
On Sun, Nov 25, 2012 at 8:35 PM, Warren Weckesser <
warren.w
On Sun, Nov 25, 2012 at 8:24 PM, Tom Bennett wrote:
> Hi,
>
> I am trying to extract n columns from an 2D array and then operate on the
> extracted columns. Below is the code:
>
> A is an MxN 2D array.
>
> u = A[:,:n] #extract the first n columns from A
>
> B = np.dot(u, u.T) #take outer product.
Hi,
I am trying to extract n columns from an 2D array and then operate on the
extracted columns. Below is the code:
A is an MxN 2D array.
u = A[:,:n] #extract the first n columns from A
B = np.dot(u, u.T) #take outer product.
This code works when n>1. However, when n=1, u becomes an 1D array i