Java中的并发访问稀疏矩阵

发布于 2024-11-11 03:14:09 字数 201 浏览 4 评论 0原文

我正在寻找 Java 中的矩阵/线性代数库,它提供可以从不同线程同时写入的稀疏矩阵。我遇到的大多数库要么根本不提供稀疏矩阵,要么 1.) 使用开放寻址哈希映射支持它们,或者 2.) 然后以 CSR 或 CSC 格式存储,这根本不适合多线程建造。现在,我正在使用并发哈希映射并行收集条目,并从单个线程填充稀疏矩阵,但这似乎浪费资源(存储并发哈希映射的空间,以及基本上填充的时间)矩阵两次)。

I'm looking for a matrix / linear algebra library in Java that provides a sparse matrix that can be written to concurrently from different threads. Most of the libraries I've come across either do not provide sparse matrices at all, or 1.) back them with an open addressed hash map, or 2.) store then in CSR or CSC format which is not at all amenable to multithreaded construction. Right now I'm gather the entries in parallel using a concurrent hash map and them populating the sparse matrix from a single thread, but this seems like a waste of resources (space to store the concurrent hash map, and time to essentially fill in the matrix twice).

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

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

发布评论

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

评论(2

后来的我们 2024-11-18 03:14:09

您不能神奇地使稀疏矩阵代数例程可扩展并行。解决这些问题涉及一些最复杂的数值分析算法,并且仍然是深入研究的主题。

你没有说你想用这些矩阵做什么,但我想你想要线性方程组的解。如果你想要并行,那么你需要一个第三方库、非常大的矩阵,可能还需要一些钱。

组装稀疏矩阵的最常见方法是以三元组格式组装它们并转换为压缩的行或列格式。组装可能很昂贵,但很容易并行完成。只需让每个线程都有自己的三元组列表,并在转换为压缩格式之前将它们拼接在一起即可。

You can't just magically make sparse matrix algebra routines scalably parallel. Tackling these issues involves some of the most complex numerical analysis algorithms around and is still the subject of intense research.

You don't say what you want to do with these matrices but I imagine that you want solution to systems of linear equations. If you want that in parallel then you'll need a 3rd party library, very large matrices, and likely some money.

The most common way to assemble sparse matrices is to assemble them in triplet format and convert to compressed row or column format. The assembly can be expensive but it is easy to do in parallel. Just let each thread have its own list of triplets and splice them together before converting to compressed format.

后来的我们 2024-11-18 03:14:09

我记得 parallel colt 中的矩阵是线程安全的。该库是 colt 的多线程版本。

I remember the matrices in parallel colt being thread safe. The library is a multithreaded version of colt.

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