Visit The New, Modern Unix Linux Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #780
Difficulty: Easy
Bill Gates was born in Seattle, Washington, on October 28, 1945.
True or False?
Linux & Unix Commands - Search Man Pages

cabs(3) [opendarwin man page]

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

NAME
cabs -- complex absolute value function SYNOPSIS
#include <math.h> struct {double x, y;} z; double cabs(z); DESCRIPTION
The cabs() function computes the complex absolute value (also called norm, modulus, or magnitude) of z, without undue underflow or overflow. It is specified by cabs(x+iy) = hypot(x, y) SEE ALSO
hypot(3), math(3), sqrt(3), cabsf STANDARDS
The cabs() function conforms to ISO/IEC 9899:1999(E). 4th Berkeley Distribution January 28, 2003 4th Berkeley Distribution

Check Out this Related Man Page

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 transformation 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 specification of special values. cabs(x +- 0i) 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(-0 +- 0i) returns +-pi. carg(+0 +- 0i) returns +-0. carg(x +- 0i) returns +-pi for x < 0. carg(x +- 0i) returns +-0 for x > 0. carg(+-0 + yi) returns -pi/2 for y < 0. carg(+-0 + 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:2011. 4th Berkeley Distribution December 11, 2006 4th Berkeley Distribution

4 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

USB Flash Drives

Can Solaris/any GNU/Linux distros/ any flavor of FreeBSD be booted, right from aUSB flash drive? Mine's the one pictured here. SanDisk | Products | USB Flash Drives | SanDisk CruzerŽ Titanium Plus USB Flash Drive Also, on a completely unrelated note (just so I don't have to fill up forum... (4 Replies)
Discussion started by: led3234
4 Replies

2. Shell Programming and Scripting

wget skips certain files.

I am trying to use wget to automate downloading of some mp3/wav files. However, I can't get it to follow the link to the mp3s. This is the line (it is not really the website): wget -prl 1 http://website.com/alarmsHowever, if I right-click and copy the link on the webpage in firefox, then... (4 Replies)
Discussion started by: Narnie
4 Replies

3. UNIX for Dummies Questions & Answers

Grep

my file has one line abcdedabxxxxabxxxab I want to know the #occurrences of substring ab and their positions Following command gives me >grep ab -o file|wc 4 4 12 Is the first 4, the number of occurrences of ab? what are other numbers. Can I get their positions in a one... (8 Replies)
Discussion started by: prak705
8 Replies

4. Shell Programming and Scripting

Perl:: mass replacement of converting C code formats to tgmath.h

hello, i have a lot of C old code I'm updating to C11 with tgmath.h for generic math. the old code has very specific types, real and complex, like cabsl, csinhl, etc usually for simple bulk replacements i would do something simple like this perl -pi -e 's/cosl/cos/g' *.c the reference... (0 Replies)
Discussion started by: f77hack
0 Replies

Featured Tech Videos