ORNL / ReSolve

Library of GPU-resident linear solvers
Other
51 stars 1 forks source link

document invariants for `nnz_expanded_` or remove it entirely #166

Open superwhiskers opened 2 weeks ago

superwhiskers commented 2 weeks ago

according to @pelesh, there is no hard requirement that the value stored in the nnz_expanded_ field on the Sparse class be correct. the field should either be removed entirely (as i'm not really sure what it would be used for if it can't be relied on) or have this invariant documented so that it does not lead to confusion or errors in the future

pelesh commented 2 weeks ago

Thanks for reporting this issue, @superwhiskers.

The nnz_expanded_ refers to the number of non zeros when you expand a symmetric matrix to a general sparse matrix format. There is no way of knowing nnz_expanded_ upon instantiation of a sparse symmetric matrix in upper/lower triangular form, so it should be set to zero and stay zero for al long as flag is_expanded_ is set to false. The nnz_expanded_ needs to be calculated at the time when a function to expand the matrix into a general form is called. The expand function should have the responsibility to set the new number of nonzeros and flip the flag is_expanded_ to true.

My preference would be to remove nnz_expanded_ as a member variable altogether because it is used only as a temporary storage until nnz_ is updated.

CC @kswirydo