  We explain the concept of Krein signature in Hamiltonian and
$\mathcal{PT}$-symmetric systems on the case study of the one-dimensional
Gross-Pitaevskii equation with a real harmonic potential and an imaginary
linear potential. These potentials correspond to the magnetic trap, and a
linear gain/loss in the mean-field model of cigar-shaped Bose-Einstein
condensates. For the linearized Gross-Pitaevskii equation, we introduce the
real-valued Krein quantity, which is nonzero if the eigenvalue is neutrally
stable and simple and zero if the eigenvalue is unstable. If the neutrally
stable eigenvalue is simple, it persists with respect to perturbations.
However, if it is multiple, it may split into unstable eigenvalues under
perturbations. A necessary condition for the onset of instability past the
bifurcation point requires existence of two simple neutrally stable eigenvalues
of opposite Krein signatures before the bifurcation point. This property is
useful in the parameter continuations of neutrally stable eigenvalues of the
linearized Gross-Pitaevskii equation.
