comparison packages/language/c/libm/current/include/complex.h @ 3337:77f9d3253c3e

Add: Complex number header and library (single and double precision floating point), port from Newlib. Add: Single precision floating point library, port from Newlib. [ Bugzilla 1001539 ]
author vae
date Sun, 25 Aug 2013 14:38:57 +0000
parents
children
comparison
equal deleted inserted replaced
3336:8ecac279f33c 3337:77f9d3253c3e
1 #ifndef CYGONCE_COMPLEX_H
2 #define CYGONCE_COMPLEX_H
3
4 //===========================================================================
5 //
6 // complex.h
7 //
8 // Standard complex number functions conforming to ANSI and other standards
9 //
10 //===========================================================================
11 // ####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 2013 Free Software Foundation, Inc.
15 //
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later
19 // version.
20 //
21 // eCos is distributed in the hope that it will be useful, but WITHOUT
22 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 // for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with eCos; if not, write to the Free Software Foundation, Inc.,
28 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 //
30 // As a special exception, if other files instantiate templates or use
31 // macros or inline functions from this file, or you compile this file
32 // and link it with other works to produce a work based on this file,
33 // this file does not by itself cause the resulting work to be covered by
34 // the GNU General Public License. However the source code for this file
35 // must still be made available in accordance with section (3) of the GNU
36 // General Public License v2.
37 //
38 // This exception does not invalidate any other reasons why a work based
39 // on this file might be covered by the GNU General Public License.
40 // -------------------------------------------
41 // ####ECOSGPLCOPYRIGHTEND####
42 //===========================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s): ilijak
46 // Based on: see below
47 // Contributors:
48 // Date: 2013-06-05
49 // Purpose:
50 // Description: Standard complex number mathematical functions.
51 //
52 // Usage: #include <complex.h>
53 //
54 //####DESCRIPTIONEND####
55 //
56 //===========================================================================
57
58 // This file was derived from a file with following copyright
59
60 /* $NetBSD: complex.h,v 1.3 2010/09/15 16:11:30 christos Exp $ */
61
62 /*
63 * Written by Matthias Drochner.
64 * Public domain.
65 */
66
67 #ifndef _COMPLEX_H
68 #define _COMPLEX_H
69 #endif
70
71 #define complex _Complex
72 #define _Complex_I (1.0fi)
73 #define I _Complex_I
74
75 // 7.3.5 Trigonometric functions
76 // 7.3.5.1 The cacos functions
77 double complex cacos(double complex);
78 float complex cacosf(float complex);
79
80 // 7.3.5.2 The casin functions
81 double complex casin(double complex);
82 float complex casinf(float complex);
83
84 // 7.3.5.1 The catan functions
85 double complex catan(double complex);
86 float complex catanf(float complex);
87
88 // 7.3.5.1 The ccos functions
89 double complex ccos(double complex);
90 float complex ccosf(float complex);
91
92 // 7.3.5.1 The csin functions
93 double complex csin(double complex);
94 float complex csinf(float complex);
95
96 // 7.3.5.1 The ctan functions
97 double complex ctan(double complex);
98 float complex ctanf(float complex);
99
100 // 7.3.6 Hyperbolic functions
101 // 7.3.6.1 The cacosh functions
102 double complex cacosh(double complex);
103 float complex cacoshf(float complex);
104
105 // 7.3.6.2 The casinh functions
106 double complex casinh(double complex);
107 float complex casinhf(float complex);
108
109 // 7.3.6.3 The catanh functions
110 double complex catanh(double complex);
111 float complex catanhf(float complex);
112
113 // 7.3.6.4 The ccosh functions
114 double complex ccosh(double complex);
115 float complex ccoshf(float complex);
116
117 // 7.3.6.5 The csinh functions
118 double complex csinh(double complex);
119 float complex csinhf(float complex);
120
121 // 7.3.6.6 The ctanh functions
122 double complex ctanh(double complex);
123 float complex ctanhf(float complex);
124
125 // 7.3.7 Exponential and logarithmic functions
126 // 7.3.7.1 The cexp functions
127 double complex cexp(double complex);
128 float complex cexpf(float complex);
129
130 // 7.3.7.2 The clog functions
131 double complex clog(double complex);
132 float complex clogf(float complex);
133
134 // 7.3.9 Manipulation functions
135 // 7.3.9.2 The cimag functions
136 double cimag(double complex);
137 float cimagf(float complex);
138 //long double cimagl(long double complex);
139
140 // 7.3.9.3 The conj functions
141 double complex conj(double complex);
142 float complex conjf(float complex);
143 //long double complex conjl(long double complex);
144
145 // 7.3.9.4 The cproj functions
146 double complex cproj(double complex);
147 float complex cprojf(float complex);
148 //long double complex cprojl(long double complex);
149
150 // 7.3.9.5 The creal functions
151 double creal(double complex);
152 float crealf(float complex);
153 //long double creall(long double complex);
154
155 // 7.3.9.1 The carg functions
156 #ifdef CYGSEM_LIBM_IEEE_API_INLINE
157 CYGBLD_FORCE_INLINE double
158 carg(double complex z)
159 {
160 return atan2( cimag(z) , creal(z) );
161 }
162
163 CYGBLD_FORCE_INLINE float
164 cargf(float complex z)
165 {
166 return atan2f( cimagf(z) , crealf(z) );
167 }
168 #else
169 double carg(double complex);
170 float cargf(float complex);
171 #endif
172
173 // 7.3.8 Power and absolute-value functions
174 // 7.3.8.1 The cabs functions
175 #ifdef CYGSEM_LIBM_IEEE_API_INLINE
176 CYGBLD_FORCE_INLINE double
177 cabs(double complex z)
178 {
179 return hypot( creal(z) , cimag(z) );
180 }
181
182 CYGBLD_FORCE_INLINE float
183 cabsf(float complex z)
184 {
185 return hypotf( crealf(z) , cimagf(z) );
186 }
187 #else
188 double cabs(double complex) ;
189 float cabsf(float complex) ;
190 #endif
191
192 // 7.3.8.2 The cpow functions
193 double complex cpow(double complex, double complex);
194 float complex cpowf(float complex, float complex);
195
196 // 7.3.8.3 The csqrt functions
197 double complex csqrt(double complex);
198 float complex csqrtf(float complex);
199
200 #endif //CYGONCE_COMPLEX_H
201
202 // End of complex.h