我正在寻找一个可以从 Ruby 使用的稀疏矩阵库。我目前正在使用“gsl”gem 提供的 GNU 科学库绑定,但我的应用程序将如果我使用专用的稀疏矩阵库,可以得到更好的优化。我调查了 linalg 和 NArray 库。这三个库都不支持稀疏矩阵优化存储或操作。
有没有我错过的东西——或者可以为其编写绑定的现有 C 库?我更喜欢前者而不是后者,因为我以前没有在 Ruby 中编写过 C 绑定,但我愿意尝试。
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.
发布评论
评论(3)
就像上面提到的 Bill 一样,纯 Ruby 解释会比您想要的慢,但可能有利于原型设计。我一直在 https://github.com/hmcfletch/sparse-matrix< 上开发这样一个库< /a>
我还没有将它作为 gem 发布,并且还有更多工作要做,但是看看您是否仍然有需要。
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.
纯红宝石解决方案将会慢得离谱。我很想选择像 MTJ (http://code.google.com/p/matrix-toolkits-java/) 这样的东西并在 JRuby 下使用它。
那里有一堆java代码;尽管我不太了解这个领域,无法推荐特定的图书馆,但其中大部分都相当成熟。我可以告诉你,我经常使用 jruby 中的 java,并且使用起来很愉快。
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.
你见过SciRuby吗?
目前我们还没有实现稀疏矩阵,但我们正在努力。在 Masahiro Tanaka 的支持下,我们也正在重写 NArray。
目标之一是让一切都可以在纯 Ruby、C 语言(通常通过 GSL 绑定)以及 JRuby 的 Java 语言中运行。 (如果 GSL 等不可用,纯 Ruby 将成为后备方案。)
旁注:对于这个问题,这是一个糟糕的答案。我将其发布在这里主要是为了让其他从事此类工作的人知道在哪里可以找到我们。 =)
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. =)