472,135 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,135 software developers and data experts.

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:


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

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
Feb 21 '06 #1
0 1030

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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.