my problem is that 'some_function( l )' is non-increasing with respect to l, i.e. some_function( l,k ) is not always greater than some_function( l' ,k) when l>l'. Therefore, for a given column k, when entry_counter is incremented, the row index is not always increasing. This results in some funny results, like if the output mxRES is a matrix X in matlab, then sometime we have [H']' =/= H.
I cannot change 'some_function( l,k )' to make it increasing w.r.t l. Is there any approach to tackle this problem? There must be one since the 'sparse' function in matlab does not require indices to be increasing