source: trunk/libs/newlib/src/newlib/libm/complex/cabs.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/* $NetBSD: cabs.c,v 1.1 2007/08/20 16:01:30 drochner Exp $ */
2
3/*
4 * Written by Matthias Drochner <drochner@NetBSD.org>.
5 * Public domain.
6 *
7 * imported and modified include for newlib 2010/10/03
8 * Marco Atzeri <marco_atzeri@yahoo.it>
9 */
10
11/*
12FUNCTION
13        <<cabs>>, <<cabsf>>, <<cabsl>>---complex absolute-value
14
15INDEX
16        cabs
17INDEX
18        cabsf
19INDEX
20        cabsl
21
22SYNOPSIS
23       #include <complex.h>
24       double cabs(double complex <[z]>);
25       float cabsf(float complex <[z]>);
26       long double cabsl(long double complex <[z]>);
27
28
29DESCRIPTION
30        These functions compute compute the complex absolute value
31        (also called norm, modulus, or magnitude) of <[z]>.
32
33        <<cabsf>> is identical to <<cabs>>, except that it performs
34        its calculations on <<float complex>>.
35
36        <<cabsl>> is identical to <<cabs>>, except that it performs
37        its calculations on <<long double complex>>.
38
39RETURNS
40        The cabs* functions return the complex absolute value.
41
42PORTABILITY
43        <<cabs>>, <<cabsf>> and <<cabsl>> are ISO C99
44
45QUICKREF
46        <<cabs>>, <<cabsf>> and <<cabsl>> are ISO C99
47
48*/
49
50
51#include <complex.h>
52#include <math.h>
53
54double
55cabs(double complex z)
56{
57
58        return hypot( creal(z), cimag(z) );
59}
Note: See TracBrowser for help on using the repository browser.