[SciPy-user] Ideas about matrices
Giovanni.Samaey at cs.kuleuven.be
Tue Nov 7 08:03:18 CST 2006
from scipy import *
size = (8,3)
A = random.random(size)
B = where(A>0.5,0.,1.)
B is your matrix
> i finally decided to keep the "import scipy" option and rewrite what needed. :)
> Just, i have a question.
> I am not really good at python programming (nor programming in
> general, to say), and every time i want to modify a matrix (an array)
> i have to run thru all indices.
> In the example, i want a matrix with random ones or zeros:
> import scipy
> import random
> for i in range(len(jik)):
> for k in range(len(jik)):
> if random.random()<0.5:
> print jik
> Is there a more fast and synthetic way to write the same code?
> What if my matrix is not square?
> Sorry for my incompetence, TIA!
> As always, RTFM much welcomed with pointers on what to read! :)
> SciPy-user mailing list
> SciPy-user at scipy.org
More information about the SciPy-user