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