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.
Minkoo S. (Guest)
on 2006-03-11 10: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 S.
Minkoo S. (Guest)
on 2006-03-11 14:31
(Received via mailing list)
I've found it by myself:

a = Matrix[(0..3).map { Array.new(5) }]
unknown (Guest)
on 2006-03-11 17:16
(Received via mailing list)
On Sat, 11 Mar 2006, Minkoo S. 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.