Forum: Ruby Matrix in Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47b36de21d7ecbc824c81d24802a6290?d=identicon&s=25 Minkoo Seo (pool007)
on 2006-03-11 09:56
(Received via mailing list)
What is the best way to create a matrix whose size is m x n?
The value of m and n may be different, and the values in each cell
should be zeroed.

Can anybody help me?

Sincerely,
Minkoo Seo
47b36de21d7ecbc824c81d24802a6290?d=identicon&s=25 Minkoo Seo (pool007)
on 2006-03-11 13:31
(Received via mailing list)
I've found it by myself:

a = Matrix[(0..3).map { Array.new(5) }]
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-03-11 16:16
(Received via mailing list)
On Sat, 11 Mar 2006, Minkoo Seo wrote:

> I've found it by myself:
>
> a = Matrix[(0..3).map { Array.new(5) }]


if you're going to be working with large matrices and doing lots of
number
crunching you'll want

   require 'narray'

   a = NArray.int 3, 5

it's on the raa.

cheers.

-a
This topic is locked and can not be replied to.