简体   繁体   English

本征“稀疏矩阵格式”示例是否包含错误?

[英]Does Eigen “Sparse matrix format” example contains error?

Eigen 3.3.7 documentation for SparceMatrix http://eigen.tuxfamily.org/dox/group__TutorialSparse.html seems to contain an error in Sparse matrix format section: SparceMatrix的Eigen 3.3.7文档http://eigen.tuxfamily.org/dox/group__TutorialSparse.html似乎在“ 稀疏矩阵格式”部分中包含错误:

This storage scheme is better explained on an example. The following matrix

0   3   0   0   0
22  0   0   0   17
7   5   0   1   0
0   0   0   0   0
0   0   14  0   8

and one of its possible sparse, column major representation:

Values:         22  7   _   3   5   14  _   _   1   _   17  8
InnerIndices:   1   2   _   0   2   4   _   _   2   _   1   4
OuterStarts:    0   3   5   8   10  12
InnerNNZs:      2   2   1   1   2   

If 14 is moved from the third column to the second (ie its indices changed from [4,2] to [4,1]), then the first two arrays, Values and InnerIndices , make sense. 如果将14从第三列移到第二列(即其索引从[4,2]更改为[4,1]),则前两个数组ValuesInnerIndices意义。 OuterStarts doesn't seem to be correct for either 14 position, while InnerNNZs makes sense for 14 being in [4,2] element of the matrix, but is inconsistent with Values array. OuterStarts似乎并不对任一正确14的位置,而InnerNNZs有意义14在矩阵的[4,2]元件上时,但是不一致Values数组。

Is this example incorrect or am I missing something? 这个例子不正确还是我错过了什么?

In general, what is the best way of figuring out Eigen , besides examining the source code? 通常,除了检查源代码之外,找出Eigen的最佳方法是什么? I normally look at tests and examples, but building most benchmark and tests for sparse matrices results in compilation errors (were these tests written for older version of Eigen and not updated for version 3?)... 我通常查看测试和示例,但是为稀疏矩阵构建大多数基准和测试会导致编译错误(这些测试是针对较早版本的Eigen编写的,而不是针对版本3进行的更新吗?)...

The key is that the user is supposed to reserve at least as many entries per column as they need. 关键是用户应该在每列中保留至少所需数量的条目。 In this example the user only reserved 2 entries for the second column, so if you were to try to add another entry to that column, it would probably require an expensive reallocation, or at least a complicated shift to "steal" an unused entry from another column. 在此示例中,用户仅为第二列保留2个条目,因此,如果您尝试向该列添加另一个条目,则可能需要昂贵的重新分配,或者至少需要进行复杂的转换才能“窃取”未使用的条目。另一列。 (I have no idea how this is implemented.) (我不知道这是如何实现的。)

Upon a cursory look at the documentation you linked to, I didn't see anything about moving entries like you're trying to do. 粗略浏览您链接到的文档后,我没有看到关于移动条目的任何信息。 I'm not sure that Eigen supports such an operation. 我不确定Eigen是否支持这种操作。 (Correct me if I'm wrong.) I'm also not sure why you would want to do that. (如果我错了,请纠正我。)我也不确定为什么要这么做。

Your final question is probably too broad. 您的最后一个问题可能太广泛了。 I'm not an expert at Eigen, but it seems like a mature, powerful, and well-documented library. 我不是Eigen的专家,但它似乎是一个成熟,强大且有据可查的库。 If you have any specific problems compiling examples, you should post them here or on an Eigen specific forum. 如果在编译示例时遇到任何特定问题,则应在此处或在Eigen特定论坛上发布它们。 Many people at scicomp.SE are well-versed in Eigen and are accommodating. scicomp.SE的许多人都精通Eigen并能适应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM