Mercurial > octave-libgccjit
diff liboctave/CSparse.cc @ 8910:6e9f26506804
optimize diag -> sparse and perm -> sparse conversions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 05 Mar 2009 08:34:52 +0100 |
parents | 25bc2d31e1bf |
children | eb63fbe60fab |
line wrap: on
line diff
--- a/liboctave/CSparse.cc Thu Mar 05 00:55:56 2009 -0500 +++ b/liboctave/CSparse.cc Thu Mar 05 08:34:52 2009 +0100 @@ -146,20 +146,21 @@ } SparseComplexMatrix::SparseComplexMatrix (const ComplexDiagMatrix& a) - : MSparse<Complex> (a.rows (), a.cols (), a.nnz ()) -{ - octave_idx_type nz = a.nnz (), l = a.length (); - for (octave_idx_type i = 0, j = 0; i < l; i++) + : MSparse<Complex> (a.rows (), a.cols (), a.length ()) +{ + octave_idx_type j = 0, l = a.length (); + for (octave_idx_type i = 0; i < l; i++) { - if (a(i, i) != Complex (0.0, 0.0)) + cidx (i) = j; + if (a(i, i) != 0.0) { data (j) = a(i, i); ridx (j) = i; - cidx (j) = j; j++; } } - cidx (nz) = nz; + for (octave_idx_type i = l; i <= a.cols (); i++) + cidx(i) = j; } bool SparseComplexMatrix::operator == (const SparseComplexMatrix& a) const