469,275 Members | 1,871 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

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

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
0 954

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by jkohans | last post: by
3 posts views Thread by Jacky Zhu | last post: by
3 posts views Thread by Moshe Kravchik | last post: by
reply views Thread by cjharrelson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.