# HG changeset patch # User Jaroslav Hajek # Date 1271069864 -7200 # Node ID ddbd812d09aafdd7839ccebe7d710cd94ad54469 # Parent 9a5e2d13fa5ad409f59e6f1ffb4129c3469a5d3b properly compress sparse matrices after assembly diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-04-12 Jaroslav Hajek + + * Sparse.cc (Sparse::Sparse (const Array&, const idx_vector&, + const idx_vector&, ...)): Call maybe_compress after matrix is created. + 2010-04-09 Jaroslav Hajek * Sparse.cc (Sparse::diag): Change nzmax to nnz where appropriate. diff --git a/liboctave/Sparse.cc b/liboctave/Sparse.cc --- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -329,7 +329,11 @@ { // This is completely specialized, because the sorts can be simplified. T a0 = a(0); - if (cl == 1) + if (a0 == T()) + { + // Do nothing, it's an empty matrix. + } + else if (cl == 1) { // Sparse column vector. Sort row indices. idx_vector rs = r.sorted (); @@ -516,6 +520,8 @@ rrd[k] = a(rdi[i]); } } + + maybe_compress (true); } else { @@ -606,6 +612,8 @@ } } } + + maybe_compress (true); } }