Correct parameter gradient computation.

There were two bugs in the parameter gradient computation.

First, the wrong index was used to compute the break value gradient.

Second, the index gradients were both computed, irrespectively of the energy. However, if the energy is smaller than the break energy, only the first index gradient should be computed while the second will be 0. If the energy is larger, the first index gradient should be 0 and only the second should be computed.

Both bugs have been fixed.