xref: /openbsd-src/lib/libm/src/s_cabs.c (revision 2f2c00629eff6a304ebffb255fc56f4fa7a1833b)
1*2f2c0062Sguenther /*	$OpenBSD: s_cabs.c,v 1.7 2016/09/12 19:47:02 guenther Exp $	*/
27b36286aSmartynas /*
37b36286aSmartynas  * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org>
47b36286aSmartynas  *
57b36286aSmartynas  * Permission to use, copy, modify, and distribute this software for any
67b36286aSmartynas  * purpose with or without fee is hereby granted, provided that the above
77b36286aSmartynas  * copyright notice and this permission notice appear in all copies.
87b36286aSmartynas  *
97b36286aSmartynas  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
107b36286aSmartynas  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
117b36286aSmartynas  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
127b36286aSmartynas  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
137b36286aSmartynas  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
147b36286aSmartynas  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
157b36286aSmartynas  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167b36286aSmartynas  */
177b36286aSmartynas 
187b36286aSmartynas #include <complex.h>
19de3697aaSmartynas #include <float.h>
207b36286aSmartynas #include <math.h>
217b36286aSmartynas 
227b36286aSmartynas double
cabs(double complex z)237b36286aSmartynas cabs(double complex z)
247b36286aSmartynas {
257b36286aSmartynas 	return hypot(__real__ z, __imag__ z);
267b36286aSmartynas }
27*2f2c0062Sguenther DEF_STD(cabs);
28*2f2c0062Sguenther LDBL_MAYBE_CLONE(cabs);
29