changeset 10515:189274f6c7c4

omissions from last patch
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 13 Apr 2010 14:56:29 +0200
parents 40c58502a78b
children f0266ee4aabe
files liboctave/CSparse.cc liboctave/Sparse.h
diffstat 2 files changed, 12 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/CSparse.cc	Tue Apr 13 12:45:24 2010 +0200
+++ b/liboctave/CSparse.cc	Tue Apr 13 14:56:29 2010 +0200
@@ -121,19 +121,8 @@
 }
 
 SparseComplexMatrix::SparseComplexMatrix (const SparseMatrix& a)
-  : MSparse<Complex> (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<Complex> (a)
+{
 }
 
 SparseComplexMatrix::SparseComplexMatrix (const SparseBoolMatrix& a)
--- a/liboctave/Sparse.h	Tue Apr 13 12:45:24 2010 +0200
+++ b/liboctave/Sparse.h	Tue Apr 13 14:56:29 2010 +0200
@@ -104,17 +104,6 @@
         copy_or_memcpy (ncols + 1, a.c, c);
       }
  
-    template <class U>
-    SparseRep (const Sparse<U>::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 <class U> Sparse (const Sparse<U>& a)
-    : rep (new typename Sparse<T>::SparseRep (a.rep)),
-    dimensions (a.dimensions) { }
+  template <class U> 
+  Sparse (const Sparse<U>& a)
+    : rep (new typename Sparse<T>::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<T>& a)