27#ifndef _H_GRB_SEMIRING
28#define _H_GRB_SEMIRING
185 template<
class _OP1,
class _OP2,
template<
typename >
class _ID1,
template<
typename >
class _ID2 >
188 static_assert( std::is_same< typename _OP2::D3, typename _OP1::D1 >::value,
189 "The multiplicative output type must match the left-hand additive "
192 static_assert( std::is_same< typename _OP1::D2, typename _OP1::D3 >::value,
193 "The right-hand input type of the additive operator must match its "
197 "Cannot construct a semiring using a non-associative additive "
201 "Cannot construct a semiring using a non-associative multiplicative "
205 "Cannot construct a semiring using a non-commutative additive "
210 typedef typename _OP2::D1
D1;
213 typedef typename _OP2::D2
D2;
219 typedef typename _OP2::D3
D3;
225 typedef typename _OP1::D2
D4;
240 template<
typename ZeroType >
244 template<
typename OneType >
245 using One = _ID2< OneType >;
248 static constexpr size_t D1_bsz = grb::config::SIMD_BLOCKSIZE< D1 >::value();
249 static constexpr size_t D2_bsz = grb::config::SIMD_BLOCKSIZE< D2 >::value();
250 static constexpr size_t D3_bsz = grb::config::SIMD_BLOCKSIZE< D3 >::value();
251 static constexpr size_t D4_bsz = grb::config::SIMD_BLOCKSIZE< D4 >::value();
252 static constexpr size_t mul_input_bsz = D1_bsz < D2_bsz ? D1_bsz : D2_bsz;
265 static constexpr size_t blocksize_mul = mul_input_bsz < D3_bsz ? mul_input_bsz : D3_bsz;
282 template<
typename D >
284 return additiveMonoid.template getIdentity< D >();
298 template<
typename D >
300 return multiplicativeMonoid.template getIdentity< D >();
309 return additiveMonoid;
318 return multiplicativeMonoid;
341 template<
class _OP1,
class _OP2,
template<
typename >
class _ID1,
template<
typename >
class _ID2 >
342 struct is_semiring< Semiring< _OP1, _OP2, _ID1, _ID2 > > {
344 static const constexpr bool value =
true;
347 template<
class _OP1,
class _OP2,
template<
typename >
class _ID1,
template<
typename >
class _ID2 >
348 struct has_immutable_nonzeroes< Semiring< _OP1, _OP2, _ID1, _ID2 > > {
350 std::is_same< _OP1, typename grb::operators::logical_or< typename _OP1::D1, typename _OP1::D2, typename _OP1::D3 > >
::value;
Operator getOperator() const
Retrieves the underlying operator.
Definition: monoid.hpp:120
A generalised semiring.
Definition: semiring.hpp:186
static constexpr size_t blocksize_mul
Blocksize for element-wise multiplication.
Definition: semiring.hpp:265
_OP2::D2 D2
The second input domain of the multiplicative operator.
Definition: semiring.hpp:213
_OP2::D3 D3
The output domain of the multiplicative operator.
Definition: semiring.hpp:219
static constexpr size_t blocksize
Blocksize for element-wise multiply-adds.
Definition: semiring.hpp:268
constexpr D getZero() const
Retrieves the zero corresponding to this semiring.
Definition: semiring.hpp:283
Monoid< _OP2, _ID2 > MultiplicativeMonoid
The multiplicative monoid type.
Definition: semiring.hpp:237
_OP1::D2 D4
The second input domain of the additive operator.
Definition: semiring.hpp:225
AdditiveMonoid getAdditiveMonoid() const
Retrieves the underlying additive monoid.
Definition: semiring.hpp:308
MultiplicativeOperator getMultiplicativeOperator() const
Retrieves the underlying multiplicative operator.
Definition: semiring.hpp:335
AdditiveOperator getAdditiveOperator() const
Retrieves the underlying additive operator.
Definition: semiring.hpp:326
_OP2::D1 D1
The first input domain of the multiplicative operator.
Definition: semiring.hpp:190
_OP2 MultiplicativeOperator
The multiplicative operator type.
Definition: semiring.hpp:231
constexpr D getOne() const
Sets the given value equal to one, corresponding to this semiring.
Definition: semiring.hpp:299
_ID1< ZeroType > Zero
The identity under addition.
Definition: semiring.hpp:241
Monoid< _OP1, _ID1 > AdditiveMonoid
The additive monoid type.
Definition: semiring.hpp:234
MultiplicativeMonoid getMultiplicativeMonoid() const
Retrieves the underlying multiplicative monoid.
Definition: semiring.hpp:317
_ID2< OneType > One
The identity under multiplication.
Definition: semiring.hpp:245
static constexpr size_t blocksize_add
Blocksize for element-wise addition.
Definition: semiring.hpp:262
_OP1 AdditiveOperator
The additive operator type.
Definition: semiring.hpp:228
Provides a set of standard identities for use with ALP.
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
Provides a set of standard binary operators.
static const constexpr bool value
Whether T a semiring where nonzeroes are immutable.
Definition: type_traits.hpp:286
Used to inspect whether a given operator or monoid is associative.
Definition: type_traits.hpp:202
Used to inspect whether a given operator or monoid is commutative.
Definition: type_traits.hpp:240
Used to inspect whether a given type is an ALP semiring.
Definition: type_traits.hpp:66
static const constexpr bool value
Whether T is an ALP semiring.
Definition: type_traits.hpp:73