Next: Properties of complex numbers, Up: Complex Numbers [Index]
Complex numbers are represented using the type gsl_complex
. The
internal representation of this type may vary across platforms and
should not be accessed directly. The functions and macros described
below allow complex numbers to be manipulated in a portable way.
For reference, the default form of the gsl_complex
type is
given by the following struct,
typedef struct { double dat[2]; } gsl_complex;
The real and imaginary part are stored in contiguous elements of a two
element array. This eliminates any padding between the real and
imaginary parts, dat[0]
and dat[1]
, allowing the struct to
be mapped correctly onto packed complex arrays.
This function uses the rectangular Cartesian components
(x,y) to return the complex number z = x + i y. An inline version of this function is used when HAVE_INLINE
is defined.
This function returns the complex number z = r \exp(i \theta) = r (\cos(\theta) + i \sin(\theta)) from the polar representation (r,theta).
These macros return the real and imaginary parts of the complex number z.
This macro uses the Cartesian components (x,y) to set the real and imaginary parts of the complex number pointed to by zp. For example,
GSL_SET_COMPLEX(&z, 3, 4)
sets z to be 3 + 4i.
These macros allow the real and imaginary parts of the complex number pointed to by zp to be set independently.
Next: Properties of complex numbers, Up: Complex Numbers [Index]