Mercurial > hg > octave-nkf
diff src/ov-base-sparse.cc @ 14566:aa491bd9e19b stable
avoid unnecessary index overflow error when printing sparse array (bug #35148)
* ov-base-sparse.cc (octave_base_sparse<T>::print_info): Don't use
numel when computing percentage of non-zero elements.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 16 Apr 2012 15:58:38 -0400 |
parents | 72c96de7a403 |
children | f7afecdd87ef |
line wrap: on
line diff
--- a/src/ov-base-sparse.cc +++ b/src/ov-base-sparse.cc @@ -318,7 +318,13 @@ << ", cols = " << nc << ", nnz = " << nz; - double dnel = matrix.numel (); + // Avoid calling numel here since it can easily overflow + // octave_idx_type even when there is no real problem storing the + // sparse array. + + double dnr = nr; + double dnc = nc; + double dnel = dnr * dnc; if (dnel > 0) {