Go to the
previous,
next chapter.
This file defines the complex data type and some basic operations on it.
- Data Type:
COMPLEX Variable [(InitReal,[InitImag])]
- Declares Variable as complex number. If InitReal or InitImag
are present, the real and imaginary part of Variable are initialized with these
values. Example:
COMPLEX a(1.0);
declares the variable a
as complex number and initializes the real part of a
with 1.0 and the imaginary part with 0.
The basic operations +, -, *, and /, the unary operators
+ and - as well as +=, -=, *=, and /= are
defined for complex data. Comparisons of complex expressions are possible with
== and !=.
Additionally, the following functions are provided:
- Constructor:
COMPLEX COMPLEX (InitReal,[InitImag])
- Returns/defines a complex number with InitReal as real part and InitImag
as imaginary part.
- Function:
REAL Re (COMPLEX c)
- Returns the real part of c.
- Function:
REAL Im (COMPLEX c)
- Returns the imaginary part of c.
- Function:
COMPLEX Conjg (COMPLEX c)
- Returns the conjugate of c.
- Function:
REAL Abs (COMPLEX c)
- Returns the absolute value of c.
- Function:
COMPLEX Sqrt (COMPLEX c)
- Returns the complex square root of c.
The imaginary unit is available through
- Variable:
COMPLEX I
- Contains the imaginary unit, i.e. a value with a zero real part and a one
as imaginary part.