0

我正在寻找一个 C/C++ 接口,用于在 Linux 中高效计算巨大的稀疏矩阵。矩阵可能是数百万乘以百万/千。我检查了一些现有的库,但似乎没有一个能满足我的所有要求,

1、我需要通过动态添加元素来创建一个稀疏矩阵。(不适用于 SparseLib++)

2,我还需要能够创建一个稀疏对角矩阵,以便我可以用不同的标量缩放另一个稀疏矩阵的列。(没有找到一个库,也许还有另一种方法来按列缩放稀疏矩阵)

3、需要支持矩阵乘以矩阵/向量的运算(很多库都支持这些基本运算)

4,它需要支持两个稀疏矩阵或向量之间的逐项乘法或除法,如MATLAB中的.*或./(没有找到这个库,我需要这个操作来筛选出一个稀疏的一些条目矩阵与另一个稀疏矩阵)

5、矩阵求逆或线性求解器。(大多数库都提供线性系统的求解器)

我最初在 Python 中使用 scipy 来实现我的算法。Python消耗太多内存而且速度很慢,这就是为什么我想将我的程序转换为C。

谢谢。

4

5 回答 5

3

我会推荐 Tim Davis 的 CSparse。

更新(2019 年): Tim Davis 已经发布了SuiteSparse。这满足了帖子中列出的所有要求,包括增量构建矩阵的能力(参见RedisGraph 演示文稿中的幻灯片 34或SuiteSparse:GraphBLAS 论文中的“3.1.8 非阻塞模式” )。

于 2010-12-10T22:21:20.657 回答
1

Have you had a look at LinBox? It supports several sparse matrix storage formats, some of which allow you to set entries after the matrix has been created:

// set m[i,j] to a
m.refEntry(i, j) = a;

I'm not sure whether your requirement 4. is satisfied out-of-the-box, but it can certainly be coded easily using the refEntry method.

于 2010-12-13T21:42:52.833 回答
1

Alas, most sparse matrix libraries use a format which makes very difficult to set elements dynamically (google for Compressed Sparse Row, which is the most common format).

As you said, most libraries provide you with all you requirements, except #1. For #2, it is usually easy once you understand the storage format.

Intel MKL provides the PARDISO solver which doesn't impose a format, it only requires you to be able to do matrix/vector products: you call the solver in a loop, get a return code from it, and perform what it asks you to do (multiplication by A, checking termination condition, preconditioning, ...). This way, you can use whatever storage scheme you need. It is useful when you don't want to store the matrix for instance, or if you have a funky storage format.

Your requirements (especially #1) makes an excellent candidate for quadtree based sparse matrices. However, I do not know any good implementation of this. If you manage to code it / find an implementation of it, I'd be grateful.

于 2010-12-12T13:15:33.637 回答
1

我很高兴使用英特尔的MKL

于 2010-12-12T11:01:36.113 回答
0

试试TAUCSMUMPS

我已经亲自尝试使用 TAUCS 解决图像处理中百万 x 百万级别的稀疏矩阵的项目,以便您了解它可以处理的大小。

我同意 Alexandre 的观点,即这些包带有自己的“格式”,用于对稀疏矩阵进行编码,但这是不可避免的,因为您必须告诉求解器非零元素在哪里。但从好的方面来说,它们并不难学。顺便说一下,TAUCS 使用压缩列存储 (CCS) 格式。Alexandre 所指的可能是压缩行存储(CRS)。我认为还有一种更流行的格式,它使用矩阵中元素的(i,j)“位置”显式编码元素值,但仅此而已。

有关这些软件包的详细信息,请参阅www.matrixprogramming.com

于 2011-12-28T04:29:49.793 回答