C8LIB A Double Complex Arithmetic Utility Library

C8LIB is a C library which contains routines for "C8" or "double complex" arithmetic.

The original C specification did not include support for complex numbers. The "C99" version of the ANSI standard added specifications for a complex number datatype with either float, double, and long double components, the extension of existing arithmetic operations and functions to the new datatypes and the addition of a number of new functions unique to complex numbers.

To use the structures and functions of this library, it is necessary that the user's source code invoke the include file:

``````
# include
``````

A complex number may be declared as

• float complex, in which case the real and imaginary parts will be floats;
• double complex, in which case the real and imaginary parts will be doubles;
• long double complex, in which case the real and imaginary parts will be long doubles;

The constant I is defined to be equal to the imaginary unit. To assign a numeric value to a complex number, you must multiply the imaginary part by I:

``````
double complex c;

c = 3 + 4 * I;
``````

The declaration can include an initialization:

``````
double complex c = 3 - 4 * I;
``````

To examine the real or imaginary parts of a complex variable, the functions creal() and cimag() can be used:

``````
double complex c = 3 + 4 * I;
printf ( "  Expecting value 3, got %f\n", creal ( c ) );
printf ( "  Expecting value 4, got %f\n", cimag ( c ) );
``````

There are 22 functions defined for float complex, double complex, and long double complex data types. Here are the headers for the double complex functions:
FunctionValue
double = cabs(double complex)absolute value of c
double complex = cacos(double complex)inverse cosine of c
double complex = cacosh(double complex)inverse hyperbolic cosine of c
double = carg(double complex)argument of c
double complex = casin(double complex)inverse sine of c
double complex = casinh(double complex)inverse hyperbolic sine of c
double complex = catan(double complex)inverse tangent of c
double complex = catanh(double complex)inverse hyperbolic tangent of c
double complex = ccos(double complex)cosine of c
double complex = ccosh(double complex)hyperbolic cosine of c
double complex = cexp(double complex)exponential of c
double = cimag(double complex)imaginary part of c
double complex = clog(double complex)logarithm of c
double complex = conj(double complex)conjugate of c
double complex = cpow(double complex, double complex)c1 to the c2 power
double complex = cproj(double complex)projection of c onto Riemann sphere
double = creal(double complex)real part of c
double complex = csin(double complex)sine of c
double complex = csinh(double complex)hyperbolic sine of c
double complex = csqrt(double complex)square root of c
double complex = ctan(double complex)tangent of c
double complex = ctanh(double complex)hyperbolic tangent of c

C8LIB, in part, duplicates some of the functionality that was added by the C99 standard. The C8LIB versions should be of historical interest only. Other functions provided by C8LIB, however, may be of more substantial interest.

Languages:

C8LIB is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version and a Python version..

Related Programs:

BLAS1_Z, 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 "C4" or single precision complex variables using the C99 "float complex" datatype.

C8_COMPLEX_LIB, a C library which defines a double precision complex variable or "C8" as a structure, and implements certain corresponding elementary functions.

COMPLEX_NUMBERS, a C program which demonstrates some simple features involved in the use of complex numbers in C programming.

I4LIB, a C library which contains many utility routines, using "I4" or "single precision integer" arithmetic.

I8LIB, a C library which contains many utility routines, using "I8" or "double precision integer" arithmetic.

L4LIB, a C library which contains many utility routines, using one byte logical (L4) variables.

MY_COMPLEX, a C++ class for complex numbers;

R4LIB, a C library which contains many utility routines, using "R4" or "single precision real" arithmetic.

R8LIB, a C library which contains many utility routines, using "R8" or "double precision real" arithmetic.

List of Routines:

• C8_ABS returns the absolute value of a C8.
• C8_ACOS evaluates the inverse cosine of a C8.
• C8_ACOSH evaluates the inverse hyperbolic cosine of a C8.
• C8_ARG returns the argument of a C8.
• C8_ASIN evaluates the inverse sine of a C8.
• C8_ASINH evaluates the inverse hyperbolic sine of a C8.
• C8_ATAN evaluates the inverse tangent of a C8.
• C8_ATANH evaluates the inverse hyperbolic tangent of a C8.
• C8_CONJ conjugates a C8.
• C8_COPY copies a C8.
• C8_COS evaluates the cosine of a C8.
• C8_COSH evaluates the hyperbolic cosine of a C8.
• C8_CUBE_ROOT computes the principal cube root of a C8.
• C8_DIV divides two C8's.
• C8_DIV_R8 divides a C8 by an R8.
• C8_EXP exponentiates a C8.
• C8_I returns the value of I as a C8
• C8_IMAG returns the imaginary part of a C8.
• C8_INV inverts a C8.
• C8_LE_L1 := X <= Y for C8 values, and the L1 norm.
• C8_LE_L2 := X <= Y for C8 values, and the L2 norm.
• C8_LE_LI := X <= Y for C8 values, and the L-oo norm.
• C8_LOG evaluates the logarithm of a C8.
• C8_MAG returns the magnitude of a C8.
• C8_MUL multiplies two C8's.
• C8_NEG negates a C8.
• C8_NINT returns the nearest complex integer of a C8.
• C8_NORM_L1 evaluates the L1 norm of a C8.
• C8_NORM_L2 evaluates the L2 norm of a C8.
• C8_NORM_LI evaluates the L-infinity norm of a C8.
• C8_NORMAL_01 returns a unit pseudonormal C8.
• C8_ONE returns the value of 1 as a C8
• C8_PRINT prints a C8.
• C8_REAL returns the real part of a C8.
• C8_SIN evaluates the sine of a C8.
• C8_SINH evaluates the hyperbolic sine of a C8.
• C8_SQRT computes a square root of a C8.
• C8_SUB subtracts two C8's.
• C8_SWAP swaps two C8's.
• C8_TAN evaluates the tangent of a C8.
• C8_TANH evaluates the hyperbolic tangent of a C8.
• C8_TO_CARTESIAN converts a C8 to Cartesian form.
• C8_TO_POLAR converts a C8 to polar form.
• C8_UNIFORM_01 returns a unit pseudorandom C8.
• C8_ZERO returns the value of 0 as a C8
• C8MAT_ADD combines two C8MAT's with complex scale factors.
• C8MAT_ADD_R8 combines two C8MAT's with real scale factors.
• C8MAT_COPY copies one C8MAT to another.
• C8MAT_COPY_NEW copies one C8MAT to a "new" C8MAT.
• C8MAT_FSS factors and solves a system with multiple right hand sides.
• C8MAT_FSS_NEW factors and solves a system with multiple right hand sides.
• C8MAT_IDENTITY_NEW sets a C8MAT to the identity.
• C8MAT_INDICATOR_NEW returns the C8MAT indicator matrix.
• C8MAT_MINVM returns inverse(A) * B for C8MAT's.
• C8MAT_MINVM_NEW returns inverse(A) * B for C8MAT's.
• C8MAT_MM multiplies two C8MAT's.
• C8MAT_MM_NEW multiplies two C8MAT's.
• C8MAT_NINT rounds the entries of a C8MAT.
• C8MAT_NORM_FRO returns the Frobenius norm of a C8MAT.
• C8MAT_NORM_L1 returns the matrix L1 norm of a C8MAT.
• C8MAT_NORM_LI returns the L-infinity norm of a C8MAT.
• C8MAT_PRINT prints a C8MAT.
• C8MAT_PRINT_SOME prints some of a C8MAT.
• C8MAT_SCALE scales a C8MAT by a complex scale factor.
• C8MAT_SCALE_R8 scales a C8MAT by a real scale factor
• C8MAT_UNIFORM_01 returns a unit pseudorandom C8MAT.
• C8MAT_ZERO_NEW returns a new zeroed C8MAT.
• C8VEC_COPY copies a C8VEC to another.
• C8VEC_COPY_NEW copies a C8VEC to a "new" C8VEC.
• C8VEC_NINT rounds the entries of a C8VEC.
• C8VEC_NORM_L2 returns the L2 norm of a C8VEC.
• C8VEC_PRINT prints a C8VEC.
• C8VEC_PRINT_PART prints "part" of a C8VEC.
• C8VEC_PRINT_SOME prints "some" of a C8VEC.
• C8VEC_SORT_A_L2 ascending sorts a double complex array by L2 norm.
• C8VEC_SPIRAL returns N points on a spiral between C1 and C2.
• C8VEC_UNIFORM_01_NEW returns a unit pseudorandom C8VEC.
• C8VEC_UNITY returns the N roots of unity in a C8VEC.
• CARTESIAN_TO_C8 converts a Cartesian form to a C8.
• POLAR_TO_C8 converts a polar form to a C8.
• R8_CSQRT returns the complex square root of an R8.
• R8POLY2_ROOT returns the two roots of a quadratic polynomial.
• R8POLY3_ROOT returns the three roots of a cubic polynomial.
• R8POLY4_ROOT returns the four roots of a quartic polynomial.

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

Last revised on 05 March 2013.