Bug fix: Wrong computation of #NZ elements for sparse matrices in C++ code