Algorithms for matrix iterative methods