Fixes for sparse complex matrices

Fixes #4523