[SciPy-user] Ideas about matrices
Marco
gaedol at gmail.com
Tue Nov 7 08:54:27 EST 2006
Hi,
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
jik=scipy.zeros((10,10))
for i in range(len(jik)):
for k in range(len(jik)):
if random.random()<0.5:
jik[i,k]=1
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!
marco
PS
As always, RTFM much welcomed with pointers on what to read! :)
More information about the SciPy-User
mailing list