From: Philip Tresadern <Philip.T<resadern@ma...>  20131128 12:24:12

Does anybody use vnl_sparse_matrix::set_identity()? There seems to be a rather obvious bug: template<class T> vnl_sparse_matrix<T>& vnl_sparse_matrix<T>::set_identity() { // Iterate through the matrix rows, and set one at a time: unsigned int rownum = 0; for (typename vcl_vector<row>::iterator row_iter = elements.begin(); row_iter != elements.end() && rownum < cols(); ++row_iter, ++rownum) { row& rw = *row_iter; rw.clear(); rw[0] = vnl_sparse_matrix_pair<T>(rownum,T(1)); } return *this; } Namely that when rw is clear()ed, it has length 0, causing an error when rw[0] is assigned in the following line. It seems peculiar that this hasn't been spotted and corrected before now, so I thought I'd ask before committing a fix. Phil Tresadern.  "What I cannot create, I do not understand." Richard P Feynman  Dr. Philip A Tresadern Research Associate Centre for Imaging, Institute of Population Health, Stopford Building, University of Manchester, Manchester M13 9ET United Kingdom tel: +44 (0)161 275 1853 