Typically, signals are real valued. But the programs in this chapter are for complex-valued signals. In order to use these programs, copy the real-valued signal into a complex array, where the signal goes into the real part of the complex numbers; the imaginary parts are then automatically set to zero.
There is no universally correct choice of scale factor in Fourier transform: choice of scale is a matter of convenience. Equations (3) and (4) mimic the Z-transform, so their scaling factors are convenient for the convolution theorem--that a product in the frequency domain is a convolution in the time domain. Obviously, the scaling factors of equations (3) and (4) will need to be interchanged for the complementary theorem that a convolution in the frequency domain is a product in the time domain. I like to use a scale factor that keeps the sums of squares the same in the time domain as in the frequency domain. Since I almost never need the scale factor, it simplifies life to omit it from the subroutine argument list. When a scaling program is desired, we can use a simple one like scale() . Complex-valued data can be scaled with scale() merely by doubling the value of n.
Fourier transform is just one of many transforms discussed in this book. In the case of most other transforms, the number of output values is different than the number of inputs. In addition, inverse transforms (and conjugate transforms), which will also be represented in code included in this book, transform in reverse, outputs to inputs. Finally, we will eventually combine transformations by addition or concatenation (one occurring after the other). All these considerations are expressed in the simple program adjnull(), which erases output before we begin. adjnull() may seem like too trivial a function to put in a library routine, but at last count, 15 other routines in this book use it.
subroutine adjnull( adj, add, x, nx, y, ny )
integer ix, iy, adj, add, nx, ny
real x( nx), y( ny )
if( add == 0 )
if( adj == 0 )
do iy= 1, ny
y(iy) = 0.
do ix= 1, nx
x(ix) = 0.