Fix for cov() with complex input

Closes issues #597 and #2680, which are duplicates.

It follows #2716 which was abandoned.

The example for the test was taken from #597.