Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73409 - in sandbox/e_float: boost/e_float libs/e_float/src/e_float libs/e_float/src/e_float/efx libs/e_float/src/functions/elementary
From: e_float_at_[hidden]
Date: 2011-07-28 07:45:38


Author: christopher_kormanyos
Date: 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
New Revision: 73409
URL: http://svn.boost.org/trac/boost/changeset/73409

Log:
- Added loud linker error when digit mismatch between headers and Lib/DLL arises.
- Removed comparison functions of e_float with INT32.
Text files modified:
   sandbox/e_float/boost/e_float/e_float_base.hpp | 15 ++++++++++++
   sandbox/e_float/boost/e_float/e_float_elementary_complex.hpp | 44 +++++++++++++++++----------------------
   sandbox/e_float/boost/e_float/e_float_global_math.hpp | 15 -------------
   sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp | 11 ++++++++++
   sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp | 2
   sandbox/e_float/libs/e_float/src/functions/elementary/elementary_complex.cpp | 6 -----
   6 files changed, 45 insertions(+), 48 deletions(-)

Modified: sandbox/e_float/boost/e_float/e_float_base.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_base.hpp (original)
+++ sandbox/e_float/boost/e_float/e_float_base.hpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -158,8 +158,21 @@
     static e_float my_cyl_bessel_jn(const INT32, const e_float&);
     static e_float my_cyl_bessel_yn(const INT32, const e_float&);
 
+ private:
+
+ template<const INT32 digits10>
+ struct digits_match_lib_dll
+ {
+ static INT32 value(void);
+ };
+
+ static bool digits_match_lib_dll_is_ok;
+
   protected:
- e_float_base() { }
+ e_float_base()
+ {
+ digits_match_lib_dll_is_ok = (digits_match_lib_dll<ef_digits10>::value() == ef_digits10);
+ }
   };
 
   std::ostream& operator<<(std::ostream& os, const e_float_base& f);

Modified: sandbox/e_float/boost/e_float/e_float_elementary_complex.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_elementary_complex.hpp (original)
+++ sandbox/e_float/boost/e_float/e_float_elementary_complex.hpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -76,30 +76,24 @@
   bool operator==(const e_float& u, const ef_complex& v);
   bool operator!=(const e_float& u, const ef_complex& v);
 
- bool operator==(const ef_complex& u, const INT32 n);
- bool operator!=(const ef_complex& u, const INT32 n);
-
- bool operator==(const INT32 n, const ef_complex& u);
- bool operator!=(const INT32 n, const ef_complex& u);
-
- inline ef_complex operator+ (const ef_complex& u, const ef_complex& v) { return ef_complex(u) += v; }
- inline ef_complex operator- (const ef_complex& u, const ef_complex& v) { return ef_complex(u) -= v; }
- inline ef_complex operator* (const ef_complex& u, const ef_complex& v) { return ef_complex(u) *= v; }
- inline ef_complex operator/ (const ef_complex& u, const ef_complex& v) { return ef_complex(u) /= v; }
-
- inline ef_complex operator+ (const ef_complex& u, const e_float& v) { return ef_complex(u) += v; }
- inline ef_complex operator- (const ef_complex& u, const e_float& v) { return ef_complex(u) -= v; }
- inline ef_complex operator* (const ef_complex& u, const e_float& v) { return ef_complex(u) *= v; }
- inline ef_complex operator/ (const ef_complex& u, const e_float& v) { return ef_complex(u) /= v; }
-
- inline ef_complex operator+ (const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) += v; }
- inline ef_complex operator- (const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) -= v; }
- inline ef_complex operator* (const INT32 n, const ef_complex& v) { return ef_complex(v) *= n; }
- inline ef_complex operator/ (const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) /= v; }
-
- inline ef_complex operator+ (const ef_complex& z, const INT32 n) { return ef_complex(z) += n; }
- inline ef_complex operator- (const ef_complex& z, const INT32 n) { return ef_complex(z) -= n; }
- inline ef_complex operator* (const ef_complex& z, const INT32 n) { return ef_complex(z) *= n; }
- inline ef_complex operator/ (const ef_complex& z, const INT32 n) { return ef_complex(z) /= n; }
+ inline ef_complex operator+(const ef_complex& u, const ef_complex& v) { return ef_complex(u) += v; }
+ inline ef_complex operator-(const ef_complex& u, const ef_complex& v) { return ef_complex(u) -= v; }
+ inline ef_complex operator*(const ef_complex& u, const ef_complex& v) { return ef_complex(u) *= v; }
+ inline ef_complex operator/(const ef_complex& u, const ef_complex& v) { return ef_complex(u) /= v; }
+
+ inline ef_complex operator+(const ef_complex& u, const e_float& v) { return ef_complex(u) += v; }
+ inline ef_complex operator-(const ef_complex& u, const e_float& v) { return ef_complex(u) -= v; }
+ inline ef_complex operator*(const ef_complex& u, const e_float& v) { return ef_complex(u) *= v; }
+ inline ef_complex operator/(const ef_complex& u, const e_float& v) { return ef_complex(u) /= v; }
+
+ inline ef_complex operator+(const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) += v; }
+ inline ef_complex operator-(const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) -= v; }
+ inline ef_complex operator*(const INT32 n, const ef_complex& v) { return ef_complex(v) *= n; }
+ inline ef_complex operator/(const INT32 n, const ef_complex& v) { return ef_complex(e_float(n)) /= v; }
+
+ inline ef_complex operator+(const ef_complex& z, const INT32 n) { return ef_complex(z) += n; }
+ inline ef_complex operator-(const ef_complex& z, const INT32 n) { return ef_complex(z) -= n; }
+ inline ef_complex operator*(const ef_complex& z, const INT32 n) { return ef_complex(z) *= n; }
+ inline ef_complex operator/(const ef_complex& z, const INT32 n) { return ef_complex(z) /= n; }
 
 #endif // _E_FLOAT_ELEMENTARY_COMPLEX_HPP_

Modified: sandbox/e_float/boost/e_float/e_float_global_math.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_global_math.hpp (original)
+++ sandbox/e_float/boost/e_float/e_float_global_math.hpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -57,19 +57,4 @@
   inline bool operator>=(const e_float& u, const e_float& v) { return (u.cmp(v) >= static_cast<INT32>(0)); }
   inline bool operator> (const e_float& u, const e_float& v) { return (u.cmp(v) > static_cast<INT32>(0)); }
 
- // Specializations of global comparison of e_float reference with INT32
- inline bool operator< (const e_float& u, const INT32 n) { return u < e_float(n); }
- inline bool operator<=(const e_float& u, const INT32 n) { return u <= e_float(n); }
- inline bool operator==(const e_float& u, const INT32 n) { return u == e_float(n); }
- inline bool operator!=(const e_float& u, const INT32 n) { return u != e_float(n); }
- inline bool operator>=(const e_float& u, const INT32 n) { return u >= e_float(n); }
- inline bool operator> (const e_float& u, const INT32 n) { return u > e_float(n); }
-
- inline bool operator< (const INT32 n, const e_float& u) { return e_float(n) < u; }
- inline bool operator<=(const INT32 n, const e_float& u) { return e_float(n) <= u; }
- inline bool operator==(const INT32 n, const e_float& u) { return e_float(n) == u; }
- inline bool operator!=(const INT32 n, const e_float& u) { return e_float(n) != u; }
- inline bool operator>=(const INT32 n, const e_float& u) { return e_float(n) >= u; }
- inline bool operator> (const INT32 n, const e_float& u) { return e_float(n) > u; }
-
 #endif // _E_FLOAT_GLOBAL_MATH_HPP_

Modified: sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp (original)
+++ sandbox/e_float/libs/e_float/src/e_float/e_float_base.cpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -11,6 +11,17 @@
 #include <e_float/e_float.hpp>
 #include "../utility/util_lexical_cast.h"
 
+bool e_float_base::digits_match_lib_dll_is_ok;
+
+// The purpose of this template specialization is to create a loud
+// link error if the e_float headers are erroneously mismatched with
+// a library or DLL that has a different number of digits.
+template<>
+INT32 e_float_base::digits_match_lib_dll<e_float_base::ef_digits10>::value(void)
+{
+ return e_float_base::ef_digits10;
+}
+
 std::ostream& operator<<(std::ostream& os, const e_float_base& f)
 {
   std::string str;

Modified: sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp (original)
+++ sandbox/e_float/libs/e_float/src/e_float/efx/e_float_efx.cpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -81,7 +81,7 @@
       }
 
       // Ensure that the value is normalized and adjust the exponent.
- u |= static_cast<UINT64>(static_cast<UINT64>(1uLL) << (std::numeric_limits<native_float_type>::digits - 1));
+ u |= static_cast<UINT64>(1uLL << (std::numeric_limits<native_float_type>::digits - 1));
       e -= 1;
     }
   };

Modified: sandbox/e_float/libs/e_float/src/functions/elementary/elementary_complex.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/functions/elementary/elementary_complex.cpp (original)
+++ sandbox/e_float/libs/e_float/src/functions/elementary/elementary_complex.cpp 2011-07-28 07:45:37 EDT (Thu, 28 Jul 2011)
@@ -30,12 +30,6 @@
 bool operator==(const e_float& u, const ef_complex& v) { return ((u == v.real()) && ef::iszero(v.imag())); }
 bool operator!=(const e_float& u, const ef_complex& v) { return ((u != v.real()) || !ef::iszero(v.imag())); }
 
-bool operator==(const ef_complex& u, const INT32 n) { return ((u.real() == n) && ef::iszero(u.imag())); }
-bool operator!=(const ef_complex& u, const INT32 n) { return ((u.real() != n) || !ef::iszero(u.imag())); }
-
-bool operator==(const INT32 n, const ef_complex& u) { return ((n == u.real()) && ef::iszero(u.imag())); }
-bool operator!=(const INT32 n, const ef_complex& u) { return ((n != u.real()) || !ef::iszero(u.imag())); }
-
 e_float efz::abs(const ef_complex& z) { return ef::sqrt(efz::norm(z)); }
 e_float efz::arg(const ef_complex& z) { return ef::atan2(z.imag(), z.real()); }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk