C8LIB
Elementary functions for double precision complex variables


C8LIB is a C library which defines double 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 "c8lib.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 );
      

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Programs:

BLAS1_Z is a C library which contains basic linear algebra routines for vector-vector operations, using double precision complex arithmetic.

C4LIB, a C library which implements certain elementary functions for single precision complex variables;

C8LIB is available in a C version and a FORTRAN77 version and a FORTRAN90 version.

MY_COMPLEX, a C++ class for complex numbers;

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C source codes.


Last revised on 13 December 2008.