]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sincos.3
10296767958b162b7868c0293c24dace0eb969ee
[thirdparty/man-pages.git] / man3 / sincos.3
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\"
7 .TH SINCOS 3 2021-03-22 "GNU" "Linux Programmer's Manual"
8 .SH NAME
9 sincos, sincosf, sincosl \- calculate sin and cos simultaneously
10 .SH LIBRARY
11 Math library
12 .RI ( libm ", " \-lm )
13 .SH SYNOPSIS
14 .nf
15 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
16 .B #include <math.h>
17 .PP
18 .BI "void sincos(double " x ", double *" sin ", double *" cos );
19 .BI "void sincosf(float " x ", float *" sin ", float *" cos );
20 .BI "void sincosl(long double " x ", long double *" sin ", long double *" cos );
21 .fi
22 .SH DESCRIPTION
23 Several applications need sine and cosine of the same angle
24 .IR x .
25 These functions compute both at the same time, and store the results in
26 .I *sin
27 and
28 .IR *cos .
29 Using this function can be more efficient than two separate calls to
30 .BR sin (3)
31 and
32 .BR cos (3).
33 .PP
34 If
35 .I x
36 is a NaN,
37 a NaN is returned in
38 .I *sin
39 and
40 .IR *cos .
41 .PP
42 If
43 .I x
44 is positive infinity or negative infinity,
45 a domain error occurs, and
46 a NaN is returned in
47 .I *sin
48 and
49 .IR *cos .
50 .SH RETURN VALUE
51 These functions return
52 .IR void .
53 .SH ERRORS
54 See
55 .BR math_error (7)
56 for information on how to determine whether an error has occurred
57 when calling these functions.
58 .PP
59 The following errors can occur:
60 .TP
61 Domain error: \fIx\fP is an infinity
62 .I errno
63 is set to
64 .BR EDOM
65 (but see BUGS).
66 An invalid floating-point exception
67 .RB ( FE_INVALID )
68 is raised.
69 .SH VERSIONS
70 These functions first appeared in glibc in version 2.1.
71 .SH ATTRIBUTES
72 For an explanation of the terms used in this section, see
73 .BR attributes (7).
74 .ad l
75 .nh
76 .TS
77 allbox;
78 lbx lb lb
79 l l l.
80 Interface Attribute Value
81 T{
82 .BR sincos (),
83 .BR sincosf (),
84 .BR sincosl ()
85 T} Thread safety MT-Safe
86 .TE
87 .hy
88 .ad
89 .sp 1
90 .SH CONFORMING TO
91 These functions are GNU extensions.
92 .SH NOTES
93 To see the performance advantage of
94 .BR sincos (),
95 it may be necessary to disable
96 .BR gcc (1)
97 built-in optimizations, using flags such as:
98 .PP
99 .in +4n
100 .EX
101 cc \-O \-lm \-fno\-builtin prog.c
102 .EE
103 .in
104 .SH BUGS
105 Before version 2.22, the glibc implementation did not set
106 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=15467
107 .I errno
108 to
109 .B EDOM
110 when a domain error occurred.
111 .SH SEE ALSO
112 .BR cos (3),
113 .BR sin (3),
114 .BR tan (3)