This manual page is for Mac OS X version 10.6.3

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • For more information about the manual page format, see the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Reference Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.



CABS(3)                                 BSD Library Functions Manual                                 CABS(3)

NAME
     cabs -- complex norm (absolute value) function
     carg -- complex argument function

SYNOPSIS
     #include <complex.h>

     double
     cabs(double complex z);

     long double
     cabsl(long double complex z);

     float
     cabsf(float complex z);

     double
     carg(double complex z);

     long double
     cargl(long double complex z);

     float
     cargf(float complex z);

DESCRIPTION
     cabs(z) computes the norm (absolute value) of the complex floating-point number z.

     carg(z) computes the argument (also called phase angle) of the complex floating-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 imaginary part of z.

EXAMPLES
     The function foo defined in the example below applies a non-linear rotation 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 coordinates, then computing the trans-formation transformation
     formation in that coordinate system, and finally converting back to the usual rectangular coordinate
     system.

           #include <complex.h>
           #include <math.h>

           double complex foo(double complex z) {
             // get the polar coordinates of z
             double 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;
           }

SPECIAL VALUES
     cabs(x + yi), cabs(y + xi), and cabs(x - yi) are equivalent.  This is used to abbreviate the specifica-tion specification
     tion of special values.

     cabs(x +- _i) is equivalent to fabs(x).

     cabs(+-inf + yi) returns inf even if y is a NaN.

     cabs(x + NaN i) returns NaN, for finite x.

     cabs(NaN + NaN i) returns NaN.

     carg(-_ +- _i) returns +-pi.

     carg(+_ +- _i) returns +-0.

     carg(x +- _i) returns +-pi for x < 0.

     carg(x +- _i) returns +-0 for x > 0.

     carg(+-_ + yi) returns -pi/2 for y < 0.

     carg(+-_ + yi) returns +pi/2 for y > 0.

     carg(-inf +- yi) returns +-pi for finite y > 0.

     carg(+inf +- yi) returns +-0 for finite y > 0.

     carg(x +- inf i) returns +-pi/2 for finite x.

     carg(-inf +- inf i) returns +-3*pi/4.

     carg(+inf +- inf i) returns +-pi/4.

     carg(x + yi) returns NaN if either of x or y is NaN.

NOTES
     cabs() and carg() 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 cabs() and carg() functions conform to ISO/IEC 9899:1999(E).

4th Berkeley Distribution                     December 11, 2006                    4th Berkeley Distribution

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation with the feedback links below.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.

Did this document help you? Yes It's good, but... Not helpful...