Incorpoarte imaginary constants in classify_ode of undetermined_coeff

In issue 5787, there was no condition to classify imaginary constants
which caused the issue to fail in case of undetermined coefficients.
This patch have a condition added to classify it.