Mercurial > hg > octave-nkf
diff liboctave/CSparse.cc @ 9469:c6edba80dfae
sanity checks for loading sparse matrices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 29 Jul 2009 12:15:27 -0400 |
parents | 5d46c4a894e8 |
children | a5035bc7fbfb |
line wrap: on
line diff
--- a/liboctave/CSparse.cc +++ b/liboctave/CSparse.cc @@ -7466,48 +7466,9 @@ std::istream& operator >> (std::istream& is, SparseComplexMatrix& a) { - octave_idx_type nr = a.rows (); - octave_idx_type nc = a.cols (); - octave_idx_type nz = a.nzmax (); - - if (nr > 0 && nc > 0) - { - octave_idx_type itmp, jtmp, jold = 0; - Complex tmp; - octave_idx_type ii = 0; - - a.cidx (0) = 0; - for (octave_idx_type i = 0; i < nz; i++) - { - is >> itmp; - itmp--; - is >> jtmp; - jtmp--; - tmp = octave_read_complex (is); - - if (is) - { - if (jold != jtmp) - { - for (octave_idx_type j = jold; j < jtmp; j++) - a.cidx(j+1) = ii; - - jold = jtmp; - } - a.data (ii) = tmp; - a.ridx (ii++) = itmp; - } - else - goto done; - } - - for (octave_idx_type j = jold; j < nc; j++) - a.cidx(j+1) = ii; - } - - done: - - return is; + typedef SparseComplexMatrix::element_type elt_type; + + return read_sparse_matrix<elt_type> (is, a, octave_read_value<Complex>); } SparseComplexMatrix