xref: /netbsd-src/lib/libm/ld128/k_cospil.h (revision cfe182f36bde4c4d81e1607954ce22a67cf35d7a)
1*cfe182f3Schristos /*-
2*cfe182f3Schristos  * Copyright (c) 2017 Steven G. Kargl
3*cfe182f3Schristos  * All rights reserved.
4*cfe182f3Schristos  *
5*cfe182f3Schristos  * Redistribution and use in source and binary forms, with or without
6*cfe182f3Schristos  * modification, are permitted provided that the following conditions
7*cfe182f3Schristos  * are met:
8*cfe182f3Schristos  * 1. Redistributions of source code must retain the above copyright
9*cfe182f3Schristos  *    notice unmodified, this list of conditions, and the following
10*cfe182f3Schristos  *    disclaimer.
11*cfe182f3Schristos  * 2. Redistributions in binary form must reproduce the above copyright
12*cfe182f3Schristos  *    notice, this list of conditions and the following disclaimer in the
13*cfe182f3Schristos  *    documentation and/or other materials provided with the distribution.
14*cfe182f3Schristos  *
15*cfe182f3Schristos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*cfe182f3Schristos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*cfe182f3Schristos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*cfe182f3Schristos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*cfe182f3Schristos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*cfe182f3Schristos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*cfe182f3Schristos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*cfe182f3Schristos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*cfe182f3Schristos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*cfe182f3Schristos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*cfe182f3Schristos  */
26*cfe182f3Schristos 
27*cfe182f3Schristos /*
28*cfe182f3Schristos  * See ../src/k_cospi.c for implementation details.
29*cfe182f3Schristos  */
30*cfe182f3Schristos 
31*cfe182f3Schristos static inline long double
__kernel_cospil(long double x)32*cfe182f3Schristos __kernel_cospil(long double x)
33*cfe182f3Schristos {
34*cfe182f3Schristos 	long double hi, lo;
35*cfe182f3Schristos 
36*cfe182f3Schristos 	hi = (double)x;
37*cfe182f3Schristos 	lo = x - hi;
38*cfe182f3Schristos 	lo = lo * (pi_lo + pi_hi) + hi * pi_lo;
39*cfe182f3Schristos 	hi *= pi_hi;
40*cfe182f3Schristos 	_2sumF(hi, lo);
41*cfe182f3Schristos 	return (__kernel_cosl(hi, lo));
42*cfe182f3Schristos }
43