Fix crash with NaN solutions in debug mode
Function std::polar was used to convert amplitude,phase to real,imag. However, amplitudes can be NaN, in which case std::polar has undefined behaviour. In debug mode, std::polar does an assert(amplitude >= 0), causing it to crash on NaN amplitudes. This MR adds a stable Polar function that has defined NaN results.