fixed the problem... i was accessing the matrix wrongly when iterating
through non-zeros...