2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseUtilMath.h
19 * @brief This is the header file for the %Math class.
21 * This header file contains the declarations of the %Math class.
23 #ifndef _FBASE_UTIL_MATH_H_
24 #define _FBASE_UTIL_MATH_H_
26 #include <FBaseTypes.h>
28 namespace Tizen { namespace Base { namespace Utility
32 * @brief This class is the wrapper class for %Math Library.
36 * The %Math class provides various mathematical methods.
38 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/utility_namespace.htm">Utility</a>.
40 * The following example demonstrates how to use the %Math class.
45 * using namespace Tizen::Base::Utility;
48 * MyClass::MathSample(void)
50 * double radius = 5.0;
52 * double area = Math::GetPi() * Math::Pow(radius, 2.0L);
57 class _OSP_EXPORT_ Math
61 * Gets the absolute value of the specified integer.
65 * @return The absolute value of the specified integer
66 * @param[in] x An integer value
68 static int Abs(int x);
71 * Gets the arc sine of the specified @c double integer. @n
72 * Returns a value between @c -PI/2 and @c PI/2.
76 * @return The arc sine of the input, @n
77 * else Not-a-Number if @c x is out of range
78 * @param[in] x A radian angle @n
79 * It must be within the range @c -1 to @c 1 (inclusive).
83 static double Asin(double x);
86 * Gets the arc cosine of the specified double integer. @n
87 * Returns a value between @c 0 and @c PI.
91 * @return The arc cosine of the input, @n
92 * else Not-a-Number if @c x is out of range
93 * @param[in] x A radian angle @n
94 * It must be within the range @c -1 to @c 1 (inclusive).
98 static double Acos(double x);
101 * Gets the arc tangent of the specified @c double integer. @n
102 * Returns a value between @c -PI/2 and @c PI/2.
106 * @return The arc tangent of the input
107 * @param[in] x A radian angle
111 static double Atan(double x);
114 * Gets the smallest integer that is greater than or equal to the specified @c double integer. @n
115 * For example, if @c x is @c 3.9, Ceiling(double) returns @c 4.0. @n
116 * The returned value is an integer but the type is @c double.
120 * @return The smallest integer that is greater than or equal to the input
121 * @param[in] x A floating point value
123 static double Ceiling(double x);
126 * Gets the cosine of the specified @c double integer. @n
127 * Returns a value between @c -1 and @c 1.
131 * @return The cosine of the input
132 * @param[in] x A radian angle
136 static double Cos(double x);
139 * Gets the hyperbolic cosine of the specified @c double integer.
143 * @return The hyperbolic cosine of the input
144 * @param[in] x A radian angle
146 static double Cosh(double x);
149 * Gets the exponential value of the specified @c double integer.
153 * @return The exponential value of the input
154 * @param[in] x A floating point value
156 static double Exp(double x);
159 * Gets the largest integer that is less than or equal to the input. @n
160 * For example, if @c x is @c 3.3 then Floor(double) returns @c 3.0. @n
161 * The returned value is an integer but the type is @c double.
165 * @return The largest @c double integer that is less than or equal to the input
166 * @param[in] x A floating point value
168 static double Floor(double x);
171 * Gets the natural logarithm of the specified number.
175 * @return The natural logarithm of the input
176 * @param[in] x A floating point value
178 static double Log(double x);
181 * Gets the logarithm to the base 10 of the specified number.
185 * @return The logarithm to the base 10 of the input
186 * @param[in] x A floating point value
188 static double Log10(double x);
191 * Gets the greater of the two specified integer values. @n
192 * If both inputs have the same value, this method returns the same value.
196 * @return The greater of the two integer values
197 * @param[in] x An integer value
198 * @param[in] y An integer value
201 static int Max(int x, int y);
204 * Gets the greater of the two floating point values. @n
205 * If both inputs have the same value, this method returns the same value. @n
206 * If either value is not a valid number, then this method returns Not-a-Number.
210 * @return The greater of the two floating point values
211 * @param[in] x A floating point value
212 * @param[in] y A floating point value
215 static double Max(double x, double y);
218 * Gets the smaller of the two integer values. @n
219 * If both inputs have the same value, this method returns the same value.
223 * @return The smaller of the two integer values
224 * @param[in] x An integer value
225 * @param[in] y An integer value
228 static int Min(int x, int y);
231 * Gets the smaller of the two @c double values. @n
232 * If both inputs have the same value, this method returns the same value. @n
233 * If either value is not a valid number, this method returns Not-a-Number.
237 * @return The smaller of the two @c double values
238 * @param[in] x A floating point value
239 * @param[in] y A floating point value
242 static double Min(double x, double y);
245 * Gets the value of @c x raised to the power of @c y.
249 * @return @c x raised to the power of @c y, @n
250 * else Not-a-Number if @c x and @c y do not satisfy the conditions described below
251 * @param[in] x A floating point value
252 * @param[in] y A floating point value
253 * @remarks @li @c x cannot be negative if @c y is a fractional value.
254 * @li @c x cannot be @c 0 if @c y is less than or equal to @c 0.
256 static double Pow(double x, double y);
259 * Gets the nearest integer to the specified number.
263 * @return The closest integer to the specified input
264 * @param[in] x A floating point value
266 static double Round(double x);
269 * Gets the sine of the specified @c double integer. @n
270 * Returns a value between @c -1 and @c 1.
274 * @return The sine of the input
275 * @param[in] x A radian angle
279 static double Sin(double x);
282 * Gets the hyperbolic sine of the specified @c double integer.
286 * @return The hyperbolic sine of the input
287 * @param[in] x A radian angle
289 static double Sinh(double x);
292 * Gets the square root of the specified number.
296 * @return The square root of the input, @n
297 * else Not-a-Number if @c x is a negative number
298 * @param[in] x A non-negative floating point value
300 static double Sqrt(double x);
303 * Gets the tangent of the specified @c double integer.
307 * @return The tangent of the input
308 * @param[in] x A radian angle
312 static double Tan(double x);
315 * Gets the hyperbolic tangent of the specified @c double integer.
319 * @return The hyperbolic tangent of the input
320 * @param[in] x A radian angle
322 static double Tanh(double x);
326 * Initializes a random number generator.
330 * @param[in] seed An integer value to use as seed by the pseudo-random number generator algorithm
333 static void Srand(unsigned int seed);
337 * Gets a random integral number in the range @c 0 to @c RAND_VALUE_MAX.
341 * @return An integer value between @c 0 and @c RAND_VALUE_MAX
342 * @remarks This method uses a seed to generate the pseudo-random numbers, that must be initialized to some distinctive value using Srand().
345 static int Rand(void);
348 * Gets the constant value of E (the base of natural logarithms).
352 * @return The constant value of E
354 static const double GetE(void);
357 * Gets the constant value of PI.
361 * @return The constant value of PI
363 static const double GetPi(void);
366 * The maximum value that can be returned by the Rand() method.
370 static const int RAND_VALUE_MAX = 32767; // 0x7fff
375 * This default constructor is intentionally declared as private because this class cannot be constructed.
380 * This destructor is intentionally declared as private because this class cannot be constructed.
385 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
387 * @param[in] rhs The instance of the Math
389 Math(const Math& rhs);
392 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
394 * @param[in] rhs An instance of %Math
396 Math& operator =(const Math& rhs);
399 }}} // Tizen::Base::Utility
401 #endif // _FBASE_UTIL_MATH_H_