math-octonion.qbk 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. [/macro definitions specific to octonions]
  2. [def __R ['[*R]]]
  3. [def __C ['[*C]]]
  4. [def __H ['[*H]]]
  5. [def __O ['[*O]]]
  6. [def __R3 ['[*'''R<superscript>3</superscript>''']]]
  7. [def __R4 ['[*'''R<superscript>4</superscript>''']]]
  8. [def __octulple ('''&#x03B1;,&#x03B2;,&#x03B3;,&#x03B4;,&#x03B5;,&#x03B6;,&#x03B7;,&#x03B8;''')]
  9. [def __oct_formula ['[^o = '''&#x03B1; + &#x03B2;i + &#x03B3;j + &#x03B4;k + &#x03B5;e' + &#x03B6;i' + &#x03B7;j' + &#x03B8;k' ''']]]
  10. [def __oct_complex_formula ['[^o = ('''&#x03B1; + &#x03B2;i) + (&#x03B3; + &#x03B4;i)j + (&#x03B5; + &#x03B6;i)e' + (&#x03B7; - &#x03B8;i)j' ''']]]
  11. [def __oct_quat_formula ['[^o = ('''&#x03B1; + &#x03B2;i + &#x03B3;j + &#x03B4;k) + (&#x03B5; + &#x03B6;i + &#x03B7;j - &#x03B8;j)e' ''']]]
  12. [def __oct_not_equal ['[^x(yz) '''&#x2260;''' (xy)z]]]
  13. [mathpart octonions Octonions]
  14. [section:oct_overview Overview]
  15. Octonions, like [link quaternions quaternions], are a relative of complex numbers.
  16. Octonions see some use in theoretical physics.
  17. In practical terms, an octonion is simply an octuple of real numbers __octulple,
  18. which we can write in the form __oct_formula, where ['[^i]], ['[^j]] and ['[^k]]
  19. are the same objects as for quaternions, and ['[^e']], ['[^i']], ['[^j']] and ['[^k']]
  20. are distinct objects which play essentially the same kind of role as ['[^i]] (or ['[^j]] or ['[^k]]).
  21. Addition and a multiplication is defined on the set of octonions,
  22. which generalize their quaternionic counterparts. The main novelty this time
  23. is that [*the multiplication is not only not commutative, is now not even
  24. associative] (i.e. there are octonions ['[^x]], ['[^y]] and ['[^z]] such that __oct_not_equal).
  25. A way of remembering things is by using the following multiplication table:
  26. [$../octonion/graphics/octonion_blurb17.jpeg]
  27. Octonions (and their kin) are described in far more details in this other
  28. [@../quaternion/TQE.pdf document] (with [@../quaternion/TQE_EA.pdf errata and addenda]).
  29. Some traditional constructs, such as the exponential, carry over without too
  30. much change into the realms of octonions, but other, such as taking a square root,
  31. do not (the fact that the exponential has a closed form is a result of the
  32. author, but the fact that the exponential exists at all for octonions is known
  33. since quite a long time ago).
  34. [endsect] [/section:oct_overview Overview]
  35. [section:oct_header Header File]
  36. The interface and implementation are both supplied by the header file
  37. [@../../../../boost/math/octonion.hpp octonion.hpp].
  38. [endsect]
  39. [section:oct_synopsis Synopsis]
  40. namespace boost{ namespace math{
  41. template<typename T> class ``[link math_toolkit.octonion octonion]``;
  42. template<> class ``[link math_toolkit.oct_specialization octonion<float>]``;
  43. template<> class ``[link math_octonion_double octonion<double>]``;
  44. template<> class ``[link math_octonion_long_double octonion<long double>]``;
  45. // operators
  46. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (T const & lhs, octonion<T> const & rhs);
  47. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (octonion<T> const & lhs, T const & rhs);
  48. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  49. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  50. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  51. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  52. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_addition_operators operator +]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  53. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (T const & lhs, octonion<T> const & rhs);
  54. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (octonion<T> const & lhs, T const & rhs);
  55. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  56. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  57. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  58. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  59. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_subtraction_operators operator -]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  60. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (T const & lhs, octonion<T> const & rhs);
  61. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (octonion<T> const & lhs, T const & rhs);
  62. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  63. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  64. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  65. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  66. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_multiplication_operators operator *]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  67. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (T const & lhs, octonion<T> const & rhs);
  68. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (octonion<T> const & lhs, T const & rhs);
  69. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  70. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  71. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  72. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  73. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.binary_division_operators operator /]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  74. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.unary_plus_and_minus_operators operator +]`` (octonion<T> const & o);
  75. template<typename T> octonion<T> ``[link math_toolkit.oct_non_mem.unary_plus_and_minus_operators operator -]`` (octonion<T> const & o);
  76. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (T const & lhs, octonion<T> const & rhs);
  77. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (octonion<T> const & lhs, T const & rhs);
  78. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  79. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  80. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  81. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  82. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_equality_operators operator ==]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  83. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (T const & lhs, octonion<T> const & rhs);
  84. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (octonion<T> const & lhs, T const & rhs);
  85. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (::std::complex<T> const & lhs, octonion<T> const & rhs);
  86. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  87. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  88. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  89. template<typename T> bool ``[link math_toolkit.oct_non_mem.binary_inequality_operators operator !=]`` (octonion<T> const & lhs, octonion<T> const & rhs);
  90. template<typename T, typename charT, class traits>
  91. ::std::basic_istream<charT,traits> & ``[link math_toolkit.oct_non_mem.stream_extractor operator >>]`` (::std::basic_istream<charT,traits> & is, octonion<T> & o);
  92. template<typename T, typename charT, class traits>
  93. ::std::basic_ostream<charT,traits> & ``[link math_toolkit.oct_non_mem.stream_inserter operator <<]`` (::std::basic_ostream<charT,traits> & os, octonion<T> const & o);
  94. // values
  95. template<typename T> T ``[link math_toolkit.oct_value_ops.real_and_unreal real]``(octonion<T> const & o);
  96. template<typename T> octonion<T> ``[link math_toolkit.oct_value_ops.real_and_unreal unreal]``(octonion<T> const & o);
  97. template<typename T> T ``[link math_toolkit.oct_value_ops.sup sup]``(octonion<T> const & o);
  98. template<typename T> T ``[link math_toolkit.oct_value_ops.l1 l1]``(octonion<T>const & o);
  99. template<typename T> T ``[link math_toolkit.oct_value_ops.abs abs]``(octonion<T> const & o);
  100. template<typename T> T ``[link math_toolkit.oct_value_ops.norm norm]``(octonion<T>const & o);
  101. template<typename T> octonion<T> ``[link math_toolkit.oct_value_ops.conj conj]``(octonion<T> const & o);
  102. template<typename T> octonion<T> ``[link math_toolkit.oct_create spherical]``(T const & rho, T const & theta, T const & phi1, T const & phi2, T const & phi3, T const & phi4, T const & phi5, T const & phi6);
  103. template<typename T> octonion<T> ``[link math_toolkit.oct_create multipolar]``(T const & rho1, T const & theta1, T const & rho2, T const & theta2, T const & rho3, T const & theta3, T const & rho4, T const & theta4);
  104. template<typename T> octonion<T> ``[link math_toolkit.oct_create cylindrical]``(T const & r, T const & angle, T const & h1, T const & h2, T const & h3, T const & h4, T const & h5, T const & h6);
  105. // transcendentals
  106. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.exp exp]``(octonion<T> const & o);
  107. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.cos cos]``(octonion<T> const & o);
  108. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.sin sin]``(octonion<T> const & o);
  109. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.tan tan]``(octonion<T> const & o);
  110. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.cosh cosh]``(octonion<T> const & o);
  111. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.sinh sinh]``(octonion<T> const & o);
  112. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.tanh tanh]``(octonion<T> const & o);
  113. template<typename T> octonion<T> ``[link math_toolkit.oct_trans.pow pow]``(octonion<T> const & o, int n);
  114. } } // namespaces
  115. [endsect] [/section:oct_header Header File]
  116. [section:octonion Template Class octonion]
  117. namespace boost{ namespace math {
  118. template<typename T>
  119. class octonion
  120. {
  121. public:
  122. typedef T value_type;
  123. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), T const & requested_d = T(), T const & requested_e = T(), T const & requested_f = T(), T const & requested_g = T(), T const & requested_h = T());
  124. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::std::complex<T> const & z0, ::std::complex<T> const & z1 = ::std::complex<T>(), ::std::complex<T> const & z2 = ::std::complex<T>(), ::std::complex<T> const & z3 = ::std::complex<T>());
  125. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::boost::math::quaternion<T> const & q0, ::boost::math::quaternion<T> const & q1 = ::boost::math::quaternion<T>());
  126. template<typename X>
  127. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<X> const & a_recopier);
  128. T ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts real]``() const;
  129. octonion<T> ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts unreal]``() const;
  130. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_1]``() const;
  131. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_2]``() const;
  132. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_3]``() const;
  133. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_4]``() const;
  134. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_5]``() const;
  135. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_6]``() const;
  136. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_7]``() const;
  137. T ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_8]``() const;
  138. ::std::complex<T> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_1]``() const;
  139. ::std::complex<T> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_2]``() const;
  140. ::std::complex<T> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_3]``() const;
  141. ::std::complex<T> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_4]``() const;
  142. ::boost::math::quaternion<T> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_1]``() const;
  143. ::boost::math::quaternion<T> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_2]``() const;
  144. octonion<T> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<T> const & a_affecter);
  145. template<typename X>
  146. octonion<T> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<X> const & a_affecter);
  147. octonion<T> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (T const & a_affecter);
  148. octonion<T> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::std::complex<T> const & a_affecter);
  149. octonion<T> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::boost::math::quaternion<T> const & a_affecter);
  150. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (T const & rhs);
  151. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::std::complex<T> const & rhs);
  152. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::boost::math::quaternion<T> const & rhs);
  153. template<typename X>
  154. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (octonion<X> const & rhs);
  155. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (T const & rhs);
  156. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::std::complex<T> const & rhs);
  157. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::boost::math::quaternion<T> const & rhs);
  158. template<typename X>
  159. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (octonion<X> const & rhs);
  160. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (T const & rhs);
  161. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::std::complex<T> const & rhs);
  162. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::boost::math::quaternion<T> const & rhs);
  163. template<typename X>
  164. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (octonion<X> const & rhs);
  165. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (T const & rhs);
  166. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::std::complex<T> const & rhs);
  167. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::boost::math::quaternion<T> const & rhs);
  168. template<typename X>
  169. octonion<T> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (octonion<X> const & rhs);
  170. };
  171. } } // namespaces
  172. [endsect] [/section:octonion Template Class octonion]
  173. [section:oct_specialization Octonion Specializations]
  174. namespace boost{ namespace math{
  175. template<>
  176. class octonion<float>
  177. {
  178. public:
  179. typedef float value_type;
  180. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(float const & requested_a = 0.0f, float const & requested_b = 0.0f, float const & requested_c = 0.0f, float const & requested_d = 0.0f, float const & requested_e = 0.0f, float const & requested_f = 0.0f, float const & requested_g = 0.0f, float const & requested_h = 0.0f);
  181. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::std::complex<float> const & z0, ::std::complex<float> const & z1 = ::std::complex<float>(), ::std::complex<float> const & z2 = ::std::complex<float>(), ::std::complex<float> const & z3 = ::std::complex<float>());
  182. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::boost::math::quaternion<float> const & q0, ::boost::math::quaternion<float> const & q1 = ::boost::math::quaternion<float>());
  183. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<double> const & a_recopier);
  184. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<long double> const & a_recopier);
  185. float ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts real]``() const;
  186. octonion<float> ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts unreal]``() const;
  187. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_1]``() const;
  188. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_2]``() const;
  189. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_3]``() const;
  190. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_4]``() const;
  191. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_5]``() const;
  192. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_6]``() const;
  193. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_7]``() const;
  194. float ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_8]``() const;
  195. ::std::complex<float> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_1]``() const;
  196. ::std::complex<float> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_2]``() const;
  197. ::std::complex<float> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_3]``() const;
  198. ::std::complex<float> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_4]``() const;
  199. ::boost::math::quaternion<float> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_1]``() const;
  200. ::boost::math::quaternion<float> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_2]``() const;
  201. octonion<float> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<float> const & a_affecter);
  202. template<typename X>
  203. octonion<float> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<X> const & a_affecter);
  204. octonion<float> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (float const & a_affecter);
  205. octonion<float> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::std::complex<float> const & a_affecter);
  206. octonion<float> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::boost::math::quaternion<float> const & a_affecter);
  207. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (float const & rhs);
  208. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::std::complex<float> const & rhs);
  209. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::boost::math::quaternion<float> const & rhs);
  210. template<typename X>
  211. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (octonion<X> const & rhs);
  212. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (float const & rhs);
  213. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::std::complex<float> const & rhs);
  214. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::boost::math::quaternion<float> const & rhs);
  215. template<typename X>
  216. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (octonion<X> const & rhs);
  217. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (float const & rhs);
  218. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::std::complex<float> const & rhs);
  219. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::boost::math::quaternion<float> const & rhs);
  220. template<typename X>
  221. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (octonion<X> const & rhs);
  222. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (float const & rhs);
  223. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::std::complex<float> const & rhs);
  224. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::boost::math::quaternion<float> const & rhs);
  225. template<typename X>
  226. octonion<float> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (octonion<X> const & rhs);
  227. };
  228. [#math_octonion_double]
  229. template<>
  230. class octonion<double>
  231. {
  232. public:
  233. typedef double value_type;
  234. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(double const & requested_a = 0.0, double const & requested_b = 0.0, double const & requested_c = 0.0, double const & requested_d = 0.0, double const & requested_e = 0.0, double const & requested_f = 0.0, double const & requested_g = 0.0, double const & requested_h = 0.0);
  235. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::std::complex<double> const & z0, ::std::complex<double> const & z1 = ::std::complex<double>(), ::std::complex<double> const & z2 = ::std::complex<double>(), ::std::complex<double> const & z3 = ::std::complex<double>());
  236. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(::boost::math::quaternion<double> const & q0, ::boost::math::quaternion<double> const & q1 = ::boost::math::quaternion<double>());
  237. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<float> const & a_recopier);
  238. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<long double> const & a_recopier);
  239. double ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts real]``() const;
  240. octonion<double> ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts unreal]``() const;
  241. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_1]``() const;
  242. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_2]``() const;
  243. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_3]``() const;
  244. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_4]``() const;
  245. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_5]``() const;
  246. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_6]``() const;
  247. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_7]``() const;
  248. double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_8]``() const;
  249. ::std::complex<double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_1]``() const;
  250. ::std::complex<double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_2]``() const;
  251. ::std::complex<double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_3]``() const;
  252. ::std::complex<double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_4]``() const;
  253. ::boost::math::quaternion<double> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_1]``() const;
  254. ::boost::math::quaternion<double> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_2]``() const;
  255. octonion<double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<double> const & a_affecter);
  256. template<typename X>
  257. octonion<double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<X> const & a_affecter);
  258. octonion<double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (double const & a_affecter);
  259. octonion<double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::std::complex<double> const & a_affecter);
  260. octonion<double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::boost::math::quaternion<double> const & a_affecter);
  261. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (double const & rhs);
  262. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::std::complex<double> const & rhs);
  263. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::boost::math::quaternion<double> const & rhs);
  264. template<typename X>
  265. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (octonion<X> const & rhs);
  266. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (double const & rhs);
  267. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::std::complex<double> const & rhs);
  268. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::boost::math::quaternion<double> const & rhs);
  269. template<typename X>
  270. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (octonion<X> const & rhs);
  271. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (double const & rhs);
  272. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::std::complex<double> const & rhs);
  273. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::boost::math::quaternion<double> const & rhs);
  274. template<typename X>
  275. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (octonion<X> const & rhs);
  276. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (double const & rhs);
  277. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::std::complex<double> const & rhs);
  278. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::boost::math::quaternion<double> const & rhs);
  279. template<typename X>
  280. octonion<double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (octonion<X> const & rhs);
  281. };
  282. [#math_octonion_long_double]
  283. template<>
  284. class octonion<long double>
  285. {
  286. public:
  287. typedef long double value_type;
  288. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(long double const & requested_a = 0.0L, long double const & requested_b = 0.0L, long double const & requested_c = 0.0L, long double const & requested_d = 0.0L, long double const & requested_e = 0.0L, long double const & requested_f = 0.0L, long double const & requested_g = 0.0L, long double const & requested_h = 0.0L);
  289. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``( ::std::complex<long double> const & z0, ::std::complex<long double> const & z1 = ::std::complex<long double>(), ::std::complex<long double> const & z2 = ::std::complex<long double>(), ::std::complex<long double> const & z3 = ::std::complex<long double>());
  290. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``( ::boost::math::quaternion<long double> const & q0, ::boost::math::quaternion<long double> const & z1 = ::boost::math::quaternion<long double>());
  291. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<float> const & a_recopier);
  292. explicit ``[link math_toolkit.oct_mem_fun.constructors octonion]``(octonion<double> const & a_recopier);
  293. long double ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts real]``() const;
  294. octonion<long double> ``[link math_toolkit.oct_mem_fun.real_and_unreal_parts unreal]``() const;
  295. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_1]``() const;
  296. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_2]``() const;
  297. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_3]``() const;
  298. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_4]``() const;
  299. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_5]``() const;
  300. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_6]``() const;
  301. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_7]``() const;
  302. long double ``[link math_toolkit.oct_mem_fun.individual_real_components R_component_8]``() const;
  303. ::std::complex<long double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_1]``() const;
  304. ::std::complex<long double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_2]``() const;
  305. ::std::complex<long double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_3]``() const;
  306. ::std::complex<long double> ``[link math_toolkit.oct_mem_fun.individual_complex_components C_component_4]``() const;
  307. ::boost::math::quaternion<long double> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_1]``() const;
  308. ::boost::math::quaternion<long double> ``[link math_toolkit.oct_mem_fun.individual_quaternion_components H_component_2]``() const;
  309. octonion<long double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<long double> const & a_affecter);
  310. template<typename X>
  311. octonion<long double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (octonion<X> const & a_affecter);
  312. octonion<long double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (long double const & a_affecter);
  313. octonion<long double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::std::complex<long double> const & a_affecter);
  314. octonion<long double> & ``[link math_toolkit.oct_mem_fun.assignment_operators operator =]`` (::boost::math::quaternion<long double> const & a_affecter);
  315. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (long double const & rhs);
  316. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::std::complex<long double> const & rhs);
  317. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (::boost::math::quaternion<long double> const & rhs);
  318. template<typename X>
  319. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator +=]`` (octonion<X> const & rhs);
  320. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (long double const & rhs);
  321. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::std::complex<long double> const & rhs);
  322. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (::boost::math::quaternion<long double> const & rhs);
  323. template<typename X>
  324. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator -=]`` (octonion<X> const & rhs);
  325. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (long double const & rhs);
  326. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::std::complex<long double> const & rhs);
  327. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (::boost::math::quaternion<long double> const & rhs);
  328. template<typename X>
  329. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator *=]`` (octonion<X> const & rhs);
  330. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (long double const & rhs);
  331. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::std::complex<long double> const & rhs);
  332. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (::boost::math::quaternion<long double> const & rhs);
  333. template<typename X>
  334. octonion<long double> & ``[link math_toolkit.oct_mem_fun.other_member_operators operator /=]`` (octonion<X> const & rhs);
  335. };
  336. } } // namespaces
  337. [endsect] [/section:oct_specialization Octonion Specializations]
  338. [section:oct_typedefs Octonion Member Typedefs]
  339. [*value_type]
  340. Template version:
  341. typedef T value_type;
  342. Float specialization version:
  343. typedef float value_type;
  344. Double specialization version:
  345. typedef double value_type;
  346. Long double specialization version:
  347. typedef long double value_type;
  348. These provide easy access to the type the template is built upon.
  349. [endsect] [/section:oct_typedefs Octonion Member Typedefs]
  350. [section:oct_mem_fun Octonion Member Functions]
  351. [h3 Constructors]
  352. Template version:
  353. explicit octonion(T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), T const & requested_d = T(), T const & requested_e = T(), T const & requested_f = T(), T const & requested_g = T(), T const & requested_h = T());
  354. explicit octonion(::std::complex<T> const & z0, ::std::complex<T> const & z1 = ::std::complex<T>(), ::std::complex<T> const & z2 = ::std::complex<T>(), ::std::complex<T> const & z3 = ::std::complex<T>());
  355. explicit octonion(::boost::math::quaternion<T> const & q0, ::boost::math::quaternion<T> const & q1 = ::boost::math::quaternion<T>());
  356. template<typename X>
  357. explicit octonion(octonion<X> const & a_recopier);
  358. Float specialization version:
  359. explicit octonion(float const & requested_a = 0.0f, float const & requested_b = 0.0f, float const & requested_c = 0.0f, float const & requested_d = 0.0f, float const & requested_e = 0.0f, float const & requested_f = 0.0f, float const & requested_g = 0.0f, float const & requested_h = 0.0f);
  360. explicit octonion(::std::complex<float> const & z0, ::std::complex<float> const & z1 = ::std::complex<float>(), ::std::complex<float> const & z2 = ::std::complex<float>(), ::std::complex<float> const & z3 = ::std::complex<float>());
  361. explicit octonion(::boost::math::quaternion<float> const & q0, ::boost::math::quaternion<float> const & q1 = ::boost::math::quaternion<float>());
  362. explicit octonion(octonion<double> const & a_recopier);
  363. explicit octonion(octonion<long double> const & a_recopier);
  364. Double specialization version:
  365. explicit octonion(double const & requested_a = 0.0, double const & requested_b = 0.0, double const & requested_c = 0.0, double const & requested_d = 0.0, double const & requested_e = 0.0, double const & requested_f = 0.0, double const & requested_g = 0.0, double const & requested_h = 0.0);
  366. explicit octonion(::std::complex<double> const & z0, ::std::complex<double> const & z1 = ::std::complex<double>(), ::std::complex<double> const & z2 = ::std::complex<double>(), ::std::complex<double> const & z3 = ::std::complex<double>());
  367. explicit octonion(::boost::math::quaternion<double> const & q0, ::boost::math::quaternion<double> const & q1 = ::boost::math::quaternion<double>());
  368. explicit octonion(octonion<float> const & a_recopier);
  369. explicit octonion(octonion<long double> const & a_recopier);
  370. Long double specialization version:
  371. explicit octonion(long double const & requested_a = 0.0L, long double const & requested_b = 0.0L, long double const & requested_c = 0.0L, long double const & requested_d = 0.0L, long double const & requested_e = 0.0L, long double const & requested_f = 0.0L, long double const & requested_g = 0.0L, long double const & requested_h = 0.0L);
  372. explicit octonion( ::std::complex<long double> const & z0, ::std::complex<long double> const & z1 = ::std::complex<long double>(), ::std::complex<long double> const & z2 = ::std::complex<long double>(), ::std::complex<long double> const & z3 = ::std::complex<long double>());
  373. explicit octonion(::boost::math::quaternion<long double> const & q0, ::boost::math::quaternion<long double> const & q1 = ::boost::math::quaternion<long double>());
  374. explicit octonion(octonion<float> const & a_recopier);
  375. explicit octonion(octonion<double> const & a_recopier);
  376. A default constructor is provided for each form, which initializes each component
  377. to the default values for their type (i.e. zero for floating numbers).
  378. This constructor can also accept one to eight base type arguments.
  379. A constructor is also provided to build octonions from one to four complex numbers
  380. sharing the same base type, and another taking one or two quaternions
  381. sharing the same base type. The unspecialized template also sports a
  382. templarized copy constructor, while the specialized forms have copy
  383. constructors from the other two specializations, which are explicit
  384. when a risk of precision loss exists. For the unspecialized form,
  385. the base type's constructors must not throw.
  386. Destructors and untemplated copy constructors (from the same type)
  387. are provided by the compiler. Converting copy constructors make use
  388. of a templated helper function in a "detail" subnamespace.
  389. [h3 Other member functions]
  390. [h4 Real and Unreal Parts]
  391. T real() const;
  392. octonion<T> unreal() const;
  393. Like complex number, octonions do have a meaningful notion of "real part",
  394. but unlike them there is no meaningful notion of "imaginary part".
  395. Instead there is an "unreal part" which itself is a octonion,
  396. and usually nothing simpler (as opposed to the complex number case).
  397. These are returned by the first two functions.
  398. [h4 Individual Real Components]
  399. T R_component_1() const;
  400. T R_component_2() const;
  401. T R_component_3() const;
  402. T R_component_4() const;
  403. T R_component_5() const;
  404. T R_component_6() const;
  405. T R_component_7() const;
  406. T R_component_8() const;
  407. A octonion having eight real components, these are returned by
  408. these eight functions. Hence real and R_component_1 return the same value.
  409. [h4 Individual Complex Components]
  410. ::std::complex<T> C_component_1() const;
  411. ::std::complex<T> C_component_2() const;
  412. ::std::complex<T> C_component_3() const;
  413. ::std::complex<T> C_component_4() const;
  414. A octonion likewise has four complex components. Actually, octonions
  415. are indeed a (left) vector field over the complexes, but beware, as
  416. for any octonion __oct_formula we also have __oct_complex_formula
  417. (note the [*minus] sign in the last factor).
  418. What the C_component_n functions return, however, are the complexes
  419. which could be used to build the octonion using the constructor, and
  420. [*not] the components of the octonion on the basis ['[^(1, j, e', j')]].
  421. [h4 Individual Quaternion Components]
  422. ::boost::math::quaternion<T> H_component_1() const;
  423. ::boost::math::quaternion<T> H_component_2() const;
  424. Likewise, for any octonion __oct_formula we also have __oct_quat_formula, though there
  425. is no meaningful vector-space-like structure based on the quaternions.
  426. What the H_component_n functions return are the quaternions which
  427. could be used to build the octonion using the constructor.
  428. [h3 Octonion Member Operators]
  429. [h4 Assignment Operators]
  430. octonion<T> & operator = (octonion<T> const & a_affecter);
  431. template<typename X>
  432. octonion<T> & operator = (octonion<X> const & a_affecter);
  433. octonion<T> & operator = (T const & a_affecter);
  434. octonion<T> & operator = (::std::complex<T> const & a_affecter);
  435. octonion<T> & operator = (::boost::math::quaternion<T> const & a_affecter);
  436. These perform the expected assignment, with type modification if
  437. necessary (for instance, assigning from a base type will set the
  438. real part to that value, and all other components to zero).
  439. For the unspecialized form, the base type's assignment operators must not throw.
  440. [h4 Other Member Operators]
  441. octonion<T> & operator += (T const & rhs)
  442. octonion<T> & operator += (::std::complex<T> const & rhs);
  443. octonion<T> & operator += (::boost::math::quaternion<T> const & rhs);
  444. template<typename X>
  445. octonion<T> & operator += (octonion<X> const & rhs);
  446. These perform the mathematical operation `(*this)+rhs` and store the result in
  447. `*this`. The unspecialized form has exception guards, which the specialized
  448. forms do not, so as to insure exception safety. For the unspecialized form,
  449. the base type's assignment operators must not throw.
  450. octonion<T> & operator -= (T const & rhs)
  451. octonion<T> & operator -= (::std::complex<T> const & rhs);
  452. octonion<T> & operator -= (::boost::math::quaternion<T> const & rhs);
  453. template<typename X>
  454. octonion<T> & operator -= (octonion<X> const & rhs);
  455. These perform the mathematical operation `(*this)-rhs` and store the result
  456. in `*this`. The unspecialized form has exception guards, which the
  457. specialized forms do not, so as to insure exception safety.
  458. For the unspecialized form, the base type's assignment operators must not throw.
  459. octonion<T> & operator *= (T const & rhs)
  460. octonion<T> & operator *= (::std::complex<T> const & rhs);
  461. octonion<T> & operator *= (::boost::math::quaternion<T> const & rhs);
  462. template<typename X>
  463. octonion<T> & operator *= (octonion<X> const & rhs);
  464. These perform the mathematical operation `(*this)*rhs` in this order
  465. (order is important as multiplication is not commutative for octonions)
  466. and store the result in `*this`. The unspecialized form has exception guards,
  467. which the specialized forms do not, so as to insure exception safety.
  468. For the unspecialized form, the base type's assignment operators must
  469. not throw. Also, for clarity's sake, you should always group the
  470. factors in a multiplication by groups of two, as the multiplication is
  471. not even associative on the octonions (though there are of course cases
  472. where this does not matter, it usually does).
  473. octonion<T> & operator /= (T const & rhs)
  474. octonion<T> & operator /= (::std::complex<T> const & rhs);
  475. octonion<T> & operator /= (::boost::math::quaternion<T> const & rhs);
  476. template<typename X>
  477. octonion<T> & operator /= (octonion<X> const & rhs);
  478. These perform the mathematical operation `(*this)*inverse_of(rhs)`
  479. in this order (order is important as multiplication is not commutative
  480. for octonions) and store the result in `*this`. The unspecialized form
  481. has exception guards, which the specialized forms do not, so as to
  482. insure exception safety. For the unspecialized form, the base
  483. type's assignment operators must not throw. As for the multiplication,
  484. remember to group any two factors using parenthesis.
  485. [endsect] [/section:oct_mem_fun Octonion Member Functions]
  486. [section:oct_non_mem Octonion Non-Member Operators]
  487. [h4 Unary Plus and Minus Operators]
  488. template<typename T> octonion<T> operator + (octonion<T> const & o);
  489. This unary operator simply returns o.
  490. template<typename T> octonion<T> operator - (octonion<T> const & o);
  491. This unary operator returns the opposite of o.
  492. [h4 Binary Addition Operators]
  493. template<typename T> octonion<T> operator + (T const & lhs, octonion<T> const & rhs);
  494. template<typename T> octonion<T> operator + (octonion<T> const & lhs, T const & rhs);
  495. template<typename T> octonion<T> operator + (::std::complex<T> const & lhs, octonion<T> const & rhs);
  496. template<typename T> octonion<T> operator + (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  497. template<typename T> octonion<T> operator + (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  498. template<typename T> octonion<T> operator + (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  499. template<typename T> octonion<T> operator + (octonion<T> const & lhs, octonion<T> const & rhs);
  500. These operators return `octonion<T>(lhs) += rhs`.
  501. [h4 Binary Subtraction Operators]
  502. template<typename T> octonion<T> operator - (T const & lhs, octonion<T> const & rhs);
  503. template<typename T> octonion<T> operator - (octonion<T> const & lhs, T const & rhs);
  504. template<typename T> octonion<T> operator - (::std::complex<T> const & lhs, octonion<T> const & rhs);
  505. template<typename T> octonion<T> operator - (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  506. template<typename T> octonion<T> operator - (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  507. template<typename T> octonion<T> operator - (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  508. template<typename T> octonion<T> operator - (octonion<T> const & lhs, octonion<T> const & rhs);
  509. These operators return `octonion<T>(lhs) -= rhs`.
  510. [h4 Binary Multiplication Operators]
  511. template<typename T> octonion<T> operator * (T const & lhs, octonion<T> const & rhs);
  512. template<typename T> octonion<T> operator * (octonion<T> const & lhs, T const & rhs);
  513. template<typename T> octonion<T> operator * (::std::complex<T> const & lhs, octonion<T> const & rhs);
  514. template<typename T> octonion<T> operator * (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  515. template<typename T> octonion<T> operator * (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  516. template<typename T> octonion<T> operator * (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  517. template<typename T> octonion<T> operator * (octonion<T> const & lhs, octonion<T> const & rhs);
  518. These operators return `octonion<T>(lhs) *= rhs`.
  519. [h4 Binary Division Operators]
  520. template<typename T> octonion<T> operator / (T const & lhs, octonion<T> const & rhs);
  521. template<typename T> octonion<T> operator / (octonion<T> const & lhs, T const & rhs);
  522. template<typename T> octonion<T> operator / (::std::complex<T> const & lhs, octonion<T> const & rhs);
  523. template<typename T> octonion<T> operator / (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  524. template<typename T> octonion<T> operator / (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  525. template<typename T> octonion<T> operator / (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  526. template<typename T> octonion<T> operator / (octonion<T> const & lhs, octonion<T> const & rhs);
  527. These operators return `octonion<T>(lhs) /= rhs`. It is of course still an
  528. error to divide by zero...
  529. [h4 Binary Equality Operators]
  530. template<typename T> bool operator == (T const & lhs, octonion<T> const & rhs);
  531. template<typename T> bool operator == (octonion<T> const & lhs, T const & rhs);
  532. template<typename T> bool operator == (::std::complex<T> const & lhs, octonion<T> const & rhs);
  533. template<typename T> bool operator == (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  534. template<typename T> bool operator == (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  535. template<typename T> bool operator == (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  536. template<typename T> bool operator == (octonion<T> const & lhs, octonion<T> const & rhs);
  537. These return true if and only if the four components of `octonion<T>(lhs)`
  538. are equal to their counterparts in `octonion<T>(rhs)`. As with any
  539. floating-type entity, this is essentially meaningless.
  540. [h4 Binary Inequality Operators]
  541. template<typename T> bool operator != (T const & lhs, octonion<T> const & rhs);
  542. template<typename T> bool operator != (octonion<T> const & lhs, T const & rhs);
  543. template<typename T> bool operator != (::std::complex<T> const & lhs, octonion<T> const & rhs);
  544. template<typename T> bool operator != (octonion<T> const & lhs, ::std::complex<T> const & rhs);
  545. template<typename T> bool operator != (::boost::math::quaternion<T> const & lhs, octonion<T> const & rhs);
  546. template<typename T> bool operator != (octonion<T> const & lhs, ::boost::math::quaternion<T> const & rhs);
  547. template<typename T> bool operator != (octonion<T> const & lhs, octonion<T> const & rhs);
  548. These return true if and only if `octonion<T>(lhs) == octonion<T>(rhs)`
  549. is false. As with any floating-type entity, this is essentially meaningless.
  550. [h4 Stream Extractor]
  551. template<typename T, typename charT, class traits>
  552. ::std::basic_istream<charT,traits> & operator >> (::std::basic_istream<charT,traits> & is, octonion<T> & o);
  553. Extracts an octonion `o`. We accept any format which seems reasonable.
  554. However, since this leads to a great many ambiguities, decisions were made
  555. to lift these. In case of doubt, stick to lists of reals.
  556. The input values must be convertible to T. If bad input is encountered,
  557. calls `is.setstate(ios::failbit)` (which may throw `ios::failure` (27.4.5.3)).
  558. Returns `is`.
  559. [h4 Stream Inserter]
  560. template<typename T, typename charT, class traits>
  561. ::std::basic_ostream<charT,traits> & operator << (::std::basic_ostream<charT,traits> & os, octonion<T> const & o);
  562. Inserts the octonion `o` onto the stream `os` as if it were implemented as follows:
  563. template<typename T, typename charT, class traits>
  564. ::std::basic_ostream<charT,traits> & operator << ( ::std::basic_ostream<charT,traits> & os,
  565. octonion<T> const & o)
  566. {
  567. ::std::basic_ostringstream<charT,traits> s;
  568. s.flags(os.flags());
  569. s.imbue(os.getloc());
  570. s.precision(os.precision());
  571. s << '(' << o.R_component_1() << ','
  572. << o.R_component_2() << ','
  573. << o.R_component_3() << ','
  574. << o.R_component_4() << ','
  575. << o.R_component_5() << ','
  576. << o.R_component_6() << ','
  577. << o.R_component_7() << ','
  578. << o.R_component_8() << ')';
  579. return os << s.str();
  580. }
  581. [endsect] [/section:oct_non_mem Octonion Non-Member Operators]
  582. [section:oct_value_ops Octonion Value Operations]
  583. [h4 Real and Unreal]
  584. template<typename T> T real(octonion<T> const & o);
  585. template<typename T> octonion<T> unreal(octonion<T> const & o);
  586. These return `o.real()` and `o.unreal()` respectively.
  587. [h4 conj]
  588. template<typename T> octonion<T> conj(octonion<T> const & o);
  589. This returns the conjugate of the octonion.
  590. [h4 sup]
  591. template<typename T> T sup(octonion<T> const & o);
  592. This return the sup norm (the greatest among
  593. `abs(o.R_component_1())...abs(o.R_component_8()))` of the octonion.
  594. [h4 l1]
  595. template<typename T> T l1(octonion<T> const & o);
  596. This return the l1 norm (`abs(o.R_component_1())+...+abs(o.R_component_8())`)
  597. of the octonion.
  598. [h4 abs]
  599. template<typename T> T abs(octonion<T> const & o);
  600. This return the magnitude (Euclidian norm) of the octonion.
  601. [h4 norm]
  602. template<typename T> T norm(octonion<T>const & o);
  603. This return the (Cayley) norm of the octonion. The term "norm" might
  604. be confusing, as most people associate it with the Euclidian norm
  605. (and quadratic functionals). For this version of (the mathematical
  606. objects known as) octonions, the Euclidian norm (also known as
  607. magnitude) is the square root of the Cayley norm.
  608. [endsect] [/section:oct_value_ops Octonion Value Operations]
  609. [section:oct_create Octonion Creation Functions]
  610. template<typename T> octonion<T> spherical(T const & rho, T const & theta, T const & phi1, T const & phi2, T const & phi3, T const & phi4, T const & phi5, T const & phi6);
  611. template<typename T> octonion<T> multipolar(T const & rho1, T const & theta1, T const & rho2, T const & theta2, T const & rho3, T const & theta3, T const & rho4, T const & theta4);
  612. template<typename T> octonion<T> cylindrical(T const & r, T const & angle, T const & h1, T const & h2, T const & h3, T const & h4, T const & h5, T const & h6);
  613. These build octonions in a way similar to the way polar builds
  614. complex numbers, as there is no strict equivalent to
  615. polar coordinates for octonions.
  616. `spherical` is a simple transposition of `polar`, it takes as inputs a
  617. (positive) magnitude and a point on the hypersphere, given
  618. by three angles. The first of these, ['theta] has a natural range of
  619. -pi to +pi, and the other two have natural ranges of
  620. -pi/2 to +pi/2 (as is the case with the usual spherical
  621. coordinates in __R3). Due to the many symmetries and periodicities,
  622. nothing untoward happens if the magnitude is negative or the angles are
  623. outside their natural ranges. The expected degeneracies (a magnitude of
  624. zero ignores the angles settings...) do happen however.
  625. `cylindrical` is likewise a simple transposition of the usual
  626. cylindrical coordinates in __R3, which in turn is another derivative of
  627. planar polar coordinates. The first two inputs are the polar
  628. coordinates of the first __C component of the octonion. The third and
  629. fourth inputs are placed into the third and fourth __R components of the
  630. octonion, respectively.
  631. `multipolar` is yet another simple generalization of polar coordinates.
  632. This time, both __C components of the octonion are given in polar coordinates.
  633. In this version of our implementation of octonions, there is no
  634. analogue of the complex value operation arg as the situation is
  635. somewhat more complicated.
  636. [endsect] [/section:oct_create Octonion Creation Functions]
  637. [section:oct_trans Octonions Transcendentals]
  638. There is no `log` or `sqrt` provided for octonions in this implementation,
  639. and `pow` is likewise restricted to integral powers of the exponent.
  640. There are several reasons to this: on the one hand, the equivalent of
  641. analytic continuation for octonions ("branch cuts") remains to be
  642. investigated thoroughly (by me, at any rate...), and we wish to avoid
  643. the nonsense introduced in the standard by exponentiations of
  644. complexes by complexes (which is well defined, but not in the standard...).
  645. Talking of nonsense, saying that `pow(0,0)` is "implementation defined" is
  646. just plain brain-dead...
  647. We do, however provide several transcendentals, chief among which is
  648. the exponential. That it allows for a "closed formula" is a result
  649. of the author (the existence and definition of the exponential, on the
  650. octonions among others, on the other hand, is a few centuries old).
  651. Basically, any converging power series with real coefficients which
  652. allows for a closed formula in __C can be transposed to __O. More
  653. transcendentals of this type could be added in a further revision upon
  654. request. It should be noted that it is these functions which force the
  655. dependency upon the
  656. [@../../../../boost/math/special_functions/sinc.hpp boost/math/special_functions/sinc.hpp]
  657. and the
  658. [@../../../../boost/math/special_functions/sinhc.hpp boost/math/special_functions/sinhc.hpp]
  659. headers.
  660. [h4 exp]
  661. template<typename T>
  662. octonion<T> exp(octonion<T> const & o);
  663. Computes the exponential of the octonion.
  664. [h4 cos]
  665. template<typename T>
  666. octonion<T> cos(octonion<T> const & o);
  667. Computes the cosine of the octonion
  668. [h4 sin]
  669. template<typename T>
  670. octonion<T> sin(octonion<T> const & o);
  671. Computes the sine of the octonion.
  672. [h4 tan]
  673. template<typename T>
  674. octonion<T> tan(octonion<T> const & o);
  675. Computes the tangent of the octonion.
  676. [h4 cosh]
  677. template<typename T>
  678. octonion<T> cosh(octonion<T> const & o);
  679. Computes the hyperbolic cosine of the octonion.
  680. [h4 sinh]
  681. template<typename T>
  682. octonion<T> sinh(octonion<T> const & o);
  683. Computes the hyperbolic sine of the octonion.
  684. [h4 tanh]
  685. template<typename T>
  686. octonion<T> tanh(octonion<T> const & o);
  687. Computes the hyperbolic tangent of the octonion.
  688. [h4 pow]
  689. template<typename T>
  690. octonion<T> pow(octonion<T> const & o, int n);
  691. Computes the n-th power of the octonion q.
  692. [endsect]
  693. [section:oct_tests Test Program]
  694. The [@../../test/octonion_test.cpp octonion_test.cpp]
  695. test program tests octonions specialisations for float, double and long double
  696. ([@../octonion/output.txt sample output]).
  697. If you define the symbol BOOST_OCTONION_TEST_VERBOSE, you will get additional
  698. output ([@../octonion/output_more.txt verbose output]); this will
  699. only be helpfull if you enable message output at the same time, of course
  700. (by uncommenting the relevant line in the test or by adding --log_level=messages
  701. to your command line,...). In that case, and if you are running interactively,
  702. you may in addition define the symbol BOOST_INTERACTIVE_TEST_INPUT_ITERATOR to
  703. interactively test the input operator with input of your choice from the
  704. standard input (instead of hard-coding it in the test).
  705. [endsect] [/section:oct_trans Octonions Transcendentals]
  706. [section:acknowledgements Acknowledgements]
  707. The mathematical text has been typeset with
  708. [@http://www.nisus-soft.com/ Nisus Writer].
  709. Jens Maurer has helped with portability and standard adherence, and was the
  710. Review Manager for this library. More acknowledgements in the
  711. History section. Thank you to all who contributed to the discussion about this library.
  712. [endsect] [/section:acknowledgements Acknowledgements]
  713. [section:oct_history History]
  714. * 1.5.9 - 13/5/2013: Incorporated into Boost.Math.
  715. * 1.5.8 - 17/12/2005: Converted documentation to Quickbook Format.
  716. * 1.5.7 - 25/02/2003: transitionned to the unit test framework; <boost/config.hpp> now included by the library header (rather than the test files), via <boost/math/quaternion.hpp>.
  717. * 1.5.6 - 15/10/2002: Gcc2.95.x and stlport on linux compatibility by Alkis Evlogimenos (alkis@routescience.com).
  718. * 1.5.5 - 27/09/2002: Microsoft VCPP 7 compatibility, by Michael Stevens (michael@acfr.usyd.edu.au); requires the /Za compiler option.
  719. * 1.5.4 - 19/09/2002: fixed problem with multiple inclusion (in different translation units); attempt at an improved compatibility with Microsoft compilers, by Michael Stevens (michael@acfr.usyd.edu.au) and Fredrik Blomqvist; other compatibility fixes.
  720. * 1.5.3 - 01/02/2002: bugfix and Gcc 2.95.3 compatibility by Douglas Gregor (gregod@cs.rpi.edu).
  721. * 1.5.2 - 07/07/2001: introduced namespace math.
  722. * 1.5.1 - 07/06/2001: (end of Boost review) now includes <boost/math/special_functions/sinc.hpp> and <boost/math/special_functions/sinhc.hpp> instead of <boost/special_functions.hpp>; corrected bug in sin (Daryle Walker); removed check for self-assignment (Gary Powel); made converting functions explicit (Gary Powel); added overflow guards for division operators and abs (Peter Schmitteckert); added sup and l1; used Vesa Karvonen's CPP metaprograming technique to simplify code.
  723. * 1.5.0 - 23/03/2001: boostification, inlining of all operators except input, output and pow, fixed exception safety of some members (template version).
  724. * 1.4.0 - 09/01/2001: added tan and tanh.
  725. * 1.3.1 - 08/01/2001: cosmetic fixes.
  726. * 1.3.0 - 12/07/2000: pow now uses Maarten Hilferink's (mhilferink@tip.nl) algorithm.
  727. * 1.2.0 - 25/05/2000: fixed the division operators and output; changed many signatures.
  728. * 1.1.0 - 23/05/2000: changed sinc into sinc_pi; added sin, cos, sinh, cosh.
  729. * 1.0.0 - 10/08/1999: first public version.
  730. [endsect] [/section:oct_history History]
  731. [section:oct_todo To Do]
  732. * Improve testing.
  733. * Rewrite input operators using Spirit (creates a dependency).
  734. * Put in place an Expression Template mechanism (perhaps borrowing from uBlas).
  735. [endsect] [/section:oct_todo To Do]
  736. [endmathpart]
  737. [/
  738. Copyright 1999, 2005, 2013 Hubert Holin.
  739. Distributed under the Boost Software License, Version 1.0.
  740. (See accompanying file LICENSE_1_0.txt or copy at
  741. http://www.boost.org/LICENSE_1_0.txt).
  742. ]