libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
template<typename Scalar = size_t>
class libsemigroups::NTPSemiring< Scalar >

Defined in matrix.hpp.

This class represents the ntp semiring consists of the integers \(\{0, 1, ..., t, t + 1, ..., t + p - 1\}\) for some \(t\) and \(p\) (called the threshold and period). Instances of this class can be used to define the value of the threshold \(t\) and period \(p\) at run time.

Template Parameters
Scalarthe type of the elements of the semiring.

Public Member Functions

 NTPSemiring ()=delete
 Deleted default constructor.
 
 NTPSemiring (NTPSemiring &&)=default
 Default move constructor.
 
 NTPSemiring (NTPSemiring const &)=default
 Default copy constructor.
 
 NTPSemiring (Scalar t, Scalar p)
 Construct from threshold and period.
 
NTPSemiringoperator= (NTPSemiring &&)=default
 Default move assignment operator.
 
NTPSemiringoperator= (NTPSemiring const &)=default
 Default copy assignment operator.
 
Scalar period () const noexcept
 Get the period.
 
Scalar plus_no_checks (Scalar x, Scalar y) const noexcept
 Addition in an ntp semiring.
 
Scalar product_no_checks (Scalar x, Scalar y) const noexcept
 Multiplication in an ntp semiring.
 
Scalar threshold () const noexcept
 Get the threshold.
 

Static Public Member Functions

static constexpr Scalar scalar_one () noexcept
 Get the multiplicative identity.
 
static constexpr Scalar scalar_zero () noexcept
 Get the additive identity.
 

Constructor & Destructor Documentation

◆ NTPSemiring() [1/4]

template<typename Scalar = size_t>
NTPSemiring ( )
delete

Deleted default constructor.

◆ NTPSemiring() [2/4]

template<typename Scalar = size_t>
NTPSemiring ( NTPSemiring< Scalar > const & )
default

Default copy constructor.

◆ NTPSemiring() [3/4]

template<typename Scalar = size_t>
NTPSemiring ( NTPSemiring< Scalar > && )
default

Default move constructor.

◆ NTPSemiring() [4/4]

template<typename Scalar = size_t>
NTPSemiring ( Scalar t,
Scalar p )
inline

Construct from threshold and period.

Parameters
tthe threshold ( \(t \geq 0\)).
pthe period ( \(p > 0\)).
Exceptions
LibsemigroupsExceptionif t is less than zero.
LibsemigroupsExceptionif p is less than or equal to zero.
Complexity
Constant.

Member Function Documentation

◆ operator=() [1/2]

template<typename Scalar = size_t>
NTPSemiring & operator= ( NTPSemiring< Scalar > && )
default

Default move assignment operator.

◆ operator=() [2/2]

template<typename Scalar = size_t>
NTPSemiring & operator= ( NTPSemiring< Scalar > const & )
default

Default copy assignment operator.

◆ period()

template<typename Scalar = size_t>
Scalar period ( ) const
inlinenoexcept

Returns the period value used to construct NTPSemiring instance.

Returns
A value of type Scalar.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ plus_no_checks()

template<typename Scalar = size_t>
Scalar plus_no_checks ( Scalar x,
Scalar y ) const
inlinenoexcept

This function returns \(x \oplus y\) which is defined by

\[ x\oplus y = \begin{cases} x + y & \text{if } x + y \leq t \\ \mbox{} t + ((x + y - t) \pmod{p}) & \text{if } x + y > t \end{cases} \]

where \(t\) is the threshold and \(p\) is the period; representing multiplication in the quotient of the semiring of natural numbers.

Parameters
xscalar ( \(0\leq x < t + p\)).
yscalar ( \(0\leq y < t + p\)).
Returns
A value of type Scalar.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ product_no_checks()

template<typename Scalar = size_t>
Scalar product_no_checks ( Scalar x,
Scalar y ) const
inlinenoexcept

This function returns \(x \otimes y\) which is defined by

\[ x\otimes y = \begin{cases} xy & \text{if } xy \leq t \\ \mbox{} t + ((xy - t)\pmod{p}) & \text{if } xy > t \end{cases} \]

where \(t\) is the threshold and \(p\) is the period; representing multiplication in the quotient of the semiring of natural numbers.

Parameters
xscalar (0 <= x < threshold() + period()).
yscalar (0 <= y < threshold() + period()).
Returns
A value of type Scalar.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ scalar_one()

template<typename Scalar = size_t>
static constexpr Scalar scalar_one ( )
inlinestaticconstexprnoexcept

This function returns \(1\); representing the multiplicative identity of the quotient of the semiring of natural numbers.

Returns
The multiplicative identity in an ntp semiring (the value 0).
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ scalar_zero()

template<typename Scalar = size_t>
static constexpr Scalar scalar_zero ( )
inlinestaticconstexprnoexcept

This function returns \(0\) representing the additive identity of the quotient of the semiring of natural numbers.

Returns
A value of type Scalar.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ threshold()

template<typename Scalar = size_t>
Scalar threshold ( ) const
inlinenoexcept

Returns the threshold value used to construct NTPSemiring instance.

Returns
A value of type Scalar.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

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