Fix complex polynomial fit

Fix for issue gh-2790.