diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-05-23 04:35:10 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-05-23 04:35:10 +0000 |
commit | aadbae34c4bc753e584fd14002e82fe23ca59cff (patch) | |
tree | 480add712e978f96c02cfe8658635e6598f66a75 /ACE | |
parent | 539a089b5751e7492ca63f69b9b7e3b63db82129 (diff) | |
download | ATCD-aadbae34c4bc753e584fd14002e82fe23ca59cff.tar.gz |
ChangeLogTag:Tue May 23 05:12:04 2007 Ossama Othman <ossama othman at symantec dot com>
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ChangeLog | 12 | ||||
-rw-r--r-- | ACE/ace/OS_NS_math.h | 33 |
2 files changed, 42 insertions, 3 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 76a8159a398..85ee6afc6fd 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,15 @@ +Tue May 23 05:12:04 2007 Ossama Othman <ossama othman at symantec dot com> + + * ace/OS_NS_math.h (ace_log2_helper): + + Moved within the ACE versioned namespace. + + Added comments about what the ACE_LACKS_LOG2 case actually + does. + + Store precomputed value of 1/log(2.0) to save an expensive + division and computing log(2.0) in each call. + Tue May 22 17:41:20 UTC 2007 Olli Savia <ops@iki.fi> * ace/config-netbsd.h: diff --git a/ACE/ace/OS_NS_math.h b/ACE/ace/OS_NS_math.h index aa438d212f3..49143738a79 100644 --- a/ACE/ace/OS_NS_math.h +++ b/ACE/ace/OS_NS_math.h @@ -34,6 +34,7 @@ #endif #define ACE_EXPORT_MACRO ACE_Export + /* * We inline and undef some functions that may be implemented * as macros on some platforms. This way macro definitions will @@ -41,7 +42,6 @@ * using the pre-processor. * */ - inline double ace_log2_helper (double x) { #if defined (log2) @@ -51,11 +51,38 @@ inline double ace_log2_helper (double x) # if !defined (ACE_LACKS_LOG2) return ACE_STD_NAMESPACE::log2 (x); # else - return log (x) / log (2.0); + /* + ================================================================== + + log (x) + k + log (x) = ------- + b log (b) + k + + meaning the binary logarithm of x using the natural logarithm, for + example, is: + + + log (x) + e + log (x) = ------- + 2 log (2) + e + + ================================================================== + */ + + // Precomputed value of 1/log(2.0). Saves an expensive division and + // computing log(2.0) in each call. + double const _1_ln2 = 1.442695040888963407359924681002; + + return log (x) * _1_ln2; # endif /* !ACE_LACKS_LOG2 */ #endif /* defined (log2) */ } + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_OS @@ -68,7 +95,7 @@ namespace ACE_OS ACE_NAMESPACE_INLINE_FUNCTION double ceil (double x); - /// This method computes base-2 logarithm of x + /// This method computes the base-2 logarithm of x. ACE_NAMESPACE_INLINE_FUNCTION double log2 (double x); |