Next: switch, Previous: swapb, Up: Internal Routines [Contents][Index]

`swaphalf, `

`data`

Swaps elements in numerical array

such that each new
coordinate `data``y`

of an element of

is related to the
old coordinate `data``x`

by `y = x + n/2 mod n/2`

, where `n`

is
the number of elements in the current dimension. This swapping is
useful for data returned by certain fft and Hartley transform routines,
which return the central point of the transform in element number 0.
When `swaphalf`

is used on such data, then the central element ends
up in the center of the data (at coordinates equal to `n/2`

for
each dimension) and the length of the wavevector is proportional to the
cartesian distance of the associated element to that central point.

`swaphalf`

works only on arrays that have even dimensions only.
`shift, `

yields the same result as
`data``swaphalf, `

, except that `data``shift`

works for
odd-sized dimensions, too, and is 4 - 5 times slower than
`swaphalf`

.