...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template<typename T> octonion<T> operator + (octonion<T> const & o);
This unary operator simply returns o.
template<typename T> octonion<T> operator - (octonion<T> const & o);
This unary operator returns the opposite of o.
template<typename T> octonion<T> operator + (T const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator + (octonion<T> const & lhs, T const & rhs); template<typename T> octonion<T> operator + (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator + (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> octonion<T> operator + (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator + (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> octonion<T> operator + (octonion<T> const & lhs, octonion<T> const & rhs);
These operators return octonion<T>(lhs) +=
rhs
.
template<typename T> octonion<T> operator - (T const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator - (octonion<T> const & lhs, T const & rhs); template<typename T> octonion<T> operator - (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator - (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> octonion<T> operator - (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator - (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> octonion<T> operator - (octonion<T> const & lhs, octonion<T> const & rhs);
These operators return octonion<T>(lhs) -=
rhs
.
template<typename T> octonion<T> operator * (T const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator * (octonion<T> const & lhs, T const & rhs); template<typename T> octonion<T> operator * (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator * (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> octonion<T> operator * (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator * (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> octonion<T> operator * (octonion<T> const & lhs, octonion<T> const & rhs);
These operators return octonion<T>(lhs) *=
rhs
.
template<typename T> octonion<T> operator / (T const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator / (octonion<T> const & lhs, T const & rhs); template<typename T> octonion<T> operator / (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator / (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> octonion<T> operator / (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> octonion<T> operator / (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> octonion<T> operator / (octonion<T> const & lhs, octonion<T> const & rhs);
These operators return octonion<T>(lhs) /=
rhs
. It is of course still an error
to divide by zero...
template<typename T> bool operator == (T const & lhs, octonion<T> const & rhs); template<typename T> bool operator == (octonion<T> const & lhs, T const & rhs); template<typename T> bool operator == (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> bool operator == (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> bool operator == (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> bool operator == (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> bool operator == (octonion<T> const & lhs, octonion<T> const & rhs);
These return true if and only if the four components of octonion<T>(lhs)
are
equal to their counterparts in octonion<T>(rhs)
. As
with any floating-type entity, this is essentially meaningless.
template<typename T> bool operator != (T const & lhs, octonion<T> const & rhs); template<typename T> bool operator != (octonion<T> const & lhs, T const & rhs); template<typename T> bool operator != (::std::complex<T> const & lhs, octonion<T> const & rhs); template<typename T> bool operator != (octonion<T> const & lhs, ::std::complex<T> const & rhs); template<typename T> bool operator != (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs); template<typename T> bool operator != (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs); template<typename T> bool operator != (octonion<T> const & lhs, octonion<T> const & rhs);
These return true if and only if octonion<T>(lhs) ==
octonion<T>(rhs)
is false. As with any floating-type entity,
this is essentially meaningless.
template<typename T, typename charT, class traits> ::std::basic_istream<charT,traits> & operator >> (::std::basic_istream<charT,traits> & is, octonion<T> & o);
Extracts an octonion o
. We
accept any format which seems reasonable. However, since this leads to a great
many ambiguities, decisions were made to lift these. In case of doubt, stick
to lists of reals.
The input values must be convertible to T. If bad input is encountered, calls
is.setstate(ios::failbit)
(which may throw ios::failure
(27.4.5.3)).
Returns is
.
template<typename T, typename charT, class traits> ::std::basic_ostream<charT,traits> & operator << (::std::basic_ostream<charT,traits> & os, octonion<T> const & o);
Inserts the octonion o
onto
the stream os
as if it were
implemented as follows:
template<typename T, typename charT, class traits> ::std::basic_ostream<charT,traits> & operator << ( ::std::basic_ostream<charT,traits> & os, octonion<T> const & o) { ::std::basic_ostringstream<charT,traits> s; s.flags(os.flags()); s.imbue(os.getloc()); s.precision(os.precision()); s << '(' << 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() << ')'; return os << s.str(); }