A note on efficient computation of the gradient in semidefinite programming