Solve linear and non-linear optimisation problems with the conjugate-gradients algorithm