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