Variational Optimization on Lie Groups, with Examples of Leading (Generalized) Eigenvalue Problems