benui
benui

Reputation: 6788

Ruby core Matrix vs NArray's NMatrix

There seems to be three matrix modules in Ruby that I've found

At the moment it seems NArray's NMatrix is faster than Matrix, has some more helpful methods, but require a bit more setup.

Is there anyone with experience of both who can give a rough overview of why I should use one over the other?

Upvotes: 2

Views: 918

Answers (2)

Translunar
Translunar

Reputation: 3816

A bit late to the ballgame, but have you seen the new NMatrix gem? It's inspired by NArray. It's also written in C/C++, whereas Ruby Matrix is written only in Ruby --- so NMatrix is definitely faster.

That's also true for NArray, which is C-only.

The advantage to using NMatrix instead of NArray::NMatrix is that you can choose between different storage types (sparse, dense, etc.).

Upvotes: 2

Jordan Arsenault
Jordan Arsenault

Reputation: 7388

Just stumbling on this question now... It's been 7 months since you've asked, so I'm sure you've found your answer by now.

However, please find information here.

Basically, the author of the core Matrix class did not add methods to perform run-time modifications to the array once it is instantiated. The NArray class allows for this.

As far as computation time, I'll leave that to somebody else, for I don't know.

Upvotes: 2

Related Questions