Changing values of 1st column of a matrix using take(mymatrix, (0, ),axis=1)

A

Anthony Liu

I am talking about the 'take' method of numarray.

See here for more info:

http://stsdas.stsci.edu/numarray/Doc/node33.html

If I initialize a matrix 'mymatrix' by zeros((3,3),
type="Float64"), I get a 3*3 matrix of all zeros.

Look:
array([[ 0., 0., 0.],
[ 0., 0., 0.],
[ 0., 0., 0.]])
I want to change the zeros of only the first column to
1's. In other words, I want to get:

array([[ 1., 0., 0.],
[ 1., 0., 0.],
[ 1., 0., 0.]])

The 'take' method is able to take out the first
column, but I am not sure if there is a good way of
changing all values of the first column to 1's.

Of course, I know that I can achieve my goal pretty
easily with this:

for i in range(3): mymatrix[i,0] = 1.0

I am just wondering if there is an existing numarray
method that elegantly does it for me.


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top