Hypercomplex
Abstract & fast header-only C++ template library for lattice-based cryptosystems in high-dimensional algebras
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Hypercomplex< mpfr_t, dim > Class Template Reference

#include <Hypercomplex_MPFR.hpp>

Public Member Functions

 Hypercomplex (const mpfr_t *ARR)
 This is the main constructor. More...
 
 Hypercomplex (const Hypercomplex &H)
 This is the copy constructor. More...
 
uint64_t _ () const
 Dimensionality getter. More...
 
int32_t norm (mpfr_t norm) const
 Calculate Euclidean norm of a number. More...
 
Hypercomplex inv () const
 Calculate inverse of a given number. More...
 
template<const uint64_t newdim>
Hypercomplex< mpfr_t, newdim > expand () const
 Cast a number into a higher dimension. More...
 
Hypercomplex operator~ () const
 Create a complex conjugate. More...
 
Hypercomplex operator- () const
 Create an additive inverse of a given number. More...
 
Hypercomplexoperator= (const Hypercomplex &H)
 Assignment operator. More...
 
mpfr_t const & operator[] (const uint64_t i) const
 Access operator (const) More...
 
mpfr_t & operator[] (const uint64_t i)
 Access operator (non-const) More...
 
Hypercomplexoperator+= (const Hypercomplex &H)
 Addition-Assignment operator. More...
 
Hypercomplexoperator-= (const Hypercomplex &H)
 Subtraction-Assignment operator. More...
 
Hypercomplexoperator*= (const Hypercomplex &H)
 Multiplication-Assignment operator. More...
 
Hypercomplexoperator^= (const uint64_t x)
 Power-Assignment operator. More...
 
Hypercomplexoperator/= (const Hypercomplex &H)
 Division-Assignment operator. More...
 

Static Public Member Functions

static void init ()
 Basis multiplication table initialiser.
 
static void clear ()
 Cleanup function: free all memory.
 
static Hypercomplex MUL (const Hypercomplex &H1, const Hypercomplex &H2)
 Optimised multiplication function. More...
 

Detailed Description

template<const uint64_t dim>
class Hypercomplex< mpfr_t, dim >

Partial specialisation of the main class for high precision

Constructor & Destructor Documentation

◆ Hypercomplex() [1/2]

template<const uint64_t dim>
Hypercomplex< mpfr_t, dim >::Hypercomplex ( const mpfr_t *  ARR)
inlineexplicit

This is the main constructor.

Parameters
[in]ARRarray of MPFR numbers

Template parameters are:

  • dimensionality of the algebra

◆ Hypercomplex() [2/2]

template<const uint64_t dim>
Hypercomplex< mpfr_t, dim >::Hypercomplex ( const Hypercomplex< mpfr_t, dim > &  H)
inline

This is the copy constructor.

Parameters
[in]Hexisting class instance

Template parameters are:

  • dimensionality of the algebra

Member Function Documentation

◆ _()

template<const uint64_t dim>
uint64_t Hypercomplex< mpfr_t, dim >::_ ( ) const
inline

Dimensionality getter.

Returns
algebraic dimension of the underlying object

◆ expand()

template<const uint64_t dim>
template<const uint64_t newdim>
Hypercomplex< mpfr_t, newdim > Hypercomplex< mpfr_t, dim >::expand ( ) const
inline

Cast a number into a higher dimension.

Returns
new class instance

New dimension is passed as a function template parameter, as the return class is not the same as the caller's class.

◆ inv()

template<const uint64_t dim>
Hypercomplex Hypercomplex< mpfr_t, dim >::inv ( ) const
inline

Calculate inverse of a given number.

Returns
new class instance

◆ MUL()

template<const uint64_t dim>
static Hypercomplex Hypercomplex< mpfr_t, dim >::MUL ( const Hypercomplex< mpfr_t, dim > &  H1,
const Hypercomplex< mpfr_t, dim > &  H2 
)
inlinestatic

Optimised multiplication function.

Parameters
[in]H1LHS operand
[in]H2RHS operand
Returns
new class instance

◆ norm()

template<const uint64_t dim>
int32_t Hypercomplex< mpfr_t, dim >::norm ( mpfr_t  norm) const
inline

Calculate Euclidean norm of a number.

Parameters
[in,out]normMPFR variable for the calculated norm
Returns
exit status

Note that the interface of this method is different than for the fully template class. Following the MPFR logic: function takes as an argument a variable to store the output in.

◆ operator*=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator*= ( const Hypercomplex< mpfr_t, dim > &  H)
inline

Multiplication-Assignment operator.

Parameters
[in]Hexisting class instance
Returns
Reference to the caller

◆ operator+=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator+= ( const Hypercomplex< mpfr_t, dim > &  H)
inline

Addition-Assignment operator.

Parameters
[in]Hexisting class instance
Returns
Reference to the caller

◆ operator-()

template<const uint64_t dim>
Hypercomplex Hypercomplex< mpfr_t, dim >::operator- ( ) const
inline

Create an additive inverse of a given number.

Returns
new class instance

◆ operator-=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator-= ( const Hypercomplex< mpfr_t, dim > &  H)
inline

Subtraction-Assignment operator.

Parameters
[in]Hexisting class instance
Returns
Reference to the caller

◆ operator/=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator/= ( const Hypercomplex< mpfr_t, dim > &  H)
inline

Division-Assignment operator.

Parameters
[in]Hexisting class instance
Returns
Reference to the caller

◆ operator=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator= ( const Hypercomplex< mpfr_t, dim > &  H)
inline

Assignment operator.

Parameters
[in]Hexisting class instance
Returns
Reference to the caller (for chained assignments)

◆ operator[]() [1/2]

template<const uint64_t dim>
mpfr_t & Hypercomplex< mpfr_t, dim >::operator[] ( const uint64_t  i)
inline

Access operator (non-const)

Parameters
[in]iindex for the element to access
Returns
i-th element of the number

◆ operator[]() [2/2]

template<const uint64_t dim>
mpfr_t const & Hypercomplex< mpfr_t, dim >::operator[] ( const uint64_t  i) const
inline

Access operator (const)

Parameters
[in]iindex for the element to access
Returns
i-th element of the number

◆ operator^=()

template<const uint64_t dim>
Hypercomplex & Hypercomplex< mpfr_t, dim >::operator^= ( const uint64_t  x)
inline

Power-Assignment operator.

Parameters
[in]xpositive integer
Returns
Reference to the caller

◆ operator~()

template<const uint64_t dim>
Hypercomplex Hypercomplex< mpfr_t, dim >::operator~ ( ) const
inline

Create a complex conjugate.

Returns
new class instance