fft - Is the storage of COMPLEX in fortran guaranteed to be two REALs? -
many fft algorithms take advantage of complex numbers stored alternating real , imaginary part in array. creating complex array , passing fft routine, guaranteed can cast real array (of twice size) alternating real , imaginary components?
subroutine fft (data, n, isign) dimension data(2*n) 1 i=1,2*n,2 data(i) = .. data(i+1) = .. 1 continue return end ... complex s(n) call fft (s, n, 1) ...
(and, btw, dimension data(2*n) same saying real?)
i'm writing answer because experience has taught me write sort of answer 1 of real fortran experts hereabouts piles in correct me.
i don't think current standard, nor of predecessors, states explicitly complex
implemented 2 neighbouring-in-memory reals
. however, think implementation necessary consequence of standard's definitions of equivalence
, of common
. don't think have ever encountered implementation in complex
not implemented pair of reals
.
the standard guarantee, though complex
can converted pair of reals
. so, given definitions:
complex :: z complex, dimension(4) :: zarr real :: r1, r2 real, dimension(8) :: rarr
the following might expect
r1 = real(z) r2 = aimag(z)
both functions elemental , here comes wrinkle:
real(zarr)
returns 4-element array of reals,
aimag(zarr)
while
[real(zarr), aimag(zarr)]
is 8-element array of reals real parts of zarr
followed complex parts. perhaps
rarr(1:8:2) = real(zarr) rarr(2:8:2) = aimag(zarr)
will ok you. i'm not sure of neater way though.
alexander's not 1 able quote standard ! part quotes left me wondering non-default complex scalars. read on, , think para 6 of section points towards germane
a nonpointer scalar object of type not specified in items (1)-(5) occupies single unspecified storage unit different each case , each set of type parameter values, , different unspecified storage units of item (4),
i don't think has impact @ on of answers here.
Comments
Post a Comment