libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
Matrices over the natural numbers mod (t = t + p)

Defined in matrix.hpp.

This page describes the functionality for \(n \times n\) matrices over the finite quotient of the usual semiring of natural number by the congruence \(t = t + p\) for arbitrary \(n\), \(t\), and \(p\). The value \(t\) is referred to as the threshold and \(p\) is called the period. The matrices of this type are referred to by the acronym ntp matrices, for "natural threshold period". The NTPSemiring has elements \(\{0, 1, ..., t, t + 1, ..., t + p - 1\}\) where \(t\), and \(p\) are the threshold and period, respectively; addition and multiplication in the NTPSemiring is defined below.

There are three types of such matrices where:

  1. the dimension is known at compile-time;
  2. the dimension is to be defined a run time but the arithmetic operations are known at compile-time (i.e. the values of \(t\) and \(p\) are known at compile time)
  3. both the dimension and the arithmetic operations (i.e. \(t\) and \(p\)) are to be defined a run time.

All three of these types can be accessed via the alias template NTPMat<T, P, R, C, Scalar> if T and P have value 0, then the threshold and period can be set at run time, and if R or C is 0, then the dimension can be set at run time. The default values of T, P, and R are 0, and the default value of C is R.

The alias NTPMat is one of StaticMatrix, DynamicMatrix (compile-time arithmetic), or DynamicMatrix (run-time arithmetic); please refer to the documentation of these class templates for more details. The only substantial difference in the interface of static and dynamic matrices is that the former can be default constructed and the latter should be constructed using the dimensions.

Example
// construct an uninitialized 3 x 3 static matrix with threshold
// 11, period 2
// construct an uninitialized 4 x 4 dynamic matrix with threshold 11,
// period 2
NTPMat<11, 2> m(4, 4);
// construct an ntp semiring with threshold 11, period 2
NTPSemiring sr(11, 2);
// construct an uninitialized 5 x 5 dynamic matrix with threshold 11,
// period 2
NTPMat<> m(sr, 5, 5);
std::conditional_t< R==0||C==0, std::conditional_t< T==0 &&P==0, DynamicNTPMatWithSemiring< Scalar >, DynamicNTPMatWithoutSemiring< T, P, Scalar > >, StaticNTPMat< T, P, R, C, Scalar > > NTPMat
Alias template for ntp matrices.
Definition matrix.hpp:6397

Classes

struct  NTPPlus< T, P, Scalar >
 Function object for addition in ntp semirings. More...
 
struct  NTPProd< T, P, Scalar >
 Function object for multiplication in an ntp semirings. More...
 
class  NTPSemiring< Scalar >
 Class representing an ntp semiring. More...
 

Typedefs

template<size_t T, size_t P, typename Scalar>
using DynamicNTPMatWithoutSemiring
 Alias for ntp matrices with static threshold and period.
 
template<typename Scalar>
using DynamicNTPMatWithSemiring = DynamicMatrix<NTPSemiring<Scalar>, Scalar>
 Alias for ntp matrices with dynamic threshold and period.
 
template<size_t T = 0, size_t P = 0, size_t R = 0, size_t C = R, typename Scalar = size_t>
using NTPMat
 Alias template for ntp matrices.
 
template<size_t T, size_t P, size_t R, size_t C, typename Scalar>
using StaticNTPMat
 Alias for ntp matrices with static threshold and period, and dimensions.
 

Functions

template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry (Mat const &m)
 Check that the entries in an ntp matrix are valid.
 
template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry (Mat const &m, typename Mat::scalar_type val)
 Check that an entry in an ntp matrix is valid.
 

Variables

template<typename U>
static constexpr bool IsNTPMat = detail::IsNTPMatHelper<U>::value
 Helper to check if a type is NTPMat.
 

Typedef Documentation

◆ DynamicNTPMatWithoutSemiring

template<size_t T, size_t P, typename Scalar>
using DynamicNTPMatWithoutSemiring
Initial value:
DynamicMatrix<NTPPlus<T, P, Scalar>,
Scalar>
Function object for returning the multiplicative identity.
Definition matrix.hpp:4213
Function object for returning the additive identity.
Definition matrix.hpp:4188
Function object for multiplication in an ntp semirings.
Definition matrix.hpp:6093

Defined in matrix.hpp.

Alias for the type of dynamic ntp matrices where the dimension is defined at run time, but the threshold and period are defined at compile-time.

Template Parameters
Tthe threshold.
Pthe period.
Scalarthe type of the entries in the matrix.

◆ DynamicNTPMatWithSemiring

template<typename Scalar>
using DynamicNTPMatWithSemiring = DynamicMatrix<NTPSemiring<Scalar>, Scalar>

Defined in matrix.hpp.

Alias for ntp matrices with dimensions, threshold, and period defined at runtime.

Template Parameters
Scalarthe type of the entries in the matrix.

◆ NTPMat

template<size_t T = 0, size_t P = 0, size_t R = 0, size_t C = R, typename Scalar = size_t>
using NTPMat
Initial value:
std::conditional_t<
R == 0 || C == 0,
std::conditional_t<T == 0 && P == 0,
DynamicMatrix< NTPSemiring< Scalar >, Scalar > DynamicNTPMatWithSemiring
Alias for ntp matrices with dynamic threshold and period.
Definition matrix.hpp:6320
DynamicMatrix< NTPPlus< T, P, Scalar >, NTPProd< T, P, Scalar >, IntegerZero< Scalar >, IntegerOne< Scalar >, Scalar > DynamicNTPMatWithoutSemiring
Alias for ntp matrices with static threshold and period.
Definition matrix.hpp:6336
StaticMatrix< NTPPlus< T, P, Scalar >, NTPProd< T, P, Scalar >, IntegerZero< Scalar >, IntegerOne< Scalar >, R, C, Scalar > StaticNTPMat
Alias for ntp matrices with static threshold and period, and dimensions.
Definition matrix.hpp:6362

Defined in matrix.hpp.

Alias template for ntp matrices.

Template Parameters
Tthe threshold. If both T and P are 0, this indicates that the value will be set at run time (default: 0).
Pthe period. If both T and P are 0, this indicates that the value will be set at run time (default: 0).
Rthe number of rows. A value of 0 indicates that the value will be set at run time (default: 0).
Cthe number of columns. A value of 0 indicates that the value will be set at run time (default: R).
Scalarthe type of the entries in the matrix (default: size_t).

◆ StaticNTPMat

template<size_t T, size_t P, size_t R, size_t C, typename Scalar>
using StaticNTPMat
Initial value:

Defined in matrix.hpp.

Alias for static ntp matrices where the threshold, period, and dimensions are defined at compile-time.

Template Parameters
Tthe threshold.
Pthe period.
Rthe number of rows.
Cthe number of columns.
Scalarthe type of the entries in the matrix (default: int).

Function Documentation

◆ throw_if_bad_entry() [1/2]

template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry ( Mat const & m)

Defined in matrix.hpp.

This function can be used to check that a matrix contains values in the underlying semiring.

Template Parameters
Matthe type of the matrix m (must satisfy IsNTPMat<Mat>).
Parameters
mthe matrix to check.
Exceptions
LibsemigroupsExceptionif any entry in the matrix is not in the set \(\{0, 1, \ldots, t + p - 1\}\) where \(t\) is the threshold, and \(p\) the period, of the matrix.
LibsemigroupsExceptionif the underlying semiring is not defined (only applies to matrices with run time arithmetic).

◆ throw_if_bad_entry() [2/2]

template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry ( Mat const & m,
typename Mat::scalar_type val )

Defined in matrix.hpp.

This function can be used to check that a matrix contains values in the underlying semiring.

Template Parameters
Matthe type of the 1st argument (must satisfy IsNTPMat<Mat>).
Parameters
mthe matrix.
valthe entry to check.
Exceptions
LibsemigroupsExceptionif the entry val is not in the set \(\{0, 1, \ldots, t + p - 1\}\) where \(t\) is the threshold, and \(p\) the period, of the matrix.
LibsemigroupsExceptionif the underlying semiring is not defined (only applies to matrices with run time arithmetic).

Variable Documentation

◆ IsNTPMat

template<typename U>
bool IsNTPMat = detail::IsNTPMatHelper<U>::value
staticconstexpr

Defined in matrix.hpp.

This variable has value true if the template parameter U is the same as NTPMat<T, P, R, C, Scalar> for some values of T, P, R, C, and Scalar; and false if it is not.

Template Parameters
Uthe type to check.