complex - Member Functions and Data by Group

Constructors & Destructor

These constructors can be used to create complex objects.

There is no explicit complex destructor.

Arrays of Complex Numbers

You can use the complex constructor to initialize arrays of complex numbers. If the list of initial values is made up of complex values, each array element is initialized to the corresponding value in the list of initial vlaues. If the list of initial values is not made up of complex values, the real parts of the array elements are initialized to these initial values and the imaginary parts of the array elements are initialized to 0.

In the following example, the elements of array b are initialized to the values in the initial value list, but only the real parts of elements of array a are initialized to the values in the initial value list.

   #include < complex.h >

   int main()
   {
      complex a[3] = {1.0, 2.0, 3.0};
      complex b[3] = {complex(1.0, 1.0), complex(2.0, 2.0), complex(3.0, 3.0)};

      cout <<  "Here is the first element of a:  " << a[0] << endl;
      cout <<  "Here is the first element of b:  " << b[0] << endl;
   }

This example produces the following output:

   Here is the first element of a: ( 1, 0)
   Here is the first element of b: ( 1, 1)
complex

Constructs a complex number.

Overload 1
public:complex(double r, double i = 0.0)

This is supported on AIX OS/400 z/OS

Constructs a complex number.

The first argument, r, is assigned to the real part of the complex number. If you specify a second argument, it is assigned to the imaginary part of the complex number. If the second parameter is not specified, the imaginary part is initialized to 0.

Overload 2
public:complex()

This is supported on AIX OS/400 z/OS

Constructs a complex number . The real and imaginary parts of the complex number are initialized to (0, 0).

Assignment Operators

The assignment operators do not produce a value that can be used in an expression. The following code, for example, produces a compile-time error:

   complex x, y, z;   // valid declaration

   x = (y += z);      // invalid assignment causes a compile-time error

   y += z;         // correct method involves splitting expression
   x = y;         // into separate statements.
operator *=

Assigns the value of x * y to x.

Overload 1
public:void operator *=(const complex&)

This is supported on AIX

Overload 2
public:inline void operator *=(complex)

This is supported on OS/400 z/OS

operator +=

Assigns the value of x + y to x.

Overload 1
public:inline void operator +=(complex)

This is supported on OS/400 z/OS

Overload 2
public:inline void operator +=(const complex&)

This is supported on AIX

operator -=

Assigns the value of x - y to x.

Overload 1
public:inline void operator -=(complex)

This is supported on OS/400 z/OS

Overload 2
public:inline void operator -=(const complex&)

This is supported on AIX

operator /=

Assigns the value of x / y to x.

Overload 1
public:inline void operator /=(complex)

This is supported on OS/400 z/OS

Overload 2
public:void operator /=(const complex&)

This is supported on AIX

Internal Functions

These functions are internal to the complex class and should not be used by application programs.

hexdiveq
public:void hexdiveq(complex)

This is supported on z/OS

An internal function called by operator/= when the application uses hexadecimal floating point and double values.

hexmuteq
public:void hexmuteq(complex)

This is supported on z/OS

An internal function called by operator*= when the application uses hexadecimal floating point and double values.

ieeediveq
public:void ieeediveq(complex)

This is supported on z/OS

An internal function called by operator/= when the application uses IEEE floating point and double values.

ieeemuteq
public:void ieeemuteq(complex)

This is supported on z/OS

An internal function called by operator*= when the application uses IEEE floating point and double values.