From: Rob Biedenharn Date: 2007-10-20T13:55:46+09:00 Subject: Re: Create matrix with random numbers On Oct 19, 2007, at 9:38 PM, Jason Bornhoft wrote: >> Not sure what you want exactly, but, maybe... >> >> require 'matrix' >> a, b = 2, 3 >> m = Matrix[*(Array.new(a) {Array.new(b) {rand}})] >> >> Todd > > What I would ideally like is to be able to specify the size of the > matrix and then have a random function populate the matrix with real > integers or, eventually, complex numbers. > > Thanks for the guidance... So something like: require 'matrix' def some_random_function # make something up, perhaps something complex end rows, columns = 2, 3 matrix = Matrix[*(Array.new(rows) {Array.new(columns) { some_random_function }})] And, yes, that just about exactly what you were already given. ;-) -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com