Ruby 核心 Matrix 与 NArray 的 NMatrix

发布于 2024-09-20 00:03:12 字数 652 浏览 5 评论 0原文

我发现 Ruby 中似乎有三个矩阵模块

目前看来 NArrayNMatrixMatrix< /code>,有一些更有用的方法,但需要更多设置。

有没有对这两种方法都有经验的人可以粗略地概述一下为什么我应该使用其中一种而不是另一种?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

饭团 2024-09-27 00:03:12

现在只是偶然发现这个问题......自您提出问题以来已经过去了 7 个月,所以我确信您现在已经找到了答案。

不过,请在此处查找信息。

基本上,核心 Matrix 类的作者没有添加在实例化数组后对数组执行运行时修改的方法。 NArray 类允许这样做。

至于计算时间,我将把它留给其他人,因为我不知道。

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.

心房敞 2024-09-27 00:03:12

虽然有点晚了,但你见过新的 NMatrix gem 吗?它的灵感来自 NArray。它也是用 C/C++ 编写的,而 Ruby Matrix 仅用 Ruby 编写——所以 NMatrix 肯定更快。

对于仅 C 语言的 NArray 也是如此。

使用 NMatrix 代替 NArray::NMatrix 的优点是您可以在不同的存储类型(稀疏、密集等)之间进行选择。

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.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文