Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cabs.c « complex « libm « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2750fab9a1c1f4d240c357004a3cacfcac492951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */

/*
 * Written by Matthias Drochner <drochner@NetBSD.org>.
 * Public domain.
 *
 * imported and modified include for newlib 2010/10/03 
 * Marco Atzeri <marco_atzeri@yahoo.it>
 */

/*
FUNCTION
        <<cabs>>, <<cabsf>>---complex absolute-value

INDEX
        cabs
INDEX
        cabsf

ANSI_SYNOPSIS
       #include <complex.h>
       double cabs(double complex <[z]>);
       float cabsf(float complex <[z]>);


DESCRIPTION
        These functions compute compute the complex absolute value 
        (also called norm, modulus, or magnitude) of <[z]>. 

        <<cabsf>> is identical to <<cabs>>, except that it performs
        its calculations on <<floats complex>>.

RETURNS
        The cabs functions return the complex absolute value.

PORTABILITY
        <<cabs>> and <<cabsf>> are ISO C99

QUICKREF
        <<cabs>> and <<cabsf>> are ISO C99

*/


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

double
cabs(double complex z)
{

	return hypot( creal(z), cimag(z) );
}