Mercurial > octave
diff libinterp/corefcn/sparse.cc @ 27081:c0d8ce61c1c9 stable
Always reserve at least 1 element of storage for sparse matrices (bug #56232).
* Sparse.h (SparseRep (void), SparseRep (octave_idx_type n),
SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz = 1)):
Rewrite constructors to always create valid d and r pointers with enough
memory for 1 value. Always initialize nzmx to at least 1.
* Sparse.cc (SparseRep::change_length): Check for nz == 0 and change value to 1
so that sparse array always maintains memory for at least one value.
* amd.cc (Famd): Re-write failing BIST test that now works.
* data.cc (Fnzmax): Document that nzmax will always return at least 1.
* sparse.cc (Fspalloc): Document that 1 element will always be allocated.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 08 May 2019 15:18:32 -0700 |
parents | f6730533820e |
children | b442ec6dda5c |
line wrap: on
line diff
--- a/libinterp/corefcn/sparse.cc Mon May 06 20:25:15 2019 -0700 +++ b/libinterp/corefcn/sparse.cc Wed May 08 15:18:32 2019 -0700 @@ -267,9 +267,9 @@ @b{and} that the following conditions are met: @itemize -@item the assignment does not decrease nnz (@var{S}). +@item the assignment does not decrease @code{nnz (@var{S})}. -@item after the assignment, nnz (@var{S}) does not exceed @var{nz}. +@item after the assignment, @code{nnz (@var{S})} does not exceed @var{nz}. @item no index is out of bounds. @end itemize @@ -281,6 +281,9 @@ The amount of pre-allocated memory for a given matrix may be queried using the function @code{nzmax}. + +Programming Note: Octave always reserves memory for at least one value, +even if @var{nz} is 0. @seealso{nzmax, sparse} @end deftypefn */) {