Chris Lowis
Chris Lowis

Reputation: 560

Sparse Matrix Libraries for Ruby

I'm looking for a Sparse Matrix library I can use from Ruby. I'm currently using the GNU Scientific Library bindings provided by the "gsl" gem, but my application would be better optimized if I used a dedicated sparse matrix library. I've investigated the linalg and NArray libraries. None of the these three libraries support sparse-matrix optimised storage or operations.

Is there anything out there I've missed - or an existing C library that may be possible to write bindings for? I'd prefer the former to that latter, as I haven't written C bindings in Ruby before, but I would be willing to attempt it.

Upvotes: 15

Views: 2123

Answers (3)

Translunar
Translunar

Reputation: 3816

Have you seen SciRuby?

We don't have a sparse matrix implemented currently, but we're working on it. We're also in the process of rewriting NArray, with Masahiro Tanaka's blessing.

One goal is to have everything working in pure Ruby, in C (via GSL bindings, typically), and in Java for JRuby. (Pure Ruby would then be the fallback if GSL, etc., were unavailable.)

Side note: This is a terrible answer to this question. I post it here mainly so that anyone else who happens to be working on such things knows where to find us. =)

Upvotes: 2

HMCFletch
HMCFletch

Reputation: 1076

Like Bill mentioned above, the a pure ruby interpretation is going to be slower than you want, but might be good for prototyping. I have been working on just such a library over at https://github.com/hmcfletch/sparse-matrix

I haven't released it as a gem yet and there is more work to be done on it, but take a look at if you stil have a need.

Upvotes: 3

Bill Dueber
Bill Dueber

Reputation: 2706

Pure ruby solutions are going to be ridiculously slow. I'd be tempted to pick up something like MTJ (http://code.google.com/p/matrix-toolkits-java/) and use it under JRuby.

There's a bunch of java code out there; much of it is pretty mature, although I don't know the space well enough to recommend a particular library. I can tell you that I've used java from jruby often and it's a joy to work with.

Upvotes: 2

Related Questions