From d11c836abd618b114286e64bf0fb759238a77f96 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 2 Jul 2022 19:40:12 -0700 Subject: [PATCH] Fix deprecated implicit copy constructor for octonion --- include/boost/math/octonion.hpp | 1660 +++++++++++++++---------------- 1 file changed, 826 insertions(+), 834 deletions(-) diff --git a/include/boost/math/octonion.hpp b/include/boost/math/octonion.hpp index 10fe1a2a4..56d8c9e05 100644 --- a/include/boost/math/octonion.hpp +++ b/include/boost/math/octonion.hpp @@ -19,7 +19,7 @@ namespace boost { namespace math { - + #define BOOST_OCTONION_ACCESSOR_GENERATOR(type) \ type real() const \ { \ @@ -100,8 +100,8 @@ namespace boost { \ return(::boost::math::quaternion(e,f,g,h)); \ } - - + + #define BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(type) \ template \ octonion & operator = (octonion const & a_affecter) \ @@ -162,8 +162,8 @@ namespace boost \ return(*this); \ } - - + + #define BOOST_OCTONION_MEMBER_DATA_GENERATOR(type) \ type a; \ type b; \ @@ -173,18 +173,18 @@ namespace boost type f; \ type g; \ type h; \ - - + + template class octonion { public: - - typedef T value_type; - + + using value_type = T; + // constructor for O seen as R^8 // (also default constructor) - + explicit octonion( T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), @@ -204,10 +204,10 @@ namespace boost { // nothing to do! } - - + + // constructor for H seen as C^4 - + explicit octonion( ::std::complex const & z0, ::std::complex const & z1 = ::std::complex(), ::std::complex const & z2 = ::std::complex(), @@ -223,10 +223,10 @@ namespace boost { // nothing to do! } - - + + // constructor for O seen as H^2 - + explicit octonion( ::boost::math::quaternion const & q0, ::boost::math::quaternion const & q1 = ::boost::math::quaternion()) : a(q0.R_component_1()), @@ -240,14 +240,14 @@ namespace boost { // nothing to do! } - - + + // UNtemplated copy constructor - // (this is taken care of by the compiler itself) - - + octonion(const octonion&) = default; + + // templated copy constructor - + template explicit octonion(octonion const & a_recopier) : a(static_cast(a_recopier.R_component_1())), @@ -261,12 +261,12 @@ namespace boost { // nothing to do! } - - + + // destructor - // (this is taken care of by the compiler itself) - - + ~octonion() = default; + + // accessors // // Note: Like complex number, octonions do have a meaningful notion of "real part", @@ -275,58 +275,58 @@ namespace boost // nothing simpler (as opposed to the complex number case). // However, for practicality, there are accessors for the other components // (these are necessary for the templated copy constructor, for instance). - + BOOST_OCTONION_ACCESSOR_GENERATOR(T) - + // assignment operators - + BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(T) - + // other assignment-related operators // // NOTE: Octonion multiplication is *NOT* commutative; // symbolically, "q *= rhs;" means "q = q * rhs;" // and "q /= rhs;" means "q = q * inverse_of(rhs);"; // octonion multiplication is also *NOT* associative - + octonion & operator += (T const & rhs) { T at = a + rhs; // exception guard - + a = at; - + return(*this); } - - + + octonion & operator += (::std::complex const & rhs) { T at = a + rhs.real(); // exception guard T bt = b + rhs.imag(); // exception guard - - a = at; + + a = at; b = bt; - + return(*this); } - - + + octonion & operator += (::boost::math::quaternion const & rhs) { T at = a + rhs.R_component_1(); // exception guard T bt = b + rhs.R_component_2(); // exception guard T ct = c + rhs.R_component_3(); // exception guard T dt = d + rhs.R_component_4(); // exception guard - - a = at; + + a = at; b = bt; c = ct; d = dt; - + return(*this); } - - + + template octonion & operator += (octonion const & rhs) { @@ -338,7 +338,7 @@ namespace boost T ft = f + static_cast(rhs.R_component_6()); // exception guard T gt = g + static_cast(rhs.R_component_7()); // exception guard T ht = h + static_cast(rhs.R_component_8()); // exception guard - + a = at; b = bt; c = ct; @@ -347,50 +347,50 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - - + + + octonion & operator -= (T const & rhs) { T at = a - rhs; // exception guard - + a = at; - + return(*this); } - - + + octonion & operator -= (::std::complex const & rhs) { T at = a - rhs.real(); // exception guard T bt = b - rhs.imag(); // exception guard - - a = at; + + a = at; b = bt; - + return(*this); } - - + + octonion & operator -= (::boost::math::quaternion const & rhs) { T at = a - rhs.R_component_1(); // exception guard T bt = b - rhs.R_component_2(); // exception guard T ct = c - rhs.R_component_3(); // exception guard T dt = d - rhs.R_component_4(); // exception guard - - a = at; + + a = at; b = bt; c = ct; d = dt; - + return(*this); } - - + + template octonion & operator -= (octonion const & rhs) { @@ -402,7 +402,7 @@ namespace boost T ft = f - static_cast(rhs.R_component_6()); // exception guard T gt = g - static_cast(rhs.R_component_7()); // exception guard T ht = h - static_cast(rhs.R_component_8()); // exception guard - + a = at; b = bt; c = ct; @@ -411,11 +411,11 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator *= (T const & rhs) { T at = a * rhs; // exception guard @@ -426,7 +426,7 @@ namespace boost T ft = f * rhs; // exception guard T gt = g * rhs; // exception guard T ht = h * rhs; // exception guard - + a = at; b = bt; c = ct; @@ -435,16 +435,16 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator *= (::std::complex const & rhs) { T ar = rhs.real(); T br = rhs.imag(); - + T at = +a*ar-b*br; T bt = +a*br+b*ar; T ct = +c*ar+d*br; @@ -453,7 +453,7 @@ namespace boost T ft = -e*br+f*ar; T gt = +g*ar-h*br; T ht = +g*br+h*ar; - + a = at; b = bt; c = ct; @@ -462,18 +462,18 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator *= (::boost::math::quaternion const & rhs) { T ar = rhs.R_component_1(); T br = rhs.R_component_2(); T cr = rhs.R_component_2(); T dr = rhs.R_component_2(); - + T at = +a*ar-b*br-c*cr-d*dr; T bt = +a*br+b*ar+c*dr-d*cr; T ct = +a*cr-b*dr+c*ar+d*br; @@ -482,7 +482,7 @@ namespace boost T ft = -e*br+f*ar-g*dr+h*cr; T gt = -e*cr+f*dr+g*ar-h*br; T ht = -e*dr-f*cr+g*br+h*ar; - + a = at; b = bt; c = ct; @@ -491,11 +491,11 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + template octonion & operator *= (octonion const & rhs) { @@ -507,7 +507,7 @@ namespace boost T fr = static_cast(rhs.R_component_6()); T gr = static_cast(rhs.R_component_7()); T hr = static_cast(rhs.R_component_8()); - + T at = +a*ar-b*br-c*cr-d*dr-e*er-f*fr-g*gr-h*hr; T bt = +a*br+b*ar+c*dr-d*cr+e*fr-f*er-g*hr+h*gr; T ct = +a*cr-b*dr+c*ar+d*br+e*gr+f*hr-g*er-h*fr; @@ -516,7 +516,7 @@ namespace boost T ft = +a*fr+b*er-c*hr+d*gr-e*br+f*ar-g*dr+h*cr; T gt = +a*gr+b*hr+c*er-d*fr-e*cr+f*dr+g*ar-h*br; T ht = +a*hr-b*gr+c*fr+d*er-e*dr-f*cr+g*br+h*ar; - + a = at; b = bt; c = ct; @@ -525,11 +525,11 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator /= (T const & rhs) { T at = a / rhs; // exception guard @@ -540,7 +540,7 @@ namespace boost T ft = f / rhs; // exception guard T gt = g / rhs; // exception guard T ht = h / rhs; // exception guard - + a = at; b = bt; c = ct; @@ -549,18 +549,18 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator /= (::std::complex const & rhs) { T ar = rhs.real(); T br = rhs.imag(); - + T denominator = ar*ar+br*br; - + T at = (+a*ar-b*br)/denominator; T bt = (-a*br+b*ar)/denominator; T ct = (+c*ar-d*br)/denominator; @@ -569,7 +569,7 @@ namespace boost T ft = (+e*br+f*ar)/denominator; T gt = (+g*ar+h*br)/denominator; T ht = (+g*br+h*ar)/denominator; - + a = at; b = bt; c = ct; @@ -578,20 +578,20 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + octonion & operator /= (::boost::math::quaternion const & rhs) { T ar = rhs.R_component_1(); T br = rhs.R_component_2(); T cr = rhs.R_component_2(); T dr = rhs.R_component_2(); - + T denominator = ar*ar+br*br+cr*cr+dr*dr; - + T at = (+a*ar+b*br+c*cr+d*dr)/denominator; T bt = (-a*br+b*ar-c*dr+d*cr)/denominator; T ct = (-a*cr+b*dr+c*ar-d*br)/denominator; @@ -600,7 +600,7 @@ namespace boost T ft = (+e*br+f*ar+g*dr-h*cr)/denominator; T gt = (+e*cr-f*dr+g*ar+h*br)/denominator; T ht = (+e*dr+f*cr-g*br+h*ar)/denominator; - + a = at; b = bt; c = ct; @@ -609,11 +609,11 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + template octonion & operator /= (octonion const & rhs) { @@ -625,9 +625,9 @@ namespace boost T fr = static_cast(rhs.R_component_6()); T gr = static_cast(rhs.R_component_7()); T hr = static_cast(rhs.R_component_8()); - + T denominator = ar*ar+br*br+cr*cr+dr*dr+er*er+fr*fr+gr*gr+hr*hr; - + T at = (+a*ar+b*br+c*cr+d*dr+e*er+f*fr+g*gr+h*hr)/denominator; T bt = (-a*br+b*ar-c*dr+d*cr-e*fr+f*er+g*hr-h*gr)/denominator; T ct = (-a*cr+b*dr+c*ar-d*br-e*gr-f*hr+g*er+h*fr)/denominator; @@ -636,7 +636,7 @@ namespace boost T ft = (-a*fr-b*er+c*hr-d*gr+e*br+f*ar+g*dr-h*cr)/denominator; T gt = (-a*gr-b*hr-c*er+d*fr+e*cr-f*dr+g*ar+h*br)/denominator; T ht = (-a*hr+b*gr-c*fr-d*er+e*dr+f*cr-g*br+h*ar)/denominator; - + a = at; b = bt; c = ct; @@ -645,43 +645,43 @@ namespace boost f = ft; g = gt; h = ht; - + return(*this); } - - + + protected: - + BOOST_OCTONION_MEMBER_DATA_GENERATOR(T) - - + + private: - + }; - - + + // declaration of octonion specialization - + template<> class octonion; template<> class octonion; template<> class octonion; - - + + // helper templates for converting copy constructors (declaration) - + namespace detail { - + template< typename T, typename U > octonion octonion_type_converter(octonion const & rhs); } - - + + // implementation of octonion specialization - - + + #define BOOST_OCTONION_CONSTRUCTOR_GENERATOR(type) \ explicit octonion( type const & requested_a = static_cast(0), \ type const & requested_b = static_cast(0), \ @@ -729,8 +729,8 @@ namespace boost h(q1.R_component_4()) \ { \ } - - + + #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_1(type) \ octonion & operator += (type const & rhs) \ { \ @@ -738,7 +738,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_2(type) \ octonion & operator += (::std::complex const & rhs) \ { \ @@ -747,7 +747,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_3(type) \ octonion & operator += (::boost::math::quaternion const & rhs) \ { \ @@ -758,7 +758,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_4(type) \ template \ octonion & operator += (octonion const & rhs) \ @@ -774,7 +774,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_1(type) \ octonion & operator -= (type const & rhs) \ { \ @@ -782,7 +782,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_2(type) \ octonion & operator -= (::std::complex const & rhs) \ { \ @@ -791,7 +791,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_3(type) \ octonion & operator -= (::boost::math::quaternion const & rhs) \ { \ @@ -802,7 +802,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_4(type) \ template \ octonion & operator -= (octonion const & rhs) \ @@ -818,7 +818,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_1(type) \ octonion & operator *= (type const & rhs) \ { \ @@ -833,7 +833,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_2(type) \ octonion & operator *= (::std::complex const & rhs) \ { \ @@ -860,7 +860,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_3(type) \ octonion & operator *= (::boost::math::quaternion const & rhs) \ { \ @@ -889,7 +889,7 @@ namespace boost \ return(*this); \ } - + #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_4(type) \ template \ octonion & operator *= (octonion const & rhs) \ @@ -923,14 +923,14 @@ namespace boost \ return(*this); \ } - + // There is quite a lot of repetition in the code below. This is intentional. // The last conditional block is the normal form, and the others merely // consist of workarounds for various compiler deficiencies. Hopefully, when // more compilers are conformant and we can retire support for those that are // not, we will be able to remove the clutter. This is makes the situation // (painfully) explicit. - + #define BOOST_OCTONION_MEMBER_DIV_GENERATOR_1(type) \ octonion & operator /= (type const & rhs) \ { \ @@ -941,7 +941,7 @@ namespace boost \ return(*this); \ } - + #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) #define BOOST_OCTONION_MEMBER_DIV_GENERATOR_2(type) \ octonion & operator /= (::std::complex const & rhs) \ @@ -1026,7 +1026,7 @@ namespace boost return(*this); \ } #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - + #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) #define BOOST_OCTONION_MEMBER_DIV_GENERATOR_3(type) \ octonion & operator /= (::boost::math::quaternion const & rhs) \ @@ -1115,7 +1115,7 @@ namespace boost return(*this); \ } #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - + #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) #define BOOST_OCTONION_MEMBER_DIV_GENERATOR_4(type) \ template \ @@ -1214,66 +1214,66 @@ namespace boost return(*this); \ } #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - - + + #define BOOST_OCTONION_MEMBER_ADD_GENERATOR(type) \ BOOST_OCTONION_MEMBER_ADD_GENERATOR_1(type) \ BOOST_OCTONION_MEMBER_ADD_GENERATOR_2(type) \ BOOST_OCTONION_MEMBER_ADD_GENERATOR_3(type) \ BOOST_OCTONION_MEMBER_ADD_GENERATOR_4(type) - + #define BOOST_OCTONION_MEMBER_SUB_GENERATOR(type) \ BOOST_OCTONION_MEMBER_SUB_GENERATOR_1(type) \ BOOST_OCTONION_MEMBER_SUB_GENERATOR_2(type) \ BOOST_OCTONION_MEMBER_SUB_GENERATOR_3(type) \ BOOST_OCTONION_MEMBER_SUB_GENERATOR_4(type) - + #define BOOST_OCTONION_MEMBER_MUL_GENERATOR(type) \ BOOST_OCTONION_MEMBER_MUL_GENERATOR_1(type) \ BOOST_OCTONION_MEMBER_MUL_GENERATOR_2(type) \ BOOST_OCTONION_MEMBER_MUL_GENERATOR_3(type) \ BOOST_OCTONION_MEMBER_MUL_GENERATOR_4(type) - + #define BOOST_OCTONION_MEMBER_DIV_GENERATOR(type) \ BOOST_OCTONION_MEMBER_DIV_GENERATOR_1(type) \ BOOST_OCTONION_MEMBER_DIV_GENERATOR_2(type) \ BOOST_OCTONION_MEMBER_DIV_GENERATOR_3(type) \ BOOST_OCTONION_MEMBER_DIV_GENERATOR_4(type) - + #define BOOST_OCTONION_MEMBER_ALGEBRAIC_GENERATOR(type) \ BOOST_OCTONION_MEMBER_ADD_GENERATOR(type) \ BOOST_OCTONION_MEMBER_SUB_GENERATOR(type) \ BOOST_OCTONION_MEMBER_MUL_GENERATOR(type) \ BOOST_OCTONION_MEMBER_DIV_GENERATOR(type) - - + + template<> class octonion { public: - - typedef float value_type; - + + using value_type = float; + BOOST_OCTONION_CONSTRUCTOR_GENERATOR(float) - + // UNtemplated copy constructor - // (this is taken care of by the compiler itself) - + octonion(const octonion&) = default; + // explicit copy constructors (precision-losing converters) - + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - + // destructor - // (this is taken care of by the compiler itself) - + ~octonion() = default; + // accessors // // Note: Like complex number, octonions do have a meaningful notion of "real part", @@ -1282,62 +1282,58 @@ namespace boost // nothing simpler (as opposed to the complex number case). // However, for practicality, there are accessors for the other components // (these are necessary for the templated copy constructor, for instance). - + BOOST_OCTONION_ACCESSOR_GENERATOR(float) - + // assignment operators - + BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(float) - + // other assignment-related operators // // NOTE: Octonion multiplication is *NOT* commutative; // symbolically, "q *= rhs;" means "q = q * rhs;" // and "q /= rhs;" means "q = q * inverse_of(rhs);"; // octonion multiplication is also *NOT* associative - + BOOST_OCTONION_MEMBER_ALGEBRAIC_GENERATOR(float) - - + + protected: - + BOOST_OCTONION_MEMBER_DATA_GENERATOR(float) - - - private: - }; - - + + template<> class octonion { public: - - typedef double value_type; - + + using value_type = double; + BOOST_OCTONION_CONSTRUCTOR_GENERATOR(double) - - // UNtemplated copy constructor - // (this is taken care of by the compiler itself) - + + // Untemplated copy constructor + octonion(const octonion&) = default; + // converting copy constructor - + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - + // explicit copy constructors (precision-losing converters) - + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - + // destructor // (this is taken care of by the compiler itself) - + // accessors // // Note: Like complex number, octonions do have a meaningful notion of "real part", @@ -1346,62 +1342,58 @@ namespace boost // nothing simpler (as opposed to the complex number case). // However, for practicality, there are accessors for the other components // (these are necessary for the templated copy constructor, for instance). - + BOOST_OCTONION_ACCESSOR_GENERATOR(double) - + // assignment operators - + BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(double) - + // other assignment-related operators // // NOTE: Octonion multiplication is *NOT* commutative; // symbolically, "q *= rhs;" means "q = q * rhs;" // and "q /= rhs;" means "q = q * inverse_of(rhs);"; // octonion multiplication is also *NOT* associative - + BOOST_OCTONION_MEMBER_ALGEBRAIC_GENERATOR(double) - - + + protected: - + BOOST_OCTONION_MEMBER_DATA_GENERATOR(double) - - - private: - }; - - + + template<> class octonion { public: - - typedef long double value_type; - + + using value_type = long double; + BOOST_OCTONION_CONSTRUCTOR_GENERATOR(long double) - + // UNtemplated copy constructor - // (this is taken care of by the compiler itself) - + octonion(const octonion&) = default; + // converting copy constructor - + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - - + + explicit octonion(octonion const & a_recopier) { *this = detail::octonion_type_converter(a_recopier); } - - + + // destructor // (this is taken care of by the compiler itself) - + // accessors // // Note: Like complex number, octonions do have a meaningful notion of "real part", @@ -1410,42 +1402,42 @@ namespace boost // nothing simpler (as opposed to the complex number case). // However, for practicality, there are accessors for the other components // (these are necessary for the templated copy constructor, for instance). - + BOOST_OCTONION_ACCESSOR_GENERATOR(long double) - + // assignment operators - + BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(long double) - + // other assignment-related operators // // NOTE: Octonion multiplication is *NOT* commutative; // symbolically, "q *= rhs;" means "q = q * rhs;" // and "q /= rhs;" means "q = q * inverse_of(rhs);"; // octonion multiplication is also *NOT* associative - + BOOST_OCTONION_MEMBER_ALGEBRAIC_GENERATOR(long double) - - + + protected: - + BOOST_OCTONION_MEMBER_DATA_GENERATOR(long double) - - + + private: - + }; - - + + #undef BOOST_OCTONION_CONSTRUCTOR_GENERATOR - + #undef BOOST_OCTONION_MEMBER_ALGEBRAIC_GENERATOR - + #undef BOOST_OCTONION_MEMBER_ADD_GENERATOR #undef BOOST_OCTONION_MEMBER_SUB_GENERATOR #undef BOOST_OCTONION_MEMBER_MUL_GENERATOR #undef BOOST_OCTONION_MEMBER_DIV_GENERATOR - + #undef BOOST_OCTONION_MEMBER_ADD_GENERATOR_1 #undef BOOST_OCTONION_MEMBER_ADD_GENERATOR_2 #undef BOOST_OCTONION_MEMBER_ADD_GENERATOR_3 @@ -1462,59 +1454,59 @@ namespace boost #undef BOOST_OCTONION_MEMBER_DIV_GENERATOR_2 #undef BOOST_OCTONION_MEMBER_DIV_GENERATOR_3 #undef BOOST_OCTONION_MEMBER_DIV_GENERATOR_4 - - + + #undef BOOST_OCTONION_MEMBER_DATA_GENERATOR - + #undef BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR - + #undef BOOST_OCTONION_ACCESSOR_GENERATOR - - + + // operators - + #define BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) \ { \ octonion res(lhs); \ res op##= rhs; \ return(res); \ } - + #define BOOST_OCTONION_OPERATOR_GENERATOR_1_L(op) \ template \ inline octonion operator op (T const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_1_R(op) \ template \ inline octonion operator op (octonion const & lhs, T const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_2_L(op) \ template \ inline octonion operator op (::std::complex const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_2_R(op) \ template \ inline octonion operator op (octonion const & lhs, ::std::complex const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_3_L(op) \ template \ inline octonion operator op (::boost::math::quaternion const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_3_R(op) \ template \ inline octonion operator op (octonion const & lhs, ::boost::math::quaternion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR_4(op) \ template \ inline octonion operator op (octonion const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) - + #define BOOST_OCTONION_OPERATOR_GENERATOR(op) \ BOOST_OCTONION_OPERATOR_GENERATOR_1_L(op) \ BOOST_OCTONION_OPERATOR_GENERATOR_1_R(op) \ @@ -1523,16 +1515,16 @@ namespace boost BOOST_OCTONION_OPERATOR_GENERATOR_3_L(op) \ BOOST_OCTONION_OPERATOR_GENERATOR_3_R(op) \ BOOST_OCTONION_OPERATOR_GENERATOR_4(op) - - + + BOOST_OCTONION_OPERATOR_GENERATOR(+) BOOST_OCTONION_OPERATOR_GENERATOR(-) BOOST_OCTONION_OPERATOR_GENERATOR(*) BOOST_OCTONION_OPERATOR_GENERATOR(/) - - + + #undef BOOST_OCTONION_OPERATOR_GENERATOR - + #undef BOOST_OCTONION_OPERATOR_GENERATOR_1_L #undef BOOST_OCTONION_OPERATOR_GENERATOR_1_R #undef BOOST_OCTONION_OPERATOR_GENERATOR_2_L @@ -1540,24 +1532,24 @@ namespace boost #undef BOOST_OCTONION_OPERATOR_GENERATOR_3_L #undef BOOST_OCTONION_OPERATOR_GENERATOR_3_R #undef BOOST_OCTONION_OPERATOR_GENERATOR_4 - + #undef BOOST_OCTONION_OPERATOR_GENERATOR_BODY - - + + template inline octonion operator + (octonion const & o) { return(o); } - - + + template inline octonion operator - (octonion const & o) { return(octonion(-o.R_component_1(),-o.R_component_2(),-o.R_component_3(),-o.R_component_4(),-o.R_component_5(),-o.R_component_6(),-o.R_component_7(),-o.R_component_8())); } - - + + template inline bool operator == (T const & lhs, octonion const & rhs) { @@ -1572,8 +1564,8 @@ namespace boost (rhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (octonion const & lhs, T const & rhs) { @@ -1588,8 +1580,8 @@ namespace boost (lhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (::std::complex const & lhs, octonion const & rhs) { @@ -1604,8 +1596,8 @@ namespace boost (rhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (octonion const & lhs, ::std::complex const & rhs) { @@ -1620,8 +1612,8 @@ namespace boost (lhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (::boost::math::quaternion const & lhs, octonion const & rhs) { @@ -1636,8 +1628,8 @@ namespace boost (rhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (octonion const & lhs, ::boost::math::quaternion const & rhs) { @@ -1652,8 +1644,8 @@ namespace boost (lhs.R_component_8() == static_cast(0)) ); } - - + + template inline bool operator == (octonion const & lhs, octonion const & rhs) { @@ -1668,44 +1660,44 @@ namespace boost (rhs.R_component_8() == lhs.R_component_8()) ); } - - + + #define BOOST_OCTONION_NOT_EQUAL_GENERATOR \ { \ return(!(lhs == rhs)); \ } - + template inline bool operator != (T const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (octonion const & lhs, T const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (::std::complex const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (octonion const & lhs, ::std::complex const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (::boost::math::quaternion const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (octonion const & lhs, ::boost::math::quaternion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + template inline bool operator != (octonion const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - + #undef BOOST_OCTONION_NOT_EQUAL_GENERATOR - - + + // Note: the default values in the constructors of the complex and quaternions make for // a very complex and ambiguous situation; we have made choices to disambiguate. template @@ -1716,7 +1708,7 @@ namespace boost #else const ::std::ctype & ct = ::std::use_facet< ::std::ctype >(is.getloc()); #endif /* BOOST_NO_STD_LOCALE */ - + T a = T(); T b = T(); T c = T(); @@ -1725,82 +1717,82 @@ namespace boost T f = T(); T g = T(); T h = T(); - + ::std::complex u = ::std::complex(); ::std::complex v = ::std::complex(); ::std::complex x = ::std::complex(); ::std::complex y = ::std::complex(); - + ::boost::math::quaternion p = ::boost::math::quaternion(); ::boost::math::quaternion q = ::boost::math::quaternion(); - + charT ch = charT(); char cc; - + is >> ch; // get the first lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(" { is >> ch; // get the second lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((" { is >> ch; // get the third lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(((" { is.putback(ch); - + is >> u; // read "((u" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((u)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // format: (((a))), (((a,b))) { o = octonion(u); @@ -1808,21 +1800,21 @@ namespace boost else if (cc == ',') // read "((u)," { p = ::boost::math::quaternion(u); - + is >> q; // read "((u),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // format: (((a)),q), (((a,b)),q) { o = octonion(p,q); @@ -1840,11 +1832,11 @@ namespace boost else if (cc ==',') // read "((u," { is >> v; // read "((u,v" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1852,13 +1844,13 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((u,v)" { p = ::boost::math::quaternion(u,v); - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1866,7 +1858,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // format: (((a),v)), (((a,b),v)) { o = octonion(p); @@ -1874,11 +1866,11 @@ namespace boost else if (cc == ',') // read "((u,v)," { is >> q; // read "(p,q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1886,7 +1878,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // format: (((a),v),q), (((a,b),v),q) { o = octonion(p,q); @@ -1914,13 +1906,13 @@ namespace boost else // read "((a" { is.putback(ch); - + is >> a; // we extract the first component - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1928,11 +1920,11 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1940,7 +1932,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a))" { o = octonion(a); @@ -1948,19 +1940,19 @@ namespace boost else if (cc == ',') // read "((a)," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a),(" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1968,19 +1960,19 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a),((" { is.putback(ch); - + is.putback(ch); // we backtrack twice, with the same value! - + is >> q; // read "((a),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -1988,11 +1980,11 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),q)" { p = ::boost::math::quaternion(a); - + o = octonion(p,q); } else // error @@ -2003,33 +1995,33 @@ namespace boost else // read "((a),(c" or "((a),(e" { is.putback(ch); - + is >> c; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c)" (ambiguity resolution) { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c))" { o = octonion(a,b,c); @@ -2037,23 +2029,23 @@ namespace boost else if (cc == ',') // read "((a),(c)," { u = ::std::complex(a); - + v = ::std::complex(c); - + is >> x; // read "((a),(c),x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c),x)" { o = octonion(u,v,x); @@ -2061,19 +2053,19 @@ namespace boost else if (cc == ',') // read "((a),(c),x," { is >> y; // read "((a),(c),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c),x,y)" { o = octonion(u,v,x,y); @@ -2096,7 +2088,7 @@ namespace boost else if (cc == ',') // read "((a),(c," or "((a),(e," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -2104,31 +2096,31 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a),(e,(" (ambiguity resolution) { p = ::boost::math::quaternion(a); - + x = ::std::complex(c); // "c" was actually "e" - + is.putback(ch); // we can only backtrace once - + is >> y; // read "((a),(e,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,y)" { q = ::boost::math::quaternion(x,y); - + is >> ch; // get the next lexeme #ifdef BOOST_NO_STD_LOCALE @@ -2136,7 +2128,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,y))" { o = octonion(p,q); @@ -2154,25 +2146,25 @@ namespace boost else // read "((a),(c,d" or "((a),(e,f" { is.putback(ch); - + is >> d; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c,d)" (ambiguity resolution) { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -2180,7 +2172,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c,d))" { o = octonion(a,b,c,d); @@ -2188,23 +2180,23 @@ namespace boost else if (cc == ',') // read "((a),(c,d)," { u = ::std::complex(a); - + v = ::std::complex(c,d); - + is >> x; // read "((a),(c,d),x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c,d),x)" { o = octonion(u,v,x); @@ -2212,19 +2204,19 @@ namespace boost else if (cc == ',') // read "((a),(c,d),x," { is >> y; // read "((a),(c,d),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(c,d),x,y)" { o = octonion(u,v,x,y); @@ -2247,35 +2239,35 @@ namespace boost else if (cc == ',') // read "((a),(e,f," (ambiguity resolution) { p = ::boost::math::quaternion(a); - + is >> g; // read "((a),(e,f,g" (too late to backtrack) - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,f,g)" { q = ::boost::math::quaternion(c,d,g); // "c" was actually "e", and "d" was actually "f" - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,f,g))" { o = octonion(p,q); @@ -2288,33 +2280,33 @@ namespace boost else if (cc == ',') // read "((a),(e,f,g," { is >> h; // read "((a),(e,f,g,h" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,f,g,h)" { q = ::boost::math::quaternion(c,d,g,h); // "c" was actually "e", and "d" was actually "f" - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),(e,f,g,h))" { o = octonion(p,q); @@ -2349,21 +2341,21 @@ namespace boost else // read "((a),c" (ambiguity resolution) { is.putback(ch); - + is >> c; // we extract the third component - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),c)" { o = octonion(a,b,c); @@ -2371,19 +2363,19 @@ namespace boost else if (cc == ',') // read "((a),c," { is >> x; // read "((a),c,x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),c,x)" { o = octonion(a,b,c,d,x.real(),x.imag()); @@ -2391,17 +2383,17 @@ namespace boost else if (cc == ',') // read "((a),c,x," { is >> y;if (!is.good()) goto finish; // read "((a),c,x,y" - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a),c,x,y)" { o = octonion(a,b,c,d,x.real(),x.imag(),y.real(),y.imag()); @@ -2430,39 +2422,39 @@ namespace boost else if (cc ==',') // read "((a," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a,(" { u = ::std::complex(a); - + is.putback(ch); // can only backtrack so much - + is >> v; // read "((a,v" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,v)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -2470,7 +2462,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,v))" { o = octonion(u,v); @@ -2478,21 +2470,21 @@ namespace boost else if (cc == ',') // read "((a,v)," { p = ::boost::math::quaternion(u,v); - + is >> q; // read "((a,v),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,v),q)" { o = octonion(p,q); @@ -2515,33 +2507,33 @@ namespace boost else { is.putback(ch); - + is >> b; // read "((a,b" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b))" { o = octonion(a,b); @@ -2549,7 +2541,7 @@ namespace boost else if (cc == ',') // read "((a,b)," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -2557,41 +2549,41 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a,b),(" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a,b),((" { p = ::boost::math::quaternion(a,b); - + is.putback(ch); - + is.putback(ch); // we backtrack twice, with the same value - + is >> q; // read "((a,b),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),q)" { o = octonion(p,q); @@ -2604,33 +2596,33 @@ namespace boost else // read "((a,b),(c" or "((a,b),(e" { is.putback(ch); - + is >> c; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c)" (ambiguity resolution) { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c))" { o = octonion(a,b,c); @@ -2638,23 +2630,23 @@ namespace boost else if (cc == ',') // read "((a,b),(c)," { u = ::std::complex(a,b); - + v = ::std::complex(c); - + is >> x; // read "((a,b),(c),x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c),x)" { o = octonion(u,v,x); @@ -2662,19 +2654,19 @@ namespace boost else if (cc == ',') // read "((a,b),(c),x," { is >> y; // read "((a,b),(c),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c),x,y)" { o = octonion(u,v,x,y); @@ -2697,41 +2689,41 @@ namespace boost else if (cc == ',') // read "((a,b),(c," or "((a,b),(e," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "((a,b),(e,(" (ambiguity resolution) { u = ::std::complex(a,b); - + x = ::std::complex(c); // "c" is actually "e" - + is.putback(ch); - + is >> y; // read "((a,b),(e,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(e,y)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -2739,7 +2731,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(e,y))" { o = octonion(u,v,x,y); @@ -2757,37 +2749,37 @@ namespace boost else // read "((a,b),(c,d" or "((a,b),(e,f" { is.putback(ch); - + is >> d; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c,d)" (ambiguity resolution) { u = ::std::complex(a,b); - + v = ::std::complex(c,d); - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c,d))" { o = octonion(u,v); @@ -2795,19 +2787,19 @@ namespace boost else if (cc == ',') // read "((a,b),(c,d)," { is >> x; // read "((a,b),(c,d),x - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c,d),x)" { o = octonion(u,v,x); @@ -2815,19 +2807,19 @@ namespace boost else if (cc == ',') // read "((a,b),(c,d),x," { is >> y; // read "((a,b),(c,d),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(c,d),x,y)" { o = octonion(u,v,x,y); @@ -2850,37 +2842,37 @@ namespace boost else if (cc == ',') // read "((a,b),(e,f," (ambiguity resolution) { p = ::boost::math::quaternion(a,b); // too late to backtrack - + is >> g; // read "((a,b),(e,f,g" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(e,f,g)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(e,f,g))" { q = ::boost::math::quaternion(c,d,g); // "c" is actually "e" and "d" is actually "f" - + o = octonion(p,q); } else // error @@ -2891,35 +2883,35 @@ namespace boost else if (cc == ',') // read "((a,b),(e,f,g," { is >> h; // read "((a,b),(e,f,g,h" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b),(e,f,g,h)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read ((a,b),(e,f,g,h))" { q = ::boost::math::quaternion(c,d,g,h); // "c" is actually "e" and "d" is actually "f" - + o = octonion(p,q); } else // error @@ -2962,31 +2954,31 @@ namespace boost else if (cc == ',') // read "((a,b," { is >> c; // read "((a,b,c" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c))" { o = octonion(a,b,c); @@ -2994,21 +2986,21 @@ namespace boost else if (cc == ',') // read "((a,b,c)," { p = ::boost::math::quaternion(a,b,c); - + is >> q; // read "((a,b,c),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c),q)" { o = octonion(p,q); @@ -3026,31 +3018,31 @@ namespace boost else if (cc == ',') // read "((a,b,c," { is >> d; // read "((a,b,c,d" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c,d)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c,d))" { o = octonion(a,b,c,d); @@ -3058,21 +3050,21 @@ namespace boost else if (cc == ',') // read "((a,b,c,d)," { p = ::boost::math::quaternion(a,b,c,d); - + is >> q; // read "((a,b,c,d),q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "((a,b,c,d),q)" { o = octonion(p,q); @@ -3112,21 +3104,21 @@ namespace boost else // read "(a" { is.putback(ch); - + is >> a; // we extract the first component - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a)" { o = octonion(a); @@ -3134,19 +3126,19 @@ namespace boost else if (cc == ',') // read "(a," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(a,(" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -3154,29 +3146,29 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(a,((" { p = ::boost::math::quaternion(a); - + is.putback(ch); - + is.putback(ch); // we backtrack twice, with the same value - + is >> q; // read "(a,q" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,q)" { o = octonion(p,q); @@ -3189,33 +3181,33 @@ namespace boost else // read "(a,(c" or "(a,(e" { is.putback(ch); - + is >> c; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c)" (ambiguity resolution) { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c))" { o = octonion(a,b,c); @@ -3223,15 +3215,15 @@ namespace boost else if (cc == ',') // read "(a,(c)," { u = ::std::complex(a); - + v = ::std::complex(c); - + is >> x; // read "(a,(c),x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; #ifdef BOOST_NO_STD_LOCALE @@ -3239,7 +3231,7 @@ namespace boost #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c),x)" { o = octonion(u,v,x); @@ -3247,19 +3239,19 @@ namespace boost else if (cc == ',') // read "(a,(c),x," { is >> y; // read "(a,(c),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c),x,y)" { o = octonion(u,v,x,y); @@ -3282,49 +3274,49 @@ namespace boost else if (cc == ',') // read "(a,(c," or "(a,(e," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(a,(e,(" (ambiguity resolution) { u = ::std::complex(a); - + x = ::std::complex(c); // "c" is actually "e" - + is.putback(ch); // we backtrack - + is >> y; // read "(a,(e,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,y)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,y))" { o = octonion(u,v,x,y); @@ -3342,33 +3334,33 @@ namespace boost else // read "(a,(c,d" or "(a,(e,f" { is.putback(ch); - + is >> d; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c,d)" (ambiguity resolution) { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c,d))" { o = octonion(a,b,c,d); @@ -3376,23 +3368,23 @@ namespace boost else if (cc == ',') // read "(a,(c,d)," { u = ::std::complex(a); - + v = ::std::complex(c,d); - + is >> x; // read "(a,(c,d),x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c,d),x)" { o = octonion(u,v,x); @@ -3400,19 +3392,19 @@ namespace boost else if (cc == ',') // read "(a,(c,d),x," { is >> y; // read "(a,(c,d),x,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(c,d),x,y)" { o = octonion(u,v,x,y); @@ -3435,37 +3427,37 @@ namespace boost else if (cc == ',') // read "(a,(e,f," (ambiguity resolution) { p = ::boost::math::quaternion(a); - + is >> g; // read "(a,(e,f,g" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,f,g)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,f,g))" { q = ::boost::math::quaternion(c,d,g); // "c" is actually "e" and "d" is actually "f" - + o = octonion(p,q); } else // error @@ -3476,35 +3468,35 @@ namespace boost else if (cc == ',') // read "(a,(e,f,g," { is >> h; // read "(a,(e,f,g,h" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,f,g,h)" { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,(e,f,g,h))" { q = ::boost::math::quaternion(c,d,g,h); // "c" is actually "e" and "d" is actually "f" - + o = octonion(p,q); } else // error @@ -3537,21 +3529,21 @@ namespace boost else // read "(a,b" or "(a,c" (ambiguity resolution) { is.putback(ch); - + is >> b; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b)" (ambiguity resolution) { o = octonion(a,b); @@ -3559,37 +3551,37 @@ namespace boost else if (cc == ',') // read "(a,b," or "(a,c," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(a,c,(" (ambiguity resolution) { u = ::std::complex(a); - + v = ::std::complex(b); // "b" is actually "c" - + is.putback(ch); // we backtrack - + is >> x; // read "(a,c,x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,c,x)" { o = octonion(u,v,x); @@ -3597,19 +3589,19 @@ namespace boost else if (cc == ',') // read "(a,c,x," { is >> y; // read "(a,c,x,y" // read "(a,c,x" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,c,x,y)" { o = octonion(u,v,x,y); @@ -3627,21 +3619,21 @@ namespace boost else // read "(a,b,c" or "(a,c,e" { is.putback(ch); - + is >> c; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c)" (ambiguity resolution) { o = octonion(a,b,c); @@ -3649,39 +3641,39 @@ namespace boost else if (cc == ',') // read "(a,b,c," or "(a,c,e," { is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == '(') // read "(a,c,e,(") (ambiguity resolution) { u = ::std::complex(a); - + v = ::std::complex(b); // "b" is actually "c" - + x = ::std::complex(c); // "c" is actually "e" - + is.putback(ch); // we backtrack - + is >> y; // read "(a,c,e,y" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,c,e,y)" { o = octonion(u,v,x,y); @@ -3694,21 +3686,21 @@ namespace boost else // read "(a,b,c,d" (ambiguity resolution) { is.putback(ch); // we backtrack - + is >> d; - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c,d)" { o = octonion(a,b,c,d); @@ -3716,19 +3708,19 @@ namespace boost else if (cc == ',') // read "(a,b,c,d," { is >> e; // read "(a,b,c,d,e" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c,d,e)" { o = octonion(a,b,c,d,e); @@ -3736,19 +3728,19 @@ namespace boost else if (cc == ',') // read "(a,b,c,d,e," { is >> f; // read "(a,b,c,d,e,f" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c,d,e,f)" { o = octonion(a,b,c,d,e,f); @@ -3756,19 +3748,19 @@ namespace boost else if (cc == ',') // read "(a,b,c,d,e,f," { is >> g; // read "(a,b,c,d,e,f,g" // read "(a,b,c,d,e,f" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c,d,e,f,g)" { o = octonion(a,b,c,d,e,f,g); @@ -3776,19 +3768,19 @@ namespace boost else if (cc == ',') // read "(a,b,c,d,e,f,g," { is >> h; // read "(a,b,c,d,e,f,g,h" // read "(a,b,c,d,e,f,g" // read "(a,b,c,d,e,f" - + if (!is.good()) goto finish; - + is >> ch; // get the next lexeme - + if (!is.good()) goto finish; - + #ifdef BOOST_NO_STD_LOCALE cc = ch; #else cc = ct.narrow(ch, char()); #endif /* BOOST_NO_STD_LOCALE */ - + if (cc == ')') // read "(a,b,c,d,e,f,g,h)" { o = octonion(a,b,c,d,e,f,g,h); @@ -3840,32 +3832,32 @@ namespace boost else // format: a { is.putback(ch); - + is >> a; // we extract the first component - + if (!is.good()) goto finish; - + o = octonion(a); } - + finish: return(is); } - - + + template ::std::basic_ostream & operator << ( ::std::basic_ostream & os, octonion const & o) { ::std::basic_ostringstream s; - + s.flags(os.flags()); #ifdef BOOST_NO_STD_LOCALE #else s.imbue(os.getloc()); #endif /* BOOST_NO_STD_LOCALE */ s.precision(os.precision()); - + s << '(' << o.R_component_1() << ',' << o.R_component_2() << ',' << o.R_component_3() << ',' @@ -3874,27 +3866,27 @@ namespace boost << o.R_component_6() << ',' << o.R_component_7() << ',' << o.R_component_8() << ')'; - + return os << s.str(); } - - + + // values - + template inline T real(octonion const & o) { return(o.real()); } - - + + template inline octonion unreal(octonion const & o) { return(o.unreal()); } - - + + #define BOOST_OCTONION_VALARRAY_LOADER \ using ::std::valarray; \ \ @@ -3908,47 +3900,47 @@ namespace boost temp[5] = o.R_component_6(); \ temp[6] = o.R_component_7(); \ temp[7] = o.R_component_8(); - - + + template inline T sup(octonion const & o) { #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP using ::std::abs; #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - + BOOST_OCTONION_VALARRAY_LOADER - + return((abs(temp).max)()); } - - + + template inline T l1(octonion const & o) { #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP using ::std::abs; #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - + BOOST_OCTONION_VALARRAY_LOADER - + return(abs(temp).sum()); } - - + + template inline T abs(const octonion & o) { #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP using ::std::abs; #endif /* BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP */ - + using ::std::sqrt; - + BOOST_OCTONION_VALARRAY_LOADER - + T maxim = (abs(temp).max)(); // overflow protection - + if (maxim == static_cast(0)) { return(maxim); @@ -3956,30 +3948,30 @@ namespace boost else { T mixam = static_cast(1)/maxim; // prefer multiplications over divisions - + temp *= mixam; - + temp *= temp; - + return(maxim*sqrt(temp.sum())); } - + //return(::std::sqrt(norm(o))); } - - + + #undef BOOST_OCTONION_VALARRAY_LOADER - - + + // Note: This is the Cayley norm, not the Euclidean norm... - + template inline T norm(octonion const & o) { return(real(o*conj(o))); } - - + + template inline octonion conj(octonion const & o) { @@ -3992,12 +3984,12 @@ namespace boost -o.R_component_7(), -o.R_component_8())); } - - + + // Note: There is little point, for the octonions, to introduce the equivalents // to the complex "arg" and the quaternionic "cylindropolar". - - + + template inline octonion spherical(T const & rho, T const & theta, @@ -4010,7 +4002,7 @@ namespace boost { using ::std::cos; using ::std::sin; - + //T a = cos(theta)*cos(phi1)*cos(phi2)*cos(phi3)*cos(phi4)*cos(phi5)*cos(phi6); //T b = sin(theta)*cos(phi1)*cos(phi2)*cos(phi3)*cos(phi4)*cos(phi5)*cos(phi6); //T c = sin(phi1)*cos(phi2)*cos(phi3)*cos(phi4)*cos(phi5)*cos(phi6); @@ -4019,40 +4011,40 @@ namespace boost //T f = sin(phi4)*cos(phi5)*cos(phi6); //T g = sin(phi5)*cos(phi6); //T h = sin(phi6); - + T courrant = static_cast(1); - + T h = sin(phi6); - + courrant *= cos(phi6); - + T g = sin(phi5)*courrant; - + courrant *= cos(phi5); - + T f = sin(phi4)*courrant; - + courrant *= cos(phi4); - + T e = sin(phi3)*courrant; - + courrant *= cos(phi3); - + T d = sin(phi2)*courrant; - + courrant *= cos(phi2); - + T c = sin(phi1)*courrant; - + courrant *= cos(phi1); - + T b = sin(theta)*courrant; T a = cos(theta)*courrant; - + return(rho*octonion(a,b,c,d,e,f,g,h)); } - - + + template inline octonion multipolar(T const & rho1, T const & theta1, @@ -4065,7 +4057,7 @@ namespace boost { using ::std::cos; using ::std::sin; - + T a = rho1*cos(theta1); T b = rho1*sin(theta1); T c = rho2*cos(theta2); @@ -4074,11 +4066,11 @@ namespace boost T f = rho3*sin(theta3); T g = rho4*cos(theta4); T h = rho4*sin(theta4); - + return(octonion(a,b,c,d,e,f,g,h)); } - - + + template inline octonion cylindrical(T const & r, T const & angle, @@ -4091,106 +4083,106 @@ namespace boost { using ::std::cos; using ::std::sin; - + T a = r*cos(angle); T b = r*sin(angle); - + return(octonion(a,b,h1,h2,h3,h4,h5,h6)); } - - + + template inline octonion exp(octonion const & o) { using ::std::exp; using ::std::cos; - + using ::boost::math::sinc_pi; - + T u = exp(real(o)); - + T z = abs(unreal(o)); - + T w = sinc_pi(z); - + return(u*octonion(cos(z), w*o.R_component_2(), w*o.R_component_3(), w*o.R_component_4(), w*o.R_component_5(), w*o.R_component_6(), w*o.R_component_7(), w*o.R_component_8())); } - - + + template inline octonion cos(octonion const & o) { using ::std::sin; using ::std::cos; using ::std::cosh; - + using ::boost::math::sinhc_pi; - + T z = abs(unreal(o)); - + T w = -sin(o.real())*sinhc_pi(z); - + return(octonion(cos(o.real())*cosh(z), w*o.R_component_2(), w*o.R_component_3(), w*o.R_component_4(), w*o.R_component_5(), w*o.R_component_6(), w*o.R_component_7(), w*o.R_component_8())); } - - + + template inline octonion sin(octonion const & o) { using ::std::sin; using ::std::cos; using ::std::cosh; - + using ::boost::math::sinhc_pi; - + T z = abs(unreal(o)); - + T w = +cos(o.real())*sinhc_pi(z); - + return(octonion(sin(o.real())*cosh(z), w*o.R_component_2(), w*o.R_component_3(), w*o.R_component_4(), w*o.R_component_5(), w*o.R_component_6(), w*o.R_component_7(), w*o.R_component_8())); } - - + + template inline octonion tan(octonion const & o) { return(sin(o)/cos(o)); } - - + + template inline octonion cosh(octonion const & o) { return((exp(+o)+exp(-o))/static_cast(2)); } - - + + template inline octonion sinh(octonion const & o) { return((exp(+o)-exp(-o))/static_cast(2)); } - - + + template inline octonion tanh(octonion const & o) { return(sinh(o)/cosh(o)); } - - + + template octonion pow(octonion const & o, int n) @@ -4198,16 +4190,16 @@ namespace boost if (n > 1) { int m = n>>1; - + octonion result = pow(o, m); - + result *= result; - + if (n != (m<<1)) { result *= o; // n odd } - + return(result); } else if (n == 1) @@ -4223,13 +4215,13 @@ namespace boost return(pow(octonion(static_cast(1))/o,-n)); } } - - + + // helper templates for converting copy constructors (definition) - + namespace detail { - + template< typename T, typename U >