An algorithm for quadratic programming