NAME
ccaabbss - complex norm (absolute value) function
ccaarrgg - complex argument function
SYNOPSIS
##iinncclluuddee <
double ccaabbss(double complex z); long double ccaabbssll(long double complex z); float ccaabbssff(float complex z); double ccaarrgg(double complex z); long double ccaarrggll(long double complex z); float ccaarrggff(float complex z);> DESCRIPTION
ccaabbss(z) computes the norm (absolute value) of the complex floating-point
number z. ccaarrgg(z) computes the argument (also called phase angle) of the complexfloating-point number z, with a branch cut on the negative real axis.
The result is in the range [-pi, pi], and has the same sign as the imagi-
nary part of z. EEXXAAMMPPLLEESSThe function foo defined in the example below applies a non-linear rota-
tion to the complex plane, such that points near the origin are not much affected, and points far from the origin are rotated by about pi/2.This is accomplished by using cabs and carg to convert to polar coordi-
nates, then computing the transformation in that coordinate system, and finally converting back to the usual rectangular coordinate system.#include
#include
double complex foo(double complex z) { // get the polar coordinates of zdouble r = cabs(z);
double theta = carg(z); // add a value dependent on r to theta theta += atan(r); // now change back to rectangular coordinates and // return the new complex number return r*cos(theta) + r*sin(theta)*I; } SSPPEECCIIAALL VVAALLUUEESSccaabbss(x + yi), ccaabbss(y + xi), and ccaabbss(x - yi) are equivalent. This is
used to abbreviate the specification of special values.ccaabbss(x +- 0i) is equivalent to ffaabbss(x).
ccaabbss(+-inf + yi) returns inf even if y is a NaN.
ccaabbss(x + NaN i) returns NaN, for finite x. ccaabbss(NaN + NaN i) returns NaN.ccaarrgg(-0 +- 0i) returns +-pi.
ccaarrgg(+0 +- 0i) returns +-0.
ccaarrgg(x +- 0i) returns +-pi for x < 0.
ccaarrgg(x +- 0i) returns +-0 for x > 0.
ccaarrgg(+-0 + yi) returns -pi/2 for y < 0.
ccaarrgg(+-0 + yi) returns +pi/2 for y > 0.
ccaarrgg(-inf +- yi) returns +-pi for finite y > 0.
ccaarrgg(+inf +- yi) returns +-0 for finite y > 0.
ccaarrgg(x +- inf i) returns +-pi/2 for finite x.
ccaarrgg(-inf +- inf i) returns +-3*pi/4.
ccaarrgg(+inf +- inf i) returns +-pi/4.
ccaarrgg(x + yi) returns NaN if either of x or y is NaN. NNOOTTEESS ccaabbss() and ccaarrgg() are fully specified in terms of real functions:cabs(x + iy) = hypot(x,y)
carg(x + iy) = atan2(y,x).SEE ALSO
hypot(3), atan2(3), fabs(3), complex(3) STANDARDS The ccaabbss() and ccaarrgg() functions conform to ISO/IEC 9899:1999(E). 4th Berkeley Distribution October 10, 2006 4th Berkeley Distribution