Update contrib.
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // LMATH.CPP - Wrappers for Epoc32 Math functions
26 * Map the Symbian error value to the standard error number and put it into errno.
28 * @param aSymbianReturnValue the standard return value returned from the Symbian function.
29 * @param aNan the result of Math::Nan
31 void MapSymbianErrorCodeToErrno(int aSymbianReturnValue, int aNan)
34 switch(aSymbianReturnValue)
38 //errno does not get set to 0 according to the standard.
39 //The user must initialize it before calling the function.
52 case (KErrTotalLossOfPrecision):
63 Performs the trigonometric arctangent operation on x and returns an angle in the range from -PI/2 to PI/2 expressed in radians.
64 @return Arctangent of arg1.
65 @param arg1 Value whose arctangent has to be calculated.
67 EXPORT_C double atan (double arg1) __SOFTFP
72 returnValue = Math::ATan(result, arg1);
73 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
80 Performs the trigonometric cosine operation on x returning a value between -1 and 1.
81 @return Cosine of arg1.
82 @param arg1 Angle expressed in radians (180 degrees = PI radians).
84 EXPORT_C double cos (double arg1) __SOFTFP
89 returnValue = Math::Cos(result, arg1);
90 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
97 Performs the trigonometric sine operation on x returning a value between -1 and 1.
99 @param arg1 Angle expressed in radians (180 degrees = PI radians).
101 EXPORT_C double sin (double arg1) __SOFTFP
106 returnValue = Math::Sin(result, arg1);
107 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
114 Performs the trigonometric tangent operation on arg1.
115 @return Tangent of arg1.
116 @param arg1 Angle expressed in radians (180 degrees = PI radians).
118 EXPORT_C double tan (double arg1) __SOFTFP
123 returnValue = Math::Tan(result, arg1);
124 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
131 Performs the trigonometric arc cosine operation on x and returns an angle in the range from 0 to PI expressed in radians.
132 @return Arc cosine of arg1.
133 @param arg1 Value between -1 and 1 whose arc cosine has to be calculated.
135 EXPORT_C double acos (double arg1) __SOFTFP
140 returnValue = Math::ACos(result, arg1);
141 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
148 Performs the trigonometric arc sine operation on x and returns an angle in the range from -PI/2 to PI/2 expressed in radians.
149 @return Arc sine of arg1
150 @param arg1 Value between -1 and 1 whose arc sine has to be calculated.
152 EXPORT_C double asin (double arg1) __SOFTFP
157 returnValue = Math::ASin(result, arg1);
158 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
164 Calculate exponential.
165 Returns the exponential value of parameter arg1.
166 @return Exponential of arg1
167 @param arg1 Floating point value.
169 EXPORT_C double exp (double arg1) __SOFTFP
174 returnValue = Math::Exp(result, arg1);
175 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
181 Calculate natural logarithm.
182 Returns the natural logarithm of parameter arg1
183 @return Logarithm of arg1.
184 @param arg1 Floating point value.
186 EXPORT_C double log (double arg1) __SOFTFP
191 returnValue = Math::Ln(result, arg1);
192 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
198 Calculate logarithm base 10.
199 Returns the logarithm base 10 of parameter arg1
200 @return Logarithm base 10 of arg1
201 @param arg1 Floating point value.
203 EXPORT_C double log10 (double arg1) __SOFTFP
208 returnValue = Math::Log(result, arg1);
209 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
215 Calculate square root.
216 Returns the square root of parameter arg1.
217 @return Square root of arg1
218 @param arg1 Non-negative floating point value.
220 EXPORT_C double sqrt (double arg1) __SOFTFP
225 returnValue = Math::Sqrt(result, arg1);
226 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
232 Calculate arctangent, 2 parameters.
233 Performs the trigonometric arctangent operation on y/x and returns an angle in the range from -PI to PI expressed in radians, using the signs of the parameters to determine the quadrant.
234 The result is valid even if arg2 is 0 (angle is PI/2 or -PI/2).
235 In fact this function returns the angle of bidimensional vector (arg2,arg1).
236 @return Arctangent of arg1/arg2.
237 @param arg1 and arg2.Values from whose division has to be calculated the arctangent.i.e.: Coordinates for the vector whose angle is to be calculated.
239 EXPORT_C double atan2 (double arg1, double arg2) __SOFTFP
244 returnValue = Math::ATan(result, arg1, arg2);
245 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
251 Calculate numeric power.
252 Returns arg1 raised to the power of arg2.
253 @return arg1 raised to the power of arg2.
254 @param arg1 - Base value.
255 @param arg2 - Exponent value.
257 EXPORT_C double pow (double arg1, double arg2) __SOFTFP
262 returnValue = Math::Pow(result, arg1, arg2);
263 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
269 Return remainder of floating point division.
270 Performs division arg1/arg2 and returns the remainder of the operation.
271 @return Remainder of arg1/arg2.
272 @param arg1 and arg2 - Floating point values
274 EXPORT_C double fmod (double arg1, double arg2) __SOFTFP
279 returnValue = Math::Mod(result, arg1, arg2);
280 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
286 Round to integral value in floating-point format
287 @return the integral value (represented as a double precision number) nearest to arg1 according to the prevailing rounding mode.
288 @param arg1 floating point value to round.
290 EXPORT_C double rint (double arg1) __SOFTFP
295 returnValue = Math::Round(result, arg1, 0);
296 MapSymbianErrorCodeToErrno(returnValue, Math::IsNaN(result));
302 tests whether d is NaN
303 @return non-zero if d is NaN. Otherwise, 0 is returned.
304 @param d floating point value.
306 EXPORT_C int isnan (double d) __SOFTFP
308 return Math::IsNaN(d);
312 test for infinity or not-a-number
313 @return 1 if the number d is Infinity, otherwise 0.
314 @param d floating point value to test.
316 EXPORT_C int isinf (double d) __SOFTFP
318 return Math::IsInfinite(d);
323 @return a nonzero value if the x parameter is a finite number;
324 that is, if d is not +-, INF, NaNQ, or NaNS.
325 @param d floating point value to test.
327 EXPORT_C int finite (double d) __SOFTFP
329 return Math::IsFinite(d);
332 } // end of extern "C"