Skip to content

Commit

Permalink
deploy: e8433b8
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMaciek committed Aug 4, 2023
1 parent e069644 commit ecc0335
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 47 deletions.
31 changes: 9 additions & 22 deletions docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ <h1><a class="anchor" id="install_sec"></a>
<div class="line">brew install mpfr</div>
</div><!-- fragment --><p >The following is a <em>header-only</em> library, meaning that the easiest way to use it is to copy the core <em>hpp</em> file alongside the main program and include it into the code with the directive: </p><div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="_hypercomplex_8hpp.html">Hypercomplex.hpp</a>&quot;</span></div>
<div class="ttc" id="a_hypercomplex_8hpp_html"><div class="ttname"><a href="_hypercomplex_8hpp.html">Hypercomplex.hpp</a></div></div>
</div><!-- fragment --><p >Remember to specify a proper langauge standard for the compiler as well as linking with <em>GNU MP</em> and <em>GNU MPFR</em> libraries, as in the command below: </p><div class="fragment"><div class="line">g++ -02 --std=c++17 test.cpp -o test -lmpfr -lgmp</div>
</div><!-- fragment --><p >Remember to specify a proper langauge standard for the compiler as well as linking with <em>GNU MP</em> and <em>GNU MPFR</em> libraries, as in the command below: </p><div class="fragment"><div class="line">g++ -O2 --std=c++17 test.cpp -o test -lmpfr -lgmp</div>
</div><!-- fragment --><p >Alternatively, if you work with conda environments this library is installable with: </p><div class="fragment"><div class="line">conda install -c angrymaciek hypercomplex</div>
</div><!-- fragment --><p >However, please note that during compilation time it might be necessary to provide additional flags which point to the headers and other libs for the linker.</p>
<p >The command above would be adjusted to: </p><div class="fragment"><div class="line">g++ -O2 --std=c++17 -I$CONDA_PREFIX/include -L$CONDA_PREFIX/lib test.cpp -o test -lmpfr -lgmp</div>
</div><!-- fragment --><h1><a class="anchor" id="usecase_sec"></a>
Brief overview</h1>
<p >The following section demonstrates general functionality and behaviour of the library. For the full unit test suite please refer to <a href="https://github.com/AngryMaciek/hypercomplex/blob/master/.test/unit/test.cpp">this file</a>.</p>
Expand Down Expand Up @@ -137,25 +140,10 @@ <h1><a class="anchor" id="install_sec"></a>
<p >Calling a class method... </p><div class="fragment"><div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;H2^-1 = &quot;</span> &lt;&lt; H2.inv() &lt;&lt; std::endl;</div>
</div><!-- fragment --><p >...creates a new class instance: </p><div class="fragment"><div class="line">H2^-1 = -0.0357143 0.0714286 0.107143 -0</div>
</div><!-- fragment --><p >Arithmetic operations on hypercomplex numbers are not complicated at all.</p><ul>
<li>Addition is carried out over respective elements: <br />
\(\forall_{H_A, H_B}: [H_A+H_B]^{(i)} := H_A^{(i)} + H_B^{(i)}\)</li>
<li>Subtraction is carried out over respective elements: <br />
\(\forall_{H_A, H_B}: [H_A-H_B]^{(i)} := H_A^{(i)} - H_B^{(i)}\)</li>
<li>A general formula for multiplication of hypercomplex numbers may be derived as follows: <br />
Let \(H_A\) and \(H_B\) be elements from a Cayley-Dickson algebra of dimension \(2^n\). <br />
Both numbers may be interpreted as ordered pairs of elements from a \(2^{(n-1)}\)-dimensional algebra: \(H_A = (a,b)\) and \(H_B = (c,d)\). <br />
Such a representation yields a recursive multiplication algorithm: <br />
\(H_A \times H_B = (a,b)(c,d) := (ac-\bar{d}b,da+b\bar{c})\). <br />
(Multiplication of hypercomplex numbers is indeed implemented as a recursive operator with the base condition of multiplying real numbers.) <br />
<b>Disclaimer:</b> Various distinct definitions of the multiplication formula exist: <a href="https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_construction">here</a>, <a href="https://ncatlab.org/nlab/show/Cayley-Dickson+construction">here</a> or <a href="http://www.zipcon.net/~swhite/docs/math/quaternions/Cayley-Dickson.html">here</a>. <br />
They all lead to a proper norm upon multiplying a number with it's conjugate and the choice is arbitrary (feel free to modify the code, if needed). <br />
In addition to the overloaded operator, hypercomplex multiplication is also available as a class method. <br />
Depending on the dimenion of algebra and compiler's optimisation settings it could be 5-50x faster than the overloaded operator. <br />
</li>
<li>Knowing that inverse elements of hypercomplex numbers exist a division operation is implementat as a multiplication with an inverse of the right operand: <br />
Let \(H_A\) and \(H_B\) be elements from a Cayley-Dickson algebra of dimension \(2^n\), \(H_B \neq 0\). <br />
\(\frac{H_A}{H_B} := H_A \times H_B^{-1}\) <br />
Notice the order of the operands, as commutativity is no longer a given.</li>
<li>Addition is carried out over respective elements: \(\forall_{H_A, H_B}: [H_A+H_B]^{(i)} := H_A^{(i)} + H_B^{(i)}\)</li>
<li>Subtraction is carried out over respective elements: \(\forall_{H_A, H_B}: [H_A-H_B]^{(i)} := H_A^{(i)} - H_B^{(i)}\)</li>
<li>A general formula for multiplication of hypercomplex numbers may be derived as follows: Let \(H_A\) and \(H_B\) be elements from a Cayley-Dickson algebra of dimension \(2^n\). Both numbers may be interpreted as ordered pairs of elements from a \(2^{(n-1)}\)-dimensional algebra: \(H_A = (a,b)\) and \(H_B = (c,d)\). Such a representation yields a recursive multiplication algorithm: \(H_A \times H_B = (a,b)(c,d) := (ac-\bar{d}b,da+b\bar{c})\). (Multiplication of hypercomplex numbers is indeed implemented as a recursive operator with the base condition of multiplying real numbers.) <b>Disclaimer:</b> Various distinct definitions of the multiplication formula exist: <a href="https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_construction">here</a>, <a href="https://ncatlab.org/nlab/show/Cayley-Dickson+construction">here</a> or <a href="http://www.zipcon.net/~swhite/docs/math/quaternions/Cayley-Dickson.html">here</a>. They all lead to a proper norm upon multiplying a number with it's conjugate and the choice is arbitrary (feel free to modify the code, if needed). In addition to the overloaded operator, hypercomplex multiplication is also available as a class method. Depending on the dimenion of algebra and compiler's optimisation settings it could be 5-50x faster than the overloaded operator.</li>
<li>Knowing that inverse elements of hypercomplex numbers exist a division operation is implementat as a multiplication with an inverse of the right operand: Let \(H_A\) and \(H_B\) be elements from a Cayley-Dickson algebra of dimension \(2^n\), \(H_B \neq 0\). \(\frac{H_A}{H_B} := H_A \times H_B^{-1}\) Notice the order of the operands, as commutativity is no longer a given.</li>
</ul>
<p >To test these operations we may execute the code below: </p><div class="fragment"><div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;H1 + H2 = &quot;</span> &lt;&lt; H1 + H2 &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;H1 - H2 = &quot;</span> &lt;&lt; H1 - H2 &lt;&lt; std::endl;</div>
Expand All @@ -172,8 +160,7 @@ <h1><a class="anchor" id="install_sec"></a>
</div><!-- fragment --><p >Produces: </p><div class="fragment"><div class="line">H2^4 = 1472 -1536 -2304 0</div>
</div><!-- fragment --><p >Last, but not least: our little cherry on top. A very special function linked to the magical Euler number - hypercomplex exponentiation:</p>
<p >\(e^H = e^{Re(H)+Im(H)} := e^{Re(H)} \times (cos||Im(H)||_2 + \frac{Im(H)}{||Im(H)||_2} \times sin||Im(H)||_2)\)</p>
<p >Regardless of the algebra hypercomplex numbers in the equation above are multiplied by scalars, therefore associativity and commutativity still holds for these formulas. <br />
For that reason the exponentiation function is highly optimized, implemented efficiently with as few operations and variables as possible.</p>
<p >Regardless of the algebra hypercomplex numbers in the equation above are multiplied by scalars, therefore associativity and commutativity still holds for these formulas. For that reason the exponentiation function is highly optimized, implemented efficiently with as few operations and variables as possible.</p>
<p >Finally, we validate it with: </p><div class="fragment"><div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;e^H1 = &quot;</span> &lt;&lt; <a class="code hl_function" href="_hypercomplex_8hpp.html#acefdb8c35a0c89587789edc830ffa282">exp</a>(H1) &lt;&lt; std::endl;</div>
<div class="ttc" id="a_hypercomplex_8hpp_html_acefdb8c35a0c89587789edc830ffa282"><div class="ttname"><a href="_hypercomplex_8hpp.html#acefdb8c35a0c89587789edc830ffa282">exp</a></div><div class="ttdeci">Hypercomplex&lt; T, dim &gt; exp(const Hypercomplex&lt; T, dim &gt; &amp;H)</div><div class="ttdoc">Exponentiation operation on a hypercomplex number.</div><div class="ttdef"><b>Definition:</b> Hypercomplex.hpp:643</div></div>
</div><!-- fragment --><p >and get: </p><div class="fragment"><div class="line">e^H1 = 0.83583 -0 0.257375 -2.57375</div>
Expand Down
63 changes: 38 additions & 25 deletions docs/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* lattice-based cryptosystems in high-dimensional algebras of truncated
* polynomial rings.
* The library is dedicated mostly to computational mathematicians and computational scientists
* whose focus is (post-quantum) cryptography and precise computation.
* whose focus is (post-quantum) cryptography and precise computation.
* As a header-only C++ template code it's greatest advantage is the combination of
* speed, generic programming and convenience for the end user, making it
* well suited for wide range of computationally challenging projects.
*
*
* \section install_sec Installation
*
* As a prerequisite it is essential to install the
* As a prerequisite it is essential to install the
* <a href="https://www.mpfr.org/">MPFR library</a> first.
* This should be rather straightforward with the following commands:
* \code
Expand All @@ -39,15 +39,28 @@
* Remember to specify a proper langauge standard for the compiler as well as
* linking with _GNU MP_ and _GNU MPFR_ libraries, as in the command below:
* \code
* g++ -02 --std=c++17 test.cpp -o test -lmpfr -lgmp
* g++ -O2 --std=c++17 test.cpp -o test -lmpfr -lgmp
* \endcode
*
*
* Alternatively, if you work with conda environments this library is installable with:
* \code
* conda install -c angrymaciek hypercomplex
* \endcode
*
* However, please note that during compilation time it might be necessary to
* provide additional flags which point to the headers and other libs for the linker.
*
* The command above would be adjusted to:
* \code
* g++ -O2 --std=c++17 -I$CONDA_PREFIX/include -L$CONDA_PREFIX/lib test.cpp -o test -lmpfr -lgmp
* \endcode
*
*
*
* \section usecase_sec Brief overview
*
* The following section demonstrates general functionality and behaviour of the library.
* For the full unit test suite please refer to
* For the full unit test suite please refer to
* <a href="https://github.com/AngryMaciek/hypercomplex/blob/master/.test/unit/test.cpp">this file</a>.
*
* Please note that throughout this whole documentation many links may point
Expand Down Expand Up @@ -165,26 +178,26 @@
* \endcode
*
* Arithmetic operations on hypercomplex numbers are not complicated at all.
* * Addition is carried out over respective elements:
* * Addition is carried out over respective elements:
* \f$\forall_{H_A, H_B}: [H_A+H_B]^{(i)} := H_A^{(i)} + H_B^{(i)}\f$
* * Subtraction is carried out over respective elements:
* * Subtraction is carried out over respective elements:
* \f$\forall_{H_A, H_B}: [H_A-H_B]^{(i)} := H_A^{(i)} - H_B^{(i)}\f$
* * A general formula for multiplication of hypercomplex numbers may be derived as follows:
* Let \f$H_A\f$ and \f$H_B\f$ be elements from a Cayley-Dickson algebra of dimension \f$2^n\f$.
* Both numbers may be interpreted as ordered pairs of elements from a \f$2^{(n-1)}\f$-dimensional algebra: \f$H_A = (a,b)\f$ and \f$H_B = (c,d)\f$.
* Such a representation yields a recursive multiplication algorithm:
* \f$H_A \times H_B = (a,b)(c,d) := (ac-\bar{d}b,da+b\bar{c})\f$.
* (Multiplication of hypercomplex numbers is indeed implemented as a recursive operator with the base condition of multiplying real numbers.)
* * A general formula for multiplication of hypercomplex numbers may be derived as follows:
* Let \f$H_A\f$ and \f$H_B\f$ be elements from a Cayley-Dickson algebra of dimension \f$2^n\f$.
* Both numbers may be interpreted as ordered pairs of elements from a \f$2^{(n-1)}\f$-dimensional algebra: \f$H_A = (a,b)\f$ and \f$H_B = (c,d)\f$.
* Such a representation yields a recursive multiplication algorithm:
* \f$H_A \times H_B = (a,b)(c,d) := (ac-\bar{d}b,da+b\bar{c})\f$.
* (Multiplication of hypercomplex numbers is indeed implemented as a recursive operator with the base condition of multiplying real numbers.)
* **Disclaimer:** Various distinct definitions of the multiplication formula exist:
* <a href="https://en.wikipedia.org/wiki/Cayley%E2%80%93Dickson_construction">here</a>,
* <a href="https://ncatlab.org/nlab/show/Cayley-Dickson+construction">here</a> or
* <a href="http://www.zipcon.net/~swhite/docs/math/quaternions/Cayley-Dickson.html">here</a>.
* They all lead to a proper norm upon multiplying a number with it's conjugate and the choice is arbitrary (feel free to modify the code, if needed).
* In addition to the overloaded operator, hypercomplex multiplication is also available as a class method.
* Depending on the dimenion of algebra and compiler's optimisation settings it could be 5-50x faster than the overloaded operator.
* * Knowing that inverse elements of hypercomplex numbers exist a division operation is implementat as a multiplication with an inverse of the right operand:
* Let \f$H_A\f$ and \f$H_B\f$ be elements from a Cayley-Dickson algebra of dimension \f$2^n\f$, \f$H_B \neq 0\f$.
* \f$\frac{H_A}{H_B} := H_A \times H_B^{-1}\f$
* <a href="https://ncatlab.org/nlab/show/Cayley-Dickson+construction">here</a> or
* <a href="http://www.zipcon.net/~swhite/docs/math/quaternions/Cayley-Dickson.html">here</a>.
* They all lead to a proper norm upon multiplying a number with it's conjugate and the choice is arbitrary (feel free to modify the code, if needed).
* In addition to the overloaded operator, hypercomplex multiplication is also available as a class method.
* Depending on the dimenion of algebra and compiler's optimisation settings it could be 5-50x faster than the overloaded operator.
* * Knowing that inverse elements of hypercomplex numbers exist a division operation is implementat as a multiplication with an inverse of the right operand:
* Let \f$H_A\f$ and \f$H_B\f$ be elements from a Cayley-Dickson algebra of dimension \f$2^n\f$, \f$H_B \neq 0\f$.
* \f$\frac{H_A}{H_B} := H_A \times H_B^{-1}\f$
* Notice the order of the operands, as commutativity is no longer a given.
*
* To test these operations we may execute the code below:
Expand Down Expand Up @@ -226,7 +239,7 @@
* \f$e^H = e^{Re(H)+Im(H)} := e^{Re(H)} \times (cos||Im(H)||_2 + \frac{Im(H)}{||Im(H)||_2} \times sin||Im(H)||_2)\f$
*
* Regardless of the algebra hypercomplex numbers in the equation above are multiplied by scalars,
* therefore associativity and commutativity still holds for these formulas.
* therefore associativity and commutativity still holds for these formulas.
* For that reason the exponentiation function is highly optimized,
* implemented efficiently with as few operations and variables as possible.
*
Expand All @@ -247,7 +260,7 @@
* It is strongly advised to read the <a href="https://www.mpfr.org/mpfr-current/mpfr.pdf">library manual</a> beforehand
* (sections 1 and 4 as a must-read). Please do not mix this library with another _MPFR_-dependant
* code in the same translation unit.
*
*
* We start with setting a global precision for all objects.
* \code{.cpp}
* set_mpfr_precision(200);
Expand Down Expand Up @@ -304,7 +317,7 @@
* mpfr_clear(A[7]);
* \endcode
*
* Also, following that, to call a wrapper function which
* Also, following that, to call a wrapper function which
* cleans all internally-reserved memory:
* \code{.cpp}
* clear_mpfr_memory();
Expand Down

0 comments on commit ecc0335

Please sign in to comment.