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


15.5.609 swaphalf

swaphalf, data

Swaps elements in numerical array data such that each new coordinate y of an element of data is related to the old coordinate 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, data yields the same result as swaphalf, data, except that shift works for odd-sized dimensions, too, and is 4 - 5 times slower than swaphalf.

See also: fft, shift