OS_NS_math.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_NS_math.h
00006  *
00007  *  $Id: OS_NS_math.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  *  @author Jesper S. M|ller<stophph@diku.dk>
00011  *  @author and a cast of thousands...
00012  *
00013  *  Originally in OS.h.
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_OS_NS_MATH_H
00018 # define ACE_OS_NS_MATH_H
00019 
00020 # include /**/ "ace/pre.h"
00021 
00022 # include "ace/config-all.h"
00023 
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 #  pragma once
00026 # endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "ace/os_include/os_math.h"
00029 
00030 #include /**/ "ace/ACE_export.h"
00031 
00032 #if defined (ACE_EXPORT_MACRO)
00033 #  undef ACE_EXPORT_MACRO
00034 #endif
00035 #define ACE_EXPORT_MACRO ACE_Export
00036 
00037 
00038 /*
00039  * We inline and undef some functions that may be implemented
00040  * as macros on some platforms. This way macro definitions will
00041  * be usable later as there is no way to save the macro definition
00042  * using the pre-processor.
00043  *
00044  */
00045 inline double ace_log2_helper (double x)
00046 {
00047 #if defined (log2)
00048   return log2 (x);
00049 #undef log2
00050 #else
00051 #  if !defined (ACE_LACKS_LOG2)
00052   return ACE_STD_NAMESPACE::log2 (x);
00053 #  else
00054   /*
00055     ==================================================================
00056 
00057                 log (x)
00058                    k
00059       log (x) = -------
00060          b      log (b)
00061                    k
00062 
00063     meaning the binary logarithm of x using the natural logarithm, for
00064     example, is:
00065 
00066 
00067                 log (x)
00068                    e
00069       log (x) = -------
00070          2      log (2)
00071                    e
00072 
00073     ==================================================================
00074    */
00075 
00076   // Precomputed value of 1/log(2.0).  Saves an expensive division and
00077   // computing log(2.0) in each call.
00078   double const _1_ln2 = 1.442695040888963407359924681002;
00079 
00080   return log (x) * _1_ln2;
00081 #  endif /* !ACE_LACKS_LOG2 */
00082 #endif /* defined (log2) */
00083 }
00084 
00085 
00086 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00087 
00088 namespace ACE_OS
00089 {
00090   /// This method computes the largest integral value not greater than x.
00091   ACE_NAMESPACE_INLINE_FUNCTION
00092   double floor (double x);
00093 
00094   /// This method computes the smallest integral value not less than x.
00095   ACE_NAMESPACE_INLINE_FUNCTION
00096   double ceil (double x);
00097 
00098   /// This method computes the base-2 logarithm of x.
00099   ACE_NAMESPACE_INLINE_FUNCTION
00100   double log2 (double x);
00101 
00102 } /* namespace ACE_OS */
00103 
00104 ACE_END_VERSIONED_NAMESPACE_DECL
00105 
00106 # if defined (ACE_HAS_INLINED_OSCALLS)
00107 #   if defined (ACE_INLINE)
00108 #     undef ACE_INLINE
00109 #   endif /* ACE_INLINE */
00110 #   define ACE_INLINE inline
00111 #   include "ace/OS_NS_math.inl"
00112 # endif /* ACE_HAS_INLINED_OSCALLS */
00113 
00114 # include /**/ "ace/post.h"
00115 #endif /* ACE_OS_NS_MATH_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7