Jacobi Rotations: A General Procedure for Electronic Energy Optimization*