Simple utility functions for converting complex data to real and back

All the PCA implementations I could find only work with real-valued data
so we need a conversion algorithm.
Currently this just uses a very simple method but in future it could
be changed to work in-place.