I'm using two numpy arrays of floating point numbers
Rs = np.linspace(*realBounds, realResolution, dtype=fdtype)
Is = np.linspace(*imagBounds, imagResolution, dtype=fdtype)
to make a grid Zs of complex numbers with shape (realResolution, imagResolution). I'd like to only specify the datatype of Zs and use this to determine the float datatype fdtype.
As I understand it from this page, complex datatypes are always represented as two floats with the same datatype, hence why Rs and Is both have dtype=fdtype. If the datatype of Zs is specified as np.csingle then I'd like fdtype to be np.single, if it's specified as np.dtype("complex128") then I'd like fdtype to be np.dtype("float64"), and so on. Is there a nice way to do this?
Edit: I'm equally interested in the inverse function which sends, for example, np.single to np.csingle.