# HG changeset patch # User Jaroslav Hajek # Date 1271163389 -7200 # Node ID 189274f6c7c42dc037d77278ab2ef53579ccd2da # Parent 40c58502a78b7fedfdeb27326f3a7bedf72dfaea omissions from last patch diff --git a/liboctave/CSparse.cc b/liboctave/CSparse.cc --- a/liboctave/CSparse.cc +++ b/liboctave/CSparse.cc @@ -121,19 +121,8 @@ } SparseComplexMatrix::SparseComplexMatrix (const SparseMatrix& a) - : MSparse (a.rows (), a.cols (), a.nnz ()) -{ - octave_idx_type nc = cols (); - octave_idx_type nz = a.nnz (); - - for (octave_idx_type i = 0; i < nc + 1; i++) - cidx (i) = a.cidx (i); - - for (octave_idx_type i = 0; i < nz; i++) - { - data (i) = Complex (a.data (i)); - ridx (i) = a.ridx (i); - } + : MSparse (a) +{ } SparseComplexMatrix::SparseComplexMatrix (const SparseBoolMatrix& a) diff --git a/liboctave/Sparse.h b/liboctave/Sparse.h --- a/liboctave/Sparse.h +++ b/liboctave/Sparse.h @@ -104,17 +104,6 @@ copy_or_memcpy (ncols + 1, a.c, c); } - template - SparseRep (const Sparse::SparseRep& a) - : d (new T [a.nzmx]), r (new octave_idx_type [a.nzmx]), c (new octave_idx_type [a.ncols + 1]), - nzmx (a.nzmx), nrows (a.nrows), ncols (a.ncols), count (1) - { - octave_idx_type nz = a.nnz (); - std::copy (a.d, a.d + nz, d); - copy_or_memcpy (nz, a.r, r); - copy_or_memcpy (ncols + 1, a.c, c); - } - ~SparseRep (void) { delete [] d; delete [] r; delete [] c; } octave_idx_type length (void) const { return nzmx; } @@ -206,9 +195,16 @@ dimensions (dim_vector (nr, nc)) { } // Type conversion case. Preserves capacity (). - template Sparse (const Sparse& a) - : rep (new typename Sparse::SparseRep (a.rep)), - dimensions (a.dimensions) { } + template + Sparse (const Sparse& a) + : rep (new typename Sparse::SparseRep (a.rep->nrows, a.rep->ncols, a.rep->nzmx)), + dimensions (a.dimensions) + { + octave_idx_type nz = a.nnz (); + std::copy (a.rep->d, a.rep->d + nz, rep->d); + copy_or_memcpy (nz, a.rep->r, rep->r); + copy_or_memcpy (rep->ncols + 1, a.rep->c, rep->c); + } // No type conversion case. Sparse (const Sparse& a)