wrote interface for conjugate gradient method