move SMatrix serialization to use iterators consistently