Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class > Class Template Reference

Class defining operators for the \( \mathbb{F}_p \) field for any prime number \( p \). More...

Public Types

using element_type = Unsigned_integer_type
 
using characteristic_type = element_type
 

Public Member Functions

 Zp_field_operators (characteristic_type characteristic=0)
 Default constructor. If a non-zero characteristic is given, initializes the field with it. The characteristic can later be changed again or initialized with set_characteristic. More...
 
 Zp_field_operators (const Zp_field_operators &toCopy)
 Copy constructor. More...
 
 Zp_field_operators (Zp_field_operators &&toMove) noexcept
 Move constructor. More...
 
void set_characteristic (characteristic_type characteristic)
 Sets the characteristic of the field. More...
 
const characteristic_typeget_characteristic () const
 Returns the current characteristic. More...
 
element_type get_value (element_type e) const
 Returns the value of an integer in the field. That is the positive value of the integer modulo the current characteristic. More...
 
template<typename Signed_integer_type , class = isSignedInteger<Signed_integer_type>>
element_type get_value (Signed_integer_type e) const
 Returns the value of an integer in the field. That is the positive value of the integer modulo the current characteristic. More...
 
element_type add (element_type e1, element_type e2) const
 Returns the sum of two elements in the field. More...
 
void add_inplace (element_type &e1, element_type e2) const
 Stores in the first element the sum of two given elements in the field, that is (e1 + e2) % characteristic, such that the result is positive. More...
 
element_type substract (element_type e1, element_type e2) const
 Returns the substraction in the field of the first element by the second element. More...
 
void substract_inplace_front (element_type &e1, element_type e2) const
 Stores in the first element the substraction in the field of the first element by the second element, that is (e1 - e2) % 2, such that the result is positive. More...
 
void substract_inplace_back (element_type e1, element_type &e2) const
 Stores in the second element the substraction in the field of the first element by the second element, that is (e1 - e2) % 2, such that the result is positive. More...
 
element_type multiply (element_type e1, element_type e2) const
 Returns the multiplication of two elements in the field. More...
 
void multiply_inplace (element_type &e1, element_type e2) const
 Stores in the first element the multiplication of two given elements in the field, that is (e1 * e2) % characteristic, such that the result is positive. More...
 
element_type multiply_and_add (element_type e, element_type m, element_type a) const
 Multiplies the first element with the second one and adds the third one. Returns the result in the field. More...
 
void multiply_and_add_inplace_front (element_type &e, element_type m, element_type a) const
 Multiplies the first element with the second one and adds the third one, that is (e * m + a) % characteristic, such that the result is positive. Stores the result in the first element. More...
 
void multiply_and_add_inplace_back (element_type e, element_type m, element_type &a) const
 Multiplies the first element with the second one and adds the third one, that is (e * m + a) % characteristic, such that the result is positive. Stores the result in the third element. More...
 
element_type add_and_multiply (element_type e, element_type a, element_type m) const
 Adds the first element to the second one and multiplies the third one with it. Returns the result in the field. More...
 
void add_and_multiply_inplace_front (element_type &e, element_type a, element_type m) const
 Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) % characteristic, such that the result is positive. Stores the result in the first element. More...
 
void add_and_multiply_inplace_back (element_type e, element_type a, element_type &m) const
 Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) % characteristic, such that the result is positive. Stores the result in the third element. More...
 
bool are_equal (element_type e1, element_type e2) const
 Returns true if the two given elements are equal in the field, false otherwise. More...
 
element_type get_inverse (element_type e) const
 Returns the inverse of the given element in the field. More...
 
std::pair< element_type, characteristic_typeget_partial_inverse (element_type e, characteristic_type productOfCharacteristics) const
 For interface purposes with multi-fields. Returns the inverse together with the second argument. More...
 
Zp_field_operatorsoperator= (Zp_field_operators other)
 Assign operator.
 

Static Public Member Functions

static constexpr element_type get_additive_identity ()
 Returns the additive identity of the field. More...
 
static constexpr element_type get_multiplicative_identity ()
 Returns the multiplicative identity of the field. More...
 
static constexpr element_type get_partial_multiplicative_identity ([[maybe_unused]] characteristic_type productOfCharacteristics)
 For interface purposes with multi-fields. Returns the multiplicative identity of the field. More...
 

Friends

void swap (Zp_field_operators &f1, Zp_field_operators &f2)
 Swap operator.
 

Detailed Description

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
class Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >

Class defining operators for the \( \mathbb{F}_p \) field for any prime number \( p \).

Template Parameters
Unsigned_integer_typeA native unsigned integer type: unsigned int, long unsigned int, etc. Will be used as the field element type.
Examples
example_field_operations.cpp.

Member Typedef Documentation

◆ characteristic_type

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
using Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::characteristic_type = element_type

Type for the field characteristic.

◆ element_type

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
using Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::element_type = Unsigned_integer_type

Type for the elements in the field.

Constructor & Destructor Documentation

◆ Zp_field_operators() [1/3]

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::Zp_field_operators ( characteristic_type  characteristic = 0)
inline

Default constructor. If a non-zero characteristic is given, initializes the field with it. The characteristic can later be changed again or initialized with set_characteristic.

Parameters
characteristicPrime number corresponding to the desired characteristic of the field.

◆ Zp_field_operators() [2/3]

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::Zp_field_operators ( const Zp_field_operators< Unsigned_integer_type, class > &  toCopy)
inline

Copy constructor.

Parameters
toCopyOperators to copy.

◆ Zp_field_operators() [3/3]

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::Zp_field_operators ( Zp_field_operators< Unsigned_integer_type, class > &&  toMove)
inlinenoexcept

Move constructor.

Parameters
toMoveOperators to move.

Member Function Documentation

◆ add()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::add ( element_type  e1,
element_type  e2 
) const
inline

Returns the sum of two elements in the field.

Parameters
e1First element.
e2Second element.
Returns
(e1 + e2) % characteristic, such that the result is positive.

◆ add_and_multiply()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::add_and_multiply ( element_type  e,
element_type  a,
element_type  m 
) const
inline

Adds the first element to the second one and multiplies the third one with it. Returns the result in the field.

Warning
Not overflow safe.
Parameters
eFirst element.
aSecond element.
mThird element.
Returns
((e + a) * m) % characteristic, such that the result is positive.

◆ add_and_multiply_inplace_back()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::add_and_multiply_inplace_back ( element_type  e,
element_type  a,
element_type m 
) const
inline

Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) % characteristic, such that the result is positive. Stores the result in the third element.

Warning
Not overflow safe.
Parameters
eFirst element.
aSecond element.
mThird element.

◆ add_and_multiply_inplace_front()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::add_and_multiply_inplace_front ( element_type e,
element_type  a,
element_type  m 
) const
inline

Adds the first element to the second one and multiplies the third one with it, that is ((e + a) * m) % characteristic, such that the result is positive. Stores the result in the first element.

Warning
Not overflow safe.
Parameters
eFirst element.
aSecond element.
mThird element.

◆ add_inplace()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::add_inplace ( element_type e1,
element_type  e2 
) const
inline

Stores in the first element the sum of two given elements in the field, that is (e1 + e2) % characteristic, such that the result is positive.

Parameters
e1First element.
e2Second element.

◆ are_equal()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
bool Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::are_equal ( element_type  e1,
element_type  e2 
) const
inline

Returns true if the two given elements are equal in the field, false otherwise.

Parameters
e1First element to compare.
e2Second element to compare.
Returns
true If e1 % characteristic == e2 % characteristic.
false Otherwise.

◆ get_additive_identity()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
static constexpr element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_additive_identity ( )
inlinestaticconstexpr

Returns the additive identity of the field.

Returns
0.

◆ get_characteristic()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
const characteristic_type& Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_characteristic ( ) const
inline

Returns the current characteristic.

Returns
The value of the current characteristic.

◆ get_inverse()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_inverse ( element_type  e) const
inline

Returns the inverse of the given element in the field.

Parameters
eElement to get the inverse from.
Returns
Inverse in the current field of e % characteristic.

◆ get_multiplicative_identity()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
static constexpr element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_multiplicative_identity ( )
inlinestaticconstexpr

Returns the multiplicative identity of the field.

Returns
1.

◆ get_partial_inverse()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
std::pair<element_type, characteristic_type> Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_partial_inverse ( element_type  e,
characteristic_type  productOfCharacteristics 
) const
inline

For interface purposes with multi-fields. Returns the inverse together with the second argument.

Parameters
eElement to get the inverse from.
productOfCharacteristicsSome value.
Returns
Pair whose first element is the inverse of e and the second element is productOfCharacteristics.

◆ get_partial_multiplicative_identity()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
static constexpr element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_partial_multiplicative_identity ( [[maybe_unused] ] characteristic_type  productOfCharacteristics)
inlinestaticconstexpr

For interface purposes with multi-fields. Returns the multiplicative identity of the field.

Parameters
productOfCharacteristicsSome value.
Returns
1.

◆ get_value() [1/2]

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_value ( element_type  e) const
inline

Returns the value of an integer in the field. That is the positive value of the integer modulo the current characteristic.

Parameters
eUnsigned integer to return the value from.
Returns
e modulo the current characteristic, such that the result is positive.

◆ get_value() [2/2]

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
template<typename Signed_integer_type , class = isSignedInteger<Signed_integer_type>>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::get_value ( Signed_integer_type  e) const
inline

Returns the value of an integer in the field. That is the positive value of the integer modulo the current characteristic.

Template Parameters
Signed_integer_typeA native signed integer type: int, long int, etc.
Parameters
eInteger to return the value from.
Returns
e modulo the current characteristic, such that the result is positive.

◆ multiply()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::multiply ( element_type  e1,
element_type  e2 
) const
inline

Returns the multiplication of two elements in the field.

Parameters
e1First element.
e2Second element.
Returns
(e1 * e2) % characteristic, such that the result is positive.

◆ multiply_and_add()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::multiply_and_add ( element_type  e,
element_type  m,
element_type  a 
) const
inline

Multiplies the first element with the second one and adds the third one. Returns the result in the field.

Warning
Not overflow safe.
Parameters
eFirst element.
mSecond element.
aThird element.
Returns
(e * m + a) % characteristic, such that the result is positive.

◆ multiply_and_add_inplace_back()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::multiply_and_add_inplace_back ( element_type  e,
element_type  m,
element_type a 
) const
inline

Multiplies the first element with the second one and adds the third one, that is (e * m + a) % characteristic, such that the result is positive. Stores the result in the third element.

Warning
Not overflow safe.
Parameters
eFirst element.
mSecond element.
aThird element.

◆ multiply_and_add_inplace_front()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::multiply_and_add_inplace_front ( element_type e,
element_type  m,
element_type  a 
) const
inline

Multiplies the first element with the second one and adds the third one, that is (e * m + a) % characteristic, such that the result is positive. Stores the result in the first element.

Warning
Not overflow safe.
Parameters
eFirst element.
mSecond element.
aThird element.

◆ multiply_inplace()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::multiply_inplace ( element_type e1,
element_type  e2 
) const
inline

Stores in the first element the multiplication of two given elements in the field, that is (e1 * e2) % characteristic, such that the result is positive.

Parameters
e1First element.
e2Second element.

◆ set_characteristic()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::set_characteristic ( characteristic_type  characteristic)
inline

Sets the characteristic of the field.

Parameters
characteristicPrime number corresponding to the desired characteristic of the field.

◆ substract()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
element_type Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::substract ( element_type  e1,
element_type  e2 
) const
inline

Returns the substraction in the field of the first element by the second element.

Parameters
e1First element.
e2Second element.
Returns
(e1 - e2) % characteristic, such that the result is positive.

◆ substract_inplace_back()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::substract_inplace_back ( element_type  e1,
element_type e2 
) const
inline

Stores in the second element the substraction in the field of the first element by the second element, that is (e1 - e2) % 2, such that the result is positive.

Parameters
e1First element.
e2Second element.

◆ substract_inplace_front()

template<typename Unsigned_integer_type = unsigned int, class = std::enable_if_t<std::is_unsigned_v<Unsigned_integer_type> >>
void Gudhi::persistence_fields::Zp_field_operators< Unsigned_integer_type, class >::substract_inplace_front ( element_type e1,
element_type  e2 
) const
inline

Stores in the first element the substraction in the field of the first element by the second element, that is (e1 - e2) % 2, such that the result is positive.

Parameters
e1First element.
e2Second element.

The documentation for this class was generated from the following file: