if-else operations can be combined in the sparse hessian with loops
improved ordering of the branches in the if-else operations used by the sparse hessian with loops