Iterative solver for matrix equations