Mercurial > hg > octave-nkf
diff liboctave/Sparse.cc @ 10527:b4d2080b6df7
Replace nzmax by nnz as needed
author | David Bateman <dbateman@free.fr> |
---|---|
date | Fri, 16 Apr 2010 16:14:45 +0200 |
parents | 4d1fc073fbb7 |
children | 2dd8ea8bfd71 |
line wrap: on
line diff
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -257,7 +257,8 @@ template <class T> Sparse<T>::Sparse (const Array<T>& a, const idx_vector& r, const idx_vector& c, octave_idx_type nr, - octave_idx_type nc, bool sum_terms) + octave_idx_type nc, bool sum_terms, + octave_idx_type nzm) : rep (nil_rep ()), dimensions () { if (nr < 0) @@ -296,7 +297,7 @@ { if (n == 1 && a(0) != T ()) { - change_capacity (1); + change_capacity (nzm > 1 ? nzm : 1); xridx(0) = r(0); xdata(0) = a(0); for (octave_idx_type j = 0; j < nc; j++) @@ -324,7 +325,7 @@ for (octave_idx_type i = 1; i < n; i++) new_nz += rd[i-1] != rd[i]; // Allocate result. - change_capacity (new_nz); + change_capacity (nzm > new_nz ? nzm : new_nz); xcidx (1) = new_nz; octave_idx_type *rri = ridx (); T *rrd = data (); @@ -407,7 +408,7 @@ xcidx(j+1) = xcidx(j) + nzj; } - change_capacity (xcidx (nc)); + change_capacity (nzm > xcidx (nc) ? nzm : xcidx (nc)); octave_idx_type *rri = ridx (); T *rrd = data (); @@ -463,7 +464,7 @@ for (octave_idx_type i = 1; i < n; i++) new_nz += rd[i-1] != rd[i]; // Allocate result. - change_capacity (new_nz); + change_capacity (nzm > new_nz ? nzm : new_nz); xcidx(1) = new_nz; octave_idx_type *rri = ridx (); T *rrd = data (); @@ -550,7 +551,7 @@ xcidx(j+1) = xcidx(j) + nzj; } - change_capacity (xcidx (nc)); + change_capacity (nzm > xcidx (nc) ? nzm : xcidx (nc)); octave_idx_type *rri = ridx (); T *rrd = data ();