Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coeffRef(it.row(), it.col()) -> it.valueRef()
Minor performance optimization. In a few of the edited places, the code is iterating over the elements of a sparse matrix using an iterator. However, when it came time to update the sparsematrix at the given position, rather then directly assign the value, the code called `coeffRef` to assign it. This is inefficient because `coeffRef` involves an expensive binary search to find position `i,j` in the sparse matrix, even though the memory location of i,j is already known to the iterator on the stack. To directly use the known value, we can just call .valueRef() on the iterator instead of looking for the position again. A discussion of this difference is given in the `Iterating over the nonzero coefficients` section of this tutorial: https://eigen.tuxfamily.org/dox/group__TutorialSparse.html Benchmark showed a modest 13% time reduction in a call to NormalizeData.
- Loading branch information