This seemingly innocuous statement can be quite complex when sparse matrix involved -- inserting a value to a sparse matrix is O(nnz) in general.