xref: /netbsd/lib/libm/complex/cacosl.c (revision 5e0f17b2)
1*5e0f17b2Schristos /* $NetBSD: cacosl.c,v 1.1 2014/10/10 00:48:18 christos Exp $ */
2*5e0f17b2Schristos 
3*5e0f17b2Schristos /*-
4*5e0f17b2Schristos  * Copyright (c) 2007 The NetBSD Foundation, Inc.
5*5e0f17b2Schristos  * All rights reserved.
6*5e0f17b2Schristos  *
7*5e0f17b2Schristos  * This code is derived from software written by Stephen L. Moshier.
8*5e0f17b2Schristos  * It is redistributed by the NetBSD Foundation by permission of the author.
9*5e0f17b2Schristos  *
10*5e0f17b2Schristos  * Redistribution and use in source and binary forms, with or without
11*5e0f17b2Schristos  * modification, are permitted provided that the following conditions
12*5e0f17b2Schristos  * are met:
13*5e0f17b2Schristos  * 1. Redistributions of source code must retain the above copyright
14*5e0f17b2Schristos  *    notice, this list of conditions and the following disclaimer.
15*5e0f17b2Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16*5e0f17b2Schristos  *    notice, this list of conditions and the following disclaimer in the
17*5e0f17b2Schristos  *    documentation and/or other materials provided with the distribution.
18*5e0f17b2Schristos  *
19*5e0f17b2Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*5e0f17b2Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*5e0f17b2Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*5e0f17b2Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*5e0f17b2Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*5e0f17b2Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*5e0f17b2Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*5e0f17b2Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*5e0f17b2Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*5e0f17b2Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*5e0f17b2Schristos  * POSSIBILITY OF SUCH DAMAGE.
30*5e0f17b2Schristos  */
31*5e0f17b2Schristos 
32*5e0f17b2Schristos #include "../src/namespace.h"
33*5e0f17b2Schristos #include <complex.h>
34*5e0f17b2Schristos #include <math.h>
35*5e0f17b2Schristos #include "cephes_subrl.h"
36*5e0f17b2Schristos 
37*5e0f17b2Schristos long double complex
cacosl(long double complex z)38*5e0f17b2Schristos cacosl(long double complex z)
39*5e0f17b2Schristos {
40*5e0f17b2Schristos 	long double complex w;
41*5e0f17b2Schristos 
42*5e0f17b2Schristos 	w = casinl(z);
43*5e0f17b2Schristos 	w = (M_PI_2L - creall(w)) - cimagl(w) * I;
44*5e0f17b2Schristos 	return w;
45*5e0f17b2Schristos }
46