  We establish a large-deviations principle for the largest eigenvalue of a
generalized sample covariance matrix, meaning a matrix proportional to $Z^T
\Gamma Z$, where $Z$ has i.i.d. real or complex entries and $\Gamma$ is not
necessarily the identity. We treat the classical case when $Z$ is Gaussian and
$\Gamma$ is positive definite, but we also cover two orthogonal extensions:
Either the entries of $Z$ can instead be sharp sub-Gaussian, a class including
Rademacher and uniform distributions, where we find the same rate function as
for the Gaussian model; or $\Gamma$ can have negative eigenvalues if $Z$
remains Gaussian. The latter case confirms formulas of Maillard in the physics
literature.
  We also apply our techniques to the largest eigenvalue of a deformed Wigner
matrix, real or complex, where we upgrade previous large-deviations estimates
to a full large-deviations principle. Finally, we remove several technical
assumptions present in previous related works.
