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