有效地更新特定特定稀疏基质的某些块的内置块?
假设我的稀疏矩阵具有以下模式:

- 每列的非齐射率及其位置仅固定,
- 仅矩阵块A和b会改变,其余矩阵保持静态; (A块A和B本身在固定的非零位置也很稀疏)
- 的每个列的确切数量
- 保留“列列稀疏矩阵插入列”列
- 最小行索引的列插入列
插入程序后面的 矩阵,仅更新A,B块Inploph。可能的方法是:
- 通过
coeffref
访问现有条目,将引入二进制搜索,因此在这里不受欢迎。 - 如有记录的在这里
似乎有点,它似乎有点 不需要在所有非零条目上进行迭代,因为稀疏矩阵的大部分时间都保持不变。
是否可以在矩阵中的所有非Zeros上进行迭代?
Suppose that I have a large sparse matrix with the following pattern:
- the number of nonzeros per column and their locations are fixed
- only matrix block A and B will change and the rest of the matrix stays static; (blocks A and B themselves are also sparse with fixed nonzero locations)
As instructed in the document, i've initialized the above matrix by
- reserving the exact number of nonzeros per column for the column major sparse matrix
- inserting column by column
- inserting from the smallest row index per column
In later part of the program, it's natural to reuse the matrix and only updates the A, B blocks inplace. Possible ways are:
- accessing existing entries by
coeffRef
, would introduce binary search so not preferred here. - iterating over the outer and inner dimensions as documented here
However, it seems a bit unnecessary to iterate over all nonzero entries since most part of the sparse matrix stays the same.
Is it possible to update A, B inplace without iterating over all nonzeros in the matrix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,
Inneriterator
可以用于此过程并在恒定时间内运行。这应该访问值C。您需要知道的只是每个列的非零元素有多少个(或一般内在维度)。您不需要知道存储多少个非零列(外部维度),因为该数组(
sparsematrix.outerindexptr()
)每列有一个条目。From what I can tell, the
InnerIterator
can be used used for this and runs in constant time.This should access the value C. All you need to know is how many nonzero elements are per column (or inner dimension in general). You don't need to know how many nonzero columns (outer dimensions) are stored because that array (
SparseMatrix.outerIndexPtr()
) has one entry per column.