algebraic-structure/monoid-action.hpp
Depends on
Required by
Verified with
Code
#pragma once
#include "algebraic-structure/monoid.hpp"
#ifdef __cpp_concepts
template < class A >
concept MonoidAction = Monoid < typename A :: value_monoid > && Monoid < typename A :: operator_monoid > && requires ( typename A :: value_monoid :: value_type x , typename A :: operator_monoid :: value_type f ) {
typename A :: value_monoid ;
typename A :: operator_monoid ;
{ A :: mapping ( f , x ) } -> same_as < typename A :: value_monoid :: value_type > ;
};
#endif
#line 2 "algebraic-structure/util.hpp"
#ifdef __cpp_concepts
#define REQUIRES(...) requires __VA_ARGS__
#else
#define REQUIRES(...)
#endif
#line 3 "algebraic-structure/magma.hpp"
#ifdef __cpp_concepts
template < class M >
concept Magma = requires ( typename M :: value_type x , typename M :: value_type y ) {
typename M :: value_type ;
{ M :: op ( x , y ) } -> same_as < typename M :: value_type > ;
};
#endif
template < class T >
struct AddMagma {
using value_type = T ;
static T op ( T x , T y ) { return x + y ; }
};
template < class T >
struct MulMagma {
using value_type = T ;
static T op ( T x , T y ) { return x * y ; }
};
template < class T , T id >
struct MaxMagma {
using value_type = T ;
static T op ( T x , T y ) { return x > y ? x : y ; }
};
template < class T , T id >
struct MinMagma {
using value_type = T ;
static T op ( T x , T y ) { return x < y ? x : y ; }
};
#line 3 "algebraic-structure/monoid.hpp"
#ifdef __cpp_concepts
template < class M >
concept Monoid = Magma < M > && requires {
{ M :: e () } -> same_as < typename M :: value_type > ;
};
#endif
template < class T >
struct AddMonoid {
using value_type = T ;
static T op ( T x , T y ) { return x + y ; }
static T e () { return T ( 0 ); }
};
template < class T >
struct MulMonoid {
using value_type = T ;
static T op ( T x , T y ) { return x * y ; }
static T e () { return T ( 1 ); }
};
template < class T , T id >
struct MaxMonoid {
using value_type = T ;
static T op ( T x , T y ) { return x > y ? x : y ; }
static T e () { return id ; }
};
template < class T , T id >
struct MinMonoid {
using value_type = T ;
static T op ( T x , T y ) { return x < y ? x : y ; }
static T e () { return id ; }
};
#line 3 "algebraic-structure/monoid-action.hpp"
#ifdef __cpp_concepts
template < class A >
concept MonoidAction = Monoid < typename A :: value_monoid > && Monoid < typename A :: operator_monoid > && requires ( typename A :: value_monoid :: value_type x , typename A :: operator_monoid :: value_type f ) {
typename A :: value_monoid ;
typename A :: operator_monoid ;
{ A :: mapping ( f , x ) } -> same_as < typename A :: value_monoid :: value_type > ;
};
#endif
Back to top page