Added CG class to apply cg iterations for certain number of iterations.