Closed jishnub closed 4 years ago
The type might be further restricted to something along the lines of
Base.ReinterpretArray{T,N,Complex{T},Array{Complex{T},N}} where {N,T}
which is expected to be contiguous. Just a general Base.ReinterpretArray{T}
might not be the best idea if arrays of structs are used because of padding (eg this discourse post).
Fixed by #131
This is more of a discussion that I wanted to have, as I often have to work in Fourier space where arrays are complex. Since complex arrays are usually laid out contiguously in memory, it's possible to write them to FITS files by reinterpreting them as floating point arrays where the first dimension is doubled in size. Such arrays may also be read in by reinterpreting them as Complex ones of the correct type. Is this a feature that might be implemented? In that case I might consider submitting a PR.
What I currently use for complex arrays is something like
floatarr = collect(reinterpret(Float64,complexarr)
before writing to FITS. This involves an extra collection --- and hence allocation --- that is unnecessary. It appears solving thewrite
is straightforward by expanding the type dispatched upon fromArray{T}
toUnion{Array{T},Base.ReinterpretArray{T}}
. I haven't looked into theread
part yet. I was wondering if this appears sensible, or if there is something that I'm missing.