One needs to develop a special algorithm that runs only through the elements of the upper triangular matrix g and have k as an index.
The expression to be derived in the following is of interest when computing the quantum force and the kinetic energy. It has the form
∇iΨCΨC=1ΨC∂ΨC∂xi,for all dimensions and with i running over all particles.