最佳 C++稀疏酉矩阵的矩阵库

发布于 2024-08-20 20:18:50 字数 273 浏览 3 评论 0 原文

我正在寻找一个好的(在最好的情况下积极维护的)C++ 矩阵库。因此它应该被模板化,因为我想使用有理数复数作为数字类型。我处理的矩阵主要是稀疏矩阵和酉矩阵。

您能否建议图书馆并简要解释一下为什么要使用它们,因为我知道如何找到它们,但我无法真正决定什么适合我,因为我错过了使用它们的经验。

编辑:

我处理的主要操作是矩阵乘法与向量的标量乘法克罗内克积。矩阵的大小是指数级的,我希望至少能够处理高达 1024x1024 条目的矩阵。

I am looking for a good (in the best case actively maintained) C++ matrix library. Thereby it should be templated, because I want to use a complex of rationals as numerical type. The matrices what I am dealing with are mainly sparse and unitary.

Can you please suggest libraries and also give a small explaination why to use them, because I know how to find them, but I cannot really decide what is suitable for me because I am missing the experience with them.

EDIT:

The main operations I am dealing with are matrix multiplication, scalar multiplication with a vector and kronecker product. The size of the matrices is exponential and I wanna at least be able to deal with matrices up to 1024x1024 entries.

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

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

发布评论

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

评论(3

那片花海 2024-08-27 20:18:50

许多人做“严肃的”矩阵工作,依赖 BLAS,添加 LAPACK / ATLAS (正规矩阵)或 UMFPACK (稀疏矩阵)更高级的数学。原因是该代码经过充分测试、稳定、可靠且速度相当快。此外,您可以直接从供应商处购买它们(例如Intel MKL)调整您的架构,但也可以免费获得它们。 uBLASManuel的答案可能是标准的C++ BLAS实现。如果您稍后需要 LAPACK 之类的东西,可以使用 绑定 来实现。

然而,这些标准库(BLAS / LAPACK / ATLAS 或 uBLAS + 绑定 + LAPACK / ATLAS)都无法满足您的模板化和易于使用的要求(除非 uBLAS 是您所需要的)。实际上,我必须承认,当我使用 BLAS / LAPACK 实现时,我倾向于直接调用 C / Fortran 接口,因为我通常在 uBLAS + 绑定组合中看不到太多额外的优势。

如果我需要一个简单易用的通用 C++ 矩阵库,我倾向于使用 Eigen(我过去曾经使用NewMat)。优点:

  • 在英特尔架构上速度相当快,可能是较小矩阵最快的
  • 界面漂亮的界面
  • 矩阵库中的所有内容
  • 几乎可以轻松添加 新类型

缺点(IMO):

  • 单处理器 [编辑:Eigen 3.0]
  • 对于较大的矩阵和一些高级数学,比 ATLAS 或 Intel MKL(例如 LU 分解)慢 [编辑:在 Eigen 3.0 中也得到了改进]
  • 仅对稀疏矩阵的实验性支持[编辑:在即将发布的版本 3.1 中得到了改进]。

编辑:即将推出的 Eigen 3.1 允许某些函数使用 Intel MKL(或任何其他 BLAS / LAPACK 实现)。

Many people doing "serious" matrix stuff, rely on BLAS, adding LAPACK / ATLAS (normal matrices) or UMFPACK (sparse matrices) for more advanced math. The reason is that this code is well-tested, stable, reliable, and quite fast. Furthermore, you can buy them directly from a vendor (e.g. Intel MKL) tuned towards your architecture, but also get them for free. uBLAS mentioned in Manuel's answer is probably the standard C++ BLAS implementation. And if you need something like LAPACK later on, there are bindings to do so.

However, none of these standard libraries (BLAS / LAPACK / ATLAS or uBLAS + bindings + LAPACK / ATLAS) ticks your box for being templated and easy to use (unless uBLAS is all you'll ever need). Actually, I must admit, that I tend to call the C / Fortran interface directly when I use a BLAS / LAPACK implementation, since I often don't see much additional advantage in the uBLAS + bindings combination.

If I a need a simple-to-use, general-purpose C++ matrix library, I tend to use Eigen (I used to use NewMat in the past). Advantages:

  • quite fast on Intel architecture, probably the fastest for smaller matrices
  • nice interface
  • almost everything you expect from a matrix library
  • you can easily add new types

Disadvantages (IMO):

  • single-processor [Edit: partly fixed in Eigen 3.0]
  • slower for larger matrices and some advanced math than ATLAS or Intel MKL (e.g. LU decomposition) [Edit: also improved in Eigen 3.0]
  • only experimental support for sparse matrices [Edit: improved in upcoming version 3.1].

Edit: The upcoming Eigen 3.1 allows some functions to use the Intel MKL (or any other BLAS / LAPACK implementation).

夜夜流光相皎洁 2024-08-27 20:18:50

Boost uBLAS,因为它通过了升压滤波器。

有一些支持稀疏矩阵的模板库,因此如果您不更具体地了解您的需求,那么真的很难提出更好的理由。

Boost uBLAS, because it's passed the Boost filter.

There are a few template libs that support sparse matrices, so it's really hard to come up with a better rationale if you're not more specific about your needs.

若有似无的小暗淡 2024-08-27 20:18:50

您还应该尝试 MLTHASEM 矩阵 C++ 库。最后一个有很好的记录。

You should also try MLT and HASEM Matrix C++ Library. The last one is very well documented.

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