C4LIB is a C library which defines single precision complex numbers and the operations necessary to do arithmetic on them.
The original C specification did not include support for complex numbers. While later versions of the ANSI standard did include specifications for complex number support, the actual implementation of this standard seems to be irregular and inconsistent. Although C++ includes solid support for complex numbers, there may be situations where a small amount of complex arithmetic is needed in a C programming context.
To use the structures and functions of this library, it is necessary that the user's source code invoke the include file:
# include "c4lib.h"
This package defines a single precision complex number as a C struct whose components are floats:
struct c4_complex
{
float real;
float imag;
};
To declare a variable c you could use a statement like:
struct c4_complex c;
The declaration can include an initialization:
struct c4_complex c = { 1.0, 2.0 };
The value of a variable c declared as struct c4_complex may be examined or changed by accessing the components of the struct. Thus, the initialization above could be carried out at run time by the commands:
c.real = 1.0;
c.imag = 2.0;
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
BLAS1_C is a C library which contains basic linear algebra routines for vector-vector operations, using single precision complex arithmetic.
C8LIB, a C library which implements certain elementary functions for double precision complex variables;
C4LIB is available in a C version and a FORTRAN77 version and a FORTRAN90 version.
MY_COMPLEX, a C++ class for complex numbers;
You can go up one level to the C source codes.