c8_complex_lib, a C code which contains routines for "C8" or "double precision complex" arithmetic.
The original C specification did not include support for complex numbers. Until the later C99 specification added such support, it was common for programmers to develop their own complex arithmetic libraries. Despite the fact that these routines are now generally obsolete, the procedures involved can still be instructive and useful, including the use of structures for the data type and the development of a variety of functions to carry out the necessary arithmetic operations.
To use the structures and functions of this library, it is necessary that the user's source code invoke the include file:
# include "c8_complex_lib.h"
This package defines a double precision complex number as a C struct whose components are doubles:
struct c8_complex
{
double real;
double imag;
};
To declare a variable c you could use a statement like:
struct c8_complex c;
The declaration can include an initialization:
struct c8_complex c = { 1.0, 2.0 };
The value of a variable c declared as struct c8_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;
In the common case when pointers are used, we declare
struct *c8_complex c;
and then create the variable with:
c = ( struct c8_complex *) malloc ( sizeof ( struct c8_complex ) );
and assign values with commands like:
c->real = 1.0;
c->imag = 2.0;
and finally, release the memory associated with the variable by
free ( c );
The computer code and data files described and made available on this web page are distributed under the MIT license
c8_complex_lib is available in a C version and a C++ version.
BLAS1_Z, a C code which contains basic linear algebra routines for vector-vector operations, using double precision complex arithmetic.
C4_COMPLEX_LIB, a C code which defines a single precision complex variable or "C4" as a structure, and implements certain corresponding elementary functions.
C8LIB, a C code which implements certain elementary functions for "C8" or double precision complex variables using the C99 standard "double complex" datatype.
COMPLEX_NUMBERS, a C code which demonstrates some simple features involved in the use of complex numbers in C codeming.
I4LIB, a C code which contains many utility routines, using "I4" or "single precision integer" arithmetic.
I8LIB, a C code which contains many utility routines, using "I8" or "double precision integer" arithmetic.
R4LIB, a C code which contains many utility routines, using "R4" or "single precision real" arithmetic.
R8LIB, a C code which contains many utility routines, using "R8" or "double precision real" arithmetic.