From ecc0335f2d649b5fd6e7fa50362beeeb6a6e45a8 Mon Sep 17 00:00:00 2001 From: AngryMaciek Date: Fri, 4 Aug 2023 23:32:52 +0000 Subject: [PATCH] deploy: e8433b8ac00ebf71a6406bb8836a3c44e9010652 --- docs/html/index.html | 31 +++++++--------------- docs/mainpage.dox | 63 ++++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/html/index.html b/docs/html/index.html index 47f233d..1872471 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -91,7 +91,10 @@

brew install mpfr

The following is a header-only library, meaning that the easiest way to use it is to copy the core hpp file alongside the main program and include it into the code with the directive:

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:

g++ -02 --std=c++17 test.cpp -o test -lmpfr -lgmp
+

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:

g++ -O2 --std=c++17 test.cpp -o test -lmpfr -lgmp
+

Alternatively, if you work with conda environments this library is installable with:

conda install -c angrymaciek hypercomplex
+

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:

g++ -O2 --std=c++17 -I$CONDA_PREFIX/include -L$CONDA_PREFIX/lib test.cpp -o test -lmpfr -lgmp

Brief overview

The following section demonstrates general functionality and behaviour of the library. For the full unit test suite please refer to this file.

@@ -137,25 +140,10 @@

Calling a class method...

std::cout << "H2^-1 = " << H2.inv() << std::endl;

...creates a new class instance:

H2^-1 = -0.0357143 0.0714286 0.107143 -0

Arithmetic operations on hypercomplex numbers are not complicated at all.

To test these operations we may execute the code below:

std::cout << "H1 + H2 = " << H1 + H2 << std::endl;
std::cout << "H1 - H2 = " << H1 - H2 << std::endl;
@@ -172,8 +160,7 @@

Produces:

H2^4 = 1472 -1536 -2304 0

Last, but not least: our little cherry on top. A very special function linked to the magical Euler number - hypercomplex exponentiation:

\(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)\)

-

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.

+

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.

Finally, we validate it with:

std::cout << "e^H1 = " << exp(H1) << std::endl;
Hypercomplex< T, dim > exp(const Hypercomplex< T, dim > &H)
Exponentiation operation on a hypercomplex number.
Definition: Hypercomplex.hpp:643

and get:

e^H1 = 0.83583 -0 0.257375 -2.57375
diff --git a/docs/mainpage.dox b/docs/mainpage.dox index ec43b79..7179753 100644 --- a/docs/mainpage.dox +++ b/docs/mainpage.dox @@ -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 * MPFR library first. * This should be rather straightforward with the following commands: * \code @@ -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 * this file. * * Please note that throughout this whole documentation many links may point @@ -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: * here, - * here or - * here. - * 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$ + * here or + * here. + * 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: @@ -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. * @@ -247,7 +260,7 @@ * It is strongly advised to read the library manual 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); @@ -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();