I have been trying to generate a matrix that is size 4x5 and full of random numbers by doing the following (in ruby 1.8.7):
m_rand = Matrix #create an empty matrix
n = 0
for n in 0...5
m=0
for m in 0...4
m_rand[n,m] = rand()
end
end
But the above does not appear to work, in particular I am not sure how to create an empty matrix of arbitrary size and then populate afterwards in ruby 1.8.7
m_rand = Array.new(4){Array.new(5){rand} }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With