OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [math/] [math.tex] - Blame information for rev 297

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
@node Math
2
@chapter Mathematical Functions (@file{math.h})
3
 
4
This chapter groups a wide variety of mathematical functions.  The
5
corresponding definitions and declarations are in @file{math.h}.
6
Two definitions from @file{math.h} are of particular interest.
7
 
8
@enumerate
9
@item
10
The representation of infinity as a @code{double} is defined as
11
@code{HUGE_VAL}; this number is returned on overflow by many functions.
12
The macro @code{HUGE_VALF} is a corresponding value for @code{float}.
13
 
14
@item
15
The structure @code{exception} is used when you write customized error
16
handlers for the mathematical functions.  You can customize error
17
handling for most of these functions by defining your own version of
18
@code{matherr}; see the section on @code{matherr} for details.
19
@end enumerate
20
 
21
@cindex system calls
22
@cindex support subroutines
23
@cindex stubs
24
@cindex OS stubs
25
Since the error handling code calls @code{fputs}, the mathematical
26
subroutines require stubs or minimal implementations for the same list
27
of OS subroutines as @code{fputs}: @code{close}, @code{fstat},
28
@code{isatty}, @code{lseek}, @code{read}, @code{sbrk}, @code{write}.
29
@xref{syscalls,,System Calls, libc.info, The Red Hat newlib C Library},
30
for a discussion and for sample minimal implementations of these support
31
subroutines.
32
 
33
Alternative declarations of the mathematical functions, which exploit
34
specific machine capabilities to operate faster---but generally have
35
less error checking and may reflect additional limitations on some
36
machines---are available when you include @file{fastmath.h} instead of
37
@file{math.h}.
38
 
39
@menu
40
* version::     Version of library
41
* acos::        Arccosine
42
* acosh::       Inverse hyperbolic cosine
43
* asin::        Arcsine
44
* asinh::       Inverse hyperbolic sine
45
* atan::        Arctangent
46
* atan2::       Arctangent of y/x
47
* atanh::       Inverse hyperbolic tangent
48
* jN::          Bessel functions (jN, yN)
49
* cbrt::        Cube root
50
* copysign::    Sign of Y, magnitude of X
51
* cosh::        Hyperbolic cosine
52
* erf::         Error function (erf, erfc)
53
* exp::         Exponential, base e
54
* exp2::        Exponential, base 2
55
* expm1::       Exponential, base e, of x - 1
56
* fabs::        Absolute value (magnitude)
57
* fdim::        Positive difference
58
* floor::       Floor and ceiling (floor, ceil)
59
* fma::         Floating multiply add
60
* fmax::        Maximum
61
* fmin::        Minimum
62
* fmod::        Floating-point remainder (modulo)
63
* fpclassify::  Floating-point classification macro
64
* frexp::       Split floating-point number
65
* gamma::       Logarithmic gamma function
66
* hypot::       Distance from origin
67
* ilogb::       Get exponent
68
* infinity::    Floating infinity
69
* isgreater::   Comparison macros
70
* ldexp::       Scale by a power of 2
71
* log::         Natural logarithms
72
* log10::       Base 10 logarithms
73
* log1p::       Log of 1 + X
74
* log2::        Base 2 logarithms
75
* logb::        Get exponent
76
* lrint::       Round to integer
77
* lround::      Round to integer, away from zero (lround, llround)
78
* matherr::     Modifiable math error handler
79
* modf::        Split fractional and integer parts
80
* nan::         Floating Not a Number
81
* nearbyint::   Round to integer
82
* nextafter::   Get next representable number
83
* pow::         X to the power Y
84
* remainder::   remainder of X divided by Y
85
* remquo::      Remainder and part of quotient
86
* rint::        Round to integer
87
* round::       Round to integer, away from zero
88
* scalbn::      Scale by a power of FLT_RADIX (2)
89
* signbit::     Does floating-point number have negative sign?
90
* sin::         Sine or cosine (sin, cos)
91
* sinh::        Hyperbolic sine
92
* sqrt::        Positive square root
93
* tan::         Tangent
94
* tanh::        Hyperbolic tangent
95
* trunc::       Round to integer, towards zero
96
@end menu
97
 
98
@page
99
@node version
100
@section Error Handling
101
 
102
There are four different versions of the math library routines: IEEE,
103
POSIX, X/Open, or SVID.  The version may be selected at runtime by
104
setting the global variable @code{_LIB_VERSION}, defined in
105
@file{math.h}.  It may be set to one of the following constants defined
106
in @file{math.h}: @code{_IEEE_}, @code{_POSIX_}, @code{_XOPEN_}, or
107
@code{_SVID_}.  The @code{_LIB_VERSION} variable is not specific to any
108
thread, and changing it will affect all threads.
109
 
110
The versions of the library differ only in how errors are handled.
111
 
112
In IEEE mode, the @code{matherr} function is never called, no warning
113
messages are printed, and @code{errno} is never set.
114
 
115
In POSIX mode, @code{errno} is set correctly, but the @code{matherr}
116
function is never called and no warning messages are printed.
117
 
118
In X/Open mode, @code{errno} is set correctly, and @code{matherr} is
119
called, but warning message are not printed.
120
 
121
In SVID mode, functions which overflow return 3.40282346638528860e+38,
122
the maximum single-precision floating-point value, rather than infinity.
123
Also, @code{errno} is set correctly, @code{matherr} is called, and, if
124
@code{matherr} returns 0, warning messages are printed for some errors.
125
For example, by default @samp{log(-1.0)} writes this message on standard
126
error output:
127
 
128
@example
129
log: DOMAIN error
130
@end example
131
 
132
The library is set to X/Open mode by default.
133
 
134
The aforementioned error reporting is the supported Newlib libm error
135
handling method.  However, the majority of the functions are written
136
so as to produce the floating-point exceptions (e.g. "invalid",
137
"divide-by-zero") as required by the C and POSIX standards, for
138
floating-point implementations that support them.  Newlib does not provide
139
the floating-point exception access routines defined in the standards
140
for fenv.h, though, which is why they are considered unsupported.  It is
141
mentioned in case you have separately-provided access routines so that
142
you are aware that they can be caused.
143
 
144
@section Standards Compliance And Portability
145
Most of the individual function descriptions describe the standards to which
146
each function complies.  However, these descriptions are mostly out of date,
147
having been written before C99 was released.  One of these days we'll get
148
around to updating the rest of them.  (If you'd like to help, please let us
149
know.)
150
 
151
``C99'' refers to ISO/IEC 9899:1999, ``Programming languages--C''.
152
``POSIX'' refers to IEEE Standard 1003.1.  POSIX@registeredsymbol{} is a
153
registered trademark of The IEEE.
154
 
155
@c To sort the include list easily, keep the indentation right because want to
156
@c skip the s_|w_ at the start of most--but not all--of the file names.
157
@c (e.g., isgreater.def does not have a leading s nor w.)  Then, sort
158
@c based on the column.  For example:  "sort -t@ -k3.17"
159
@c A few hand-edits might be appropriate after a sort, although not necessary
160
@c and are a nuisance as ought to be kept in sync with menu list above:
161
@c atan2 after atan, exp2 after exp, log first in log list, and w_j0 to place
162
@c to reflect function name of Bessel (as opposed to j; e.g. after atanh,
163
@c before cbrt).
164
 
165
@page @include   math/w_acos.def
166
@page @include   math/w_acosh.def
167
@page @include   math/w_asin.def
168
@page @include   math/s_asinh.def
169
@page @include   math/s_atan.def
170
@page @include   math/w_atan2.def
171
@page @include   math/w_atanh.def
172
@page @include   math/w_j0.def
173
@page @include common/s_cbrt.def
174
@page @include common/s_copysign.def
175
@page @include   math/w_cosh.def
176
@page @include   math/s_erf.def
177
@page @include   math/w_exp.def
178
@page @include   math/w_exp2.def
179
@page @include common/s_expm1.def
180
@page @include   math/s_fabs.def
181
@page @include common/s_fdim.def
182
@page @include   math/s_floor.def
183
@page @include common/s_fma.def
184
@page @include common/s_fmax.def
185
@page @include common/s_fmin.def
186
@page @include   math/w_fmod.def
187
@page @include   math/s_frexp.def
188
@page @include   math/w_gamma.def
189
@page @include   math/w_hypot.def
190
@page @include common/s_ilogb.def
191
@page @include common/s_infinity.def
192
@page @include   common/isgreater.def
193
@page @include common/s_isnan.def
194
@page @include   math/s_ldexp.def
195
@page @include   math/w_log.def
196
@page @include   math/w_log10.def
197
@page @include common/s_log1p.def
198
@page @include common/s_log2.def
199
@page @include common/s_logb.def
200
@page @include common/s_lrint.def
201
@page @include common/s_lround.def
202
@page @include common/s_matherr.def
203
@page @include common/s_modf.def
204
@page @include common/s_nan.def
205
@page @include common/s_nearbyint.def
206
@page @include common/s_nextafter.def
207
@page @include   math/w_pow.def
208
@page @include   math/w_remainder.def
209
@page @include common/s_remquo.def
210
@page @include common/s_rint.def
211
@page @include common/s_round.def
212
@page @include common/s_scalbn.def
213
@page @include common/s_signbit.def
214
@page @include   math/s_sin.def
215
@page @include   math/w_sinh.def
216
@page @include   math/w_sqrt.def
217
@page @include   math/s_tan.def
218
@page @include   math/s_tanh.def
219
@page @include common/s_trunc.def

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.