By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

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

P: n/a
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:
from numarray import *
mymatrix = zeros((3,3), type="Float64")
mymatrix 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
Feb 21 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.