Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73512 - in sandbox/e_float: boost/e_float libs/e_float/test/real/cases
From: e_float_at_[hidden]
Date: 2011-08-03 13:18:24


Author: christopher_kormanyos
Date: 2011-08-03 13:18:24 EDT (Wed, 03 Aug 2011)
New Revision: 73512
URL: http://svn.boost.org/trac/boost/changeset/73512

Log:
- Additional progress toward compatibility with bindings from Boost.Math.
Text files modified:
   sandbox/e_float/boost/e_float/e_float_complex.hpp | 41 ++++++++++++++++++++++----------------
   sandbox/e_float/boost/e_float/e_float_elementary_complex.hpp | 42 +++++++++++++++++++++++++++++----------
   sandbox/e_float/libs/e_float/test/real/cases/test_case_0000z_global_ops_pod.cpp | 32 +++++++++++++++---------------
   3 files changed, 71 insertions(+), 44 deletions(-)

Modified: sandbox/e_float/boost/e_float/e_float_complex.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_complex.hpp (original)
+++ sandbox/e_float/boost/e_float/e_float_complex.hpp 2011-08-03 13:18:24 EDT (Wed, 03 Aug 2011)
@@ -22,6 +22,18 @@
   // as well as creating a template specialization for e_float.
   // Therefore the separate class ef_complex is needed.
 
+ class ef_complex;
+
+ inline ef_complex& operator+=(ef_complex&, const INT32);
+ inline ef_complex& operator-=(ef_complex&, const INT32);
+ inline ef_complex& operator*=(ef_complex&, const INT32);
+ inline ef_complex& operator/=(ef_complex&, const INT32);
+
+ inline ef_complex& operator+=(ef_complex&, const e_float&);
+ inline ef_complex& operator-=(ef_complex&, const e_float&);
+ inline ef_complex& operator*=(ef_complex&, const e_float&);
+ inline ef_complex& operator/=(ef_complex&, const e_float&);
+
   class ef_complex
   {
   private:
@@ -60,8 +72,6 @@
     e_float norm(void) const { return (Re * Re) + (Im * Im); }
 
     ef_complex& operator=(const ef_complex& v) { Re = v.Re; Im = v.Im; return *this; }
- ef_complex& operator=(const e_float& v) { Re = v; Im = ef::zero(); return *this; }
-
     ef_complex& operator+=(const ef_complex& v) { Re += v.Re; Im += v.Im; return *this; }
     ef_complex& operator-=(const ef_complex& v) { Re -= v.Re; Im -= v.Im; return *this; }
 
@@ -89,24 +99,21 @@
       return *this;
     }
 
- ef_complex& operator+=(const e_float& v) { Re += v; return *this; }
- ef_complex& operator-=(const e_float& v) { Re -= v; return *this; }
- ef_complex& operator*=(const e_float& v) { Re *= v; Im *= v; return *this; }
- ef_complex& operator/=(const e_float& v) { Re /= v; Im /= v; return *this; }
+ // Operators with integer.
+ friend inline ef_complex& ::operator+=(ef_complex&, const INT32);
+ friend inline ef_complex& ::operator-=(ef_complex&, const INT32);
+ friend inline ef_complex& ::operator*=(ef_complex&, const INT32);
+ friend inline ef_complex& ::operator/=(ef_complex&, const INT32);
+
+ // Operators with e_float.
+ friend inline ef_complex& ::operator+=(ef_complex&, const e_float&);
+ friend inline ef_complex& ::operator-=(ef_complex&, const e_float&);
+ friend inline ef_complex& ::operator*=(ef_complex&, const e_float&);
+ friend inline ef_complex& ::operator/=(ef_complex&, const e_float&);
 
- // Operators pre-increment and post-increment
+ // Operators pre-increment and pre-decrement
     const ef_complex& operator++(void) { ++Re; return *this; }
- ef_complex operator++(int) { const ef_complex w(*this); ++Re; return w; }
-
- // Operators pre-decrement and post-decrement
     const ef_complex& operator--(void) { --Re; return *this; }
- ef_complex operator--(int) { const ef_complex w(*this); --Re; return w; }
-
- // Operators with integer.
- ef_complex& operator+=(const INT32 n) { Re += n; return *this; }
- ef_complex& operator-=(const INT32 n) { Re -= n; return *this; }
- ef_complex& operator*=(const INT32 n) { Re *= n; Im *= n; return *this; }
- ef_complex& operator/=(const INT32 n) { Re /= n; Im /= n; return *this; }
 
     bool isnan (void) const { return Re.isnan() || Im.isnan(); }
     bool isinf (void) const { return Re.isinf() || Im.isinf(); }

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-08-03 13:18:24 EDT (Wed, 03 Aug 2011)
@@ -57,39 +57,59 @@
     ef_complex atanh (const ef_complex& z);
   }
 
-
   // Global unary operators of e_float reference.
   inline ef_complex operator-(const ef_complex& u) { return ef_complex(-u.real(), -u.imag()); }
   inline ef_complex& operator+( ef_complex& u) { return u; }
   inline const ef_complex& operator+(const ef_complex& u) { return u; }
 
+ // Global operators post-increment and post-decrement
+ inline ef_complex operator++(ef_complex& u, int) { const ef_complex v(u); ++u; return v; }
+ inline ef_complex operator--(ef_complex& u, int) { const ef_complex v(u); --u; return v; }
+
   inline bool operator==(const ef_complex& u, const ef_complex& v) { return (u.real() == v.real()) && (u.imag() == v.imag()); }
   inline bool operator!=(const ef_complex& u, const ef_complex& v) { return (u.real() != v.real()) || (u.imag() != v.imag()); }
 
+ // Global comparison operators
   bool operator==(const ef_complex& u, const e_float& v);
   bool operator!=(const ef_complex& u, const e_float& v);
 
   bool operator==(const e_float& u, const ef_complex& v);
   bool operator!=(const e_float& u, const ef_complex& v);
 
+ // Global arithmetic operators with const ef_complex&, const e_float& and INT32
   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 ef_complex& u, const e_float& v) { return ef_complex(u.real() + v, u.imag()); }
+ inline ef_complex operator-(const ef_complex& u, const e_float& v) { return ef_complex(u.real() - v, u.imag()); }
+ inline ef_complex operator*(const ef_complex& u, const e_float& v) { return ef_complex(u.real() * v, u.imag() * v); }
+ inline ef_complex operator/(const ef_complex& u, const e_float& v) { return ef_complex(u.real() / v, u.imag() / v); }
+
+ inline ef_complex operator+(const e_float& u, const ef_complex& v) { return ef_complex(u + v.real(), v.imag()); }
+ inline ef_complex operator-(const e_float& u, const ef_complex& v) { return ef_complex(u - v.real(), -v.imag()); }
+ inline ef_complex operator*(const e_float& u, const ef_complex& v) { return ef_complex(u * v.real(), u * v.imag()); }
+ inline ef_complex operator/(const e_float& u, const ef_complex& v) { const e_float norm = (v.real() * v.real()) + (v.imag() * v.imag()); return ef_complex((u * v.real()) / norm, (-u * v.imag()) / norm); }
 
   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 INT32 n, const ef_complex& v) { return ef_complex(v.real() * n, v.imag() * n); }
+ inline ef_complex operator/(const INT32 n, const ef_complex& v) { const e_float norm = (v.real() * v.real()) + (v.imag() * v.imag()); return ef_complex((n * v.real()) / norm, (-n * v.imag()) / norm); }
 
- 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& z, const INT32 n) { return ef_complex(z.real() + n, z.imag()); }
+ inline ef_complex operator-(const ef_complex& z, const INT32 n) { return ef_complex(z.real() - n, z.imag()); }
+ inline ef_complex operator*(const ef_complex& z, const INT32 n) { return ef_complex(z.real() * n, z.imag() * n); }
+ inline ef_complex operator/(const ef_complex& z, const INT32 n) { return ef_complex(z.real() / n, z.imag() / n); }
+
+ inline ef_complex& operator+=(ef_complex& z, const INT32 n) { z.Re += n; return z; }
+ inline ef_complex& operator-=(ef_complex& z, const INT32 n) { z.Re -= n; return z; }
+ inline ef_complex& operator*=(ef_complex& z, const INT32 n) { z.Re *= n; z.Im *= n; return z; }
+ inline ef_complex& operator/=(ef_complex& z, const INT32 n) { z.Re /= n; z.Im /= n; return z; }
+
+ inline ef_complex& operator+=(ef_complex& z, const e_float& v) { z.Re += v; return z; }
+ inline ef_complex& operator-=(ef_complex& z, const e_float& v) { z.Re -= v; return z; }
+ inline ef_complex& operator*=(ef_complex& z, const e_float& v) { z.Re *= v; z.Im *= v; return z; }
+ inline ef_complex& operator/=(ef_complex& z, const e_float& v) { z.Re /= v; z.Im /= v; return z; }
 
 #endif // _E_FLOAT_ELEMENTARY_COMPLEX_HPP_

Modified: sandbox/e_float/libs/e_float/test/real/cases/test_case_0000z_global_ops_pod.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/test/real/cases/test_case_0000z_global_ops_pod.cpp (original)
+++ sandbox/e_float/libs/e_float/test/real/cases/test_case_0000z_global_ops_pod.cpp 2011-08-03 13:18:24 EDT (Wed, 03 Aug 2011)
@@ -18,7 +18,7 @@
 
 namespace
 {
- struct e_float_equal_to
+ struct e_float_equate_to
   {
     static e_float the_value_min;
     static e_float the_value_max;
@@ -57,8 +57,8 @@
     }
   };
 
- e_float e_float_equal_to::the_value_min;
- e_float e_float_equal_to::the_value_max;
+ e_float e_float_equate_to::the_value_min;
+ e_float e_float_equate_to::the_value_max;
 }
 
 namespace test
@@ -134,20 +134,20 @@
 
         my_test_result = true;
 
- my_test_result &= ::e_float_equal_to::check_utype<char>();
- my_test_result &= ::e_float_equal_to::check_stype<signed char>();
- my_test_result &= ::e_float_equal_to::check_utype<unsigned char>();
- my_test_result &= ::e_float_equal_to::check_utype<wchar_t>();
- my_test_result &= ::e_float_equal_to::check_stype<signed short>();
- my_test_result &= ::e_float_equal_to::check_utype<unsigned short>();
- my_test_result &= ::e_float_equal_to::check_stype<signed int>();
- my_test_result &= ::e_float_equal_to::check_utype<unsigned int>();
- my_test_result &= ::e_float_equal_to::check_stype<signed long>();
- my_test_result &= ::e_float_equal_to::check_utype<unsigned long>();
- my_test_result &= ::e_float_equal_to::check_stype<signed long long>();
- my_test_result &= ::e_float_equal_to::check_utype<unsigned long long>();
+ my_test_result &= ::e_float_equate_to::check_utype<char>();
+ my_test_result &= ::e_float_equate_to::check_stype<signed char>();
+ my_test_result &= ::e_float_equate_to::check_utype<unsigned char>();
+ my_test_result &= ::e_float_equate_to::check_utype<wchar_t>();
+ my_test_result &= ::e_float_equate_to::check_stype<signed short>();
+ my_test_result &= ::e_float_equate_to::check_utype<unsigned short>();
+ my_test_result &= ::e_float_equate_to::check_stype<signed int>();
+ my_test_result &= ::e_float_equate_to::check_utype<unsigned int>();
+ my_test_result &= ::e_float_equate_to::check_stype<signed long>();
+ my_test_result &= ::e_float_equate_to::check_utype<unsigned long>();
+ my_test_result &= ::e_float_equate_to::check_stype<signed long long>();
+ my_test_result &= ::e_float_equate_to::check_utype<unsigned long long>();
 
- e_float x;
+ e_float x(123u);
 
         x = static_cast<float>(4.0f); my_test_result &= (x == e_float(4u));
         x = static_cast<double>(4.0); my_test_result &= (x == e_float(4u));


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