CPLXOPS(3CC4)CPLXOPS(3CC4)NAMEcplxops - arithmetic operator functions in the C++ complex number math
library
SYNOPSIS
#include <complex.h>
class complex {
public:
friend complex operator- (const complex);
friend complex operator+ (const complex, const complex);
friend complex operator+ (double, const complex);
friend complex operator+ (const complex, double);
friend complex operator- (const complex, const complex);
friend complex operator- (double, const complex);
friend complex operator- (const complex, double);
friend complex operator* (const complex, const complex);
friend complex operator* (const complex, double);
friend complex operator* (double, const complex);
friend complex operator/ (const complex, const complex);
friend complex operator/ (const complex, double);
friend complex operator/ (double, const complex);
friend int operator== (const complex, const complex);
friend int operator!= (const complex, const complex);
void operator+= (const complex);
void operator+= (double);
void operator-= (const complex);
void operator-= (double);
void operator*= (const complex);
void operator*= (double);
void operator/= (const complex);
void operator/= (double);
... // remainder not shown here
};
DESCRIPTION
These functions are versions of the normal arithmetic operators over‐
loaded for use with complex numbers.
Unary minus
complex z = - x
Returns the negative of complex x.
Binary arithmetic
complex z = x + y
Returns the sum of x and y, where one or both are complex. The
library provides versions of this function optimized for combi‐
nations of floating-point and complex arguments.
complex z = x - y
Returns the difference of x and y, where one or both are com‐
plex. The library provides versions of this function optimized
for combinations of floating-point and complex arguments.
complex z = x * y
Returns the product of x and y, where one or both are complex.
The library provides versions of this function optimized for
combinations of floating-point and complex arguments.
complex z = x / y
Returns the quotient of x and y, where one or both are complex.
The library provides versions of this function optimized for
combinations of floating-point and complex arguments.
Comparison
Complex numbers are not well-ordered, so only equality can be tested.
x == y Returns 1 if x and y (both complex) are equal, 0 otherwise.
x != y Returns 0 if x and y (both complex) are equal, 1 otherwise.
Assignment
The compiler-generated default assignment operator, complex& opera‐
tor=(const complex&), is appropriate for this type, so it is not rede‐
fined by the class. Note: The compound assignment operators do not
return a value, and so cannot be used in larger expressions. For exam‐
ple, the expression
z = ( x += y );
is valid if x is an integer or floating-point type, but will not com‐
pile if x is complex.
x += y Complex x is incremented by the value of y. The library pro‐
vides versions of this function optimized for floating-point and
complex right-hand arguments.
x -= y Complex x is decremented by the value of y. The library pro‐
vides versions of this function optimized for floating-point and
complex right-hand arguments.
x *= y Complex x is assigned the value of itself multiplied by the
value of y. The library provides versions of this function
optimized for floating-point and complex right-hand arguments.
x /= y Complex x is assigned the value of itself divided by the value
of y. The library provides versions of this function optimized
for floating-point and complex right-hand arguments.
SEE ALSOcplx.intro(3CC4), cartpol(3CC4), cplxerr(3CC4), cplxexp(3CC4), cplx‐
trig(3CC4)
C++ Library Reference Chapter 2, "The Complex Arithmetic Library."
07 August 1997 CPLXOPS(3CC4)