C complex number usage

Kent Johnson kent37 at tds.net
Sun Jan 6 12:57:47 EST 2008


Bruce Labitt wrote:
> Hopefully a simple question.  I'm trying to write a C program that uses 
> complex numbers.
> Hopefully someone can point me in the write direction.  TIA.

If you don't have a specific requirement for C, you might consider 
learning Python instead.
----> python.org :-)

Python has built-in support for complex numbers and the add-on package 
numpy supports FFT of complex arrays:
http://numpy.scipy.org/numpydoc/numpy-17.html

Your code would look something like this in Python:

from random import gauss

N = 1024
mymean = ...
mystdev = ...
g = [ complex(gauss(mymean, mystdev), gauss(mymean, mystdev)) for i in 
range(N) ]

HTH,
Kent


More information about the gnhlug-discuss mailing list