27 #ifndef _H_GRB_SEMIRING 28 #define _H_GRB_SEMIRING 186 class _OP1,
class _OP2,
187 template<
typename >
class _ID1,
188 template<
typename >
class _ID2
192 static_assert( std::is_same< typename _OP2::D3, typename _OP1::D1 >::value,
193 "The multiplicative output type must match the left-hand additive " 196 static_assert( std::is_same< typename _OP1::D2, typename _OP1::D3 >::value,
197 "The right-hand input type of the additive operator must match its " 201 "Cannot construct a semiring using a non-associative additive " 205 "Cannot construct a semiring using a non-associative multiplicative " 209 "Cannot construct a semiring using a non-commutative additive " 215 typedef typename _OP2::D1
D1;
218 typedef typename _OP2::D2
D2;
224 typedef typename _OP2::D3
D3;
230 typedef typename _OP1::D2
D4;
245 template<
typename ZeroType >
249 template<
typename OneType >
250 using One = _ID2< OneType >;
255 static constexpr
size_t D1_bsz = grb::config::SIMD_BLOCKSIZE< D1 >::value();
256 static constexpr
size_t D2_bsz = grb::config::SIMD_BLOCKSIZE< D2 >::value();
257 static constexpr
size_t D3_bsz = grb::config::SIMD_BLOCKSIZE< D3 >::value();
258 static constexpr
size_t D4_bsz = grb::config::SIMD_BLOCKSIZE< D4 >::value();
259 static constexpr
size_t mul_input_bsz = D1_bsz < D2_bsz ? D1_bsz : D2_bsz;
297 template<
typename D >
299 return additiveMonoid.template getIdentity< D >();
313 template<
typename D >
315 return multiplicativeMonoid.template getIdentity< D >();
324 return additiveMonoid;
333 return multiplicativeMonoid;
358 class _OP1,
class _OP2,
359 template<
typename >
class _ID1,
360 template<
typename >
class _ID2
363 Semiring< _OP1, _OP2, _ID1, _ID2 >
366 static const constexpr
bool value =
true;
370 class _OP1,
class _OP2,
371 template<
typename >
class _ID1,
372 template<
typename >
class _ID2
374 struct has_immutable_nonzeroes<
375 Semiring< _OP1, _OP2, _ID1, _ID2 >
378 Semiring< _OP1, _OP2, _ID1, _ID2 > >
::value &&
381 typename _OP1::D2,
typename _OP1::D3
Used to inspect whether a given operator or monoid is commutative.
Definition: type_traits.hpp:240
static constexpr size_t blocksize_add
Blocksize for element-wise addition.
Definition: semiring.hpp:271
Used to inspect whether a given operator or monoid is associative.
Definition: type_traits.hpp:202
_OP1::D2 D4
The second input domain of the additive operator.
Definition: semiring.hpp:230
static const constexpr bool value
Whether T is an ALP semiring.
Definition: type_traits.hpp:73
AdditiveOperator getAdditiveOperator() const
Retrieves the underlying additive operator.
Definition: semiring.hpp:341
MultiplicativeOperator getMultiplicativeOperator() const
Retrieves the underlying multiplicative operator.
Definition: semiring.hpp:350
MultiplicativeMonoid getMultiplicativeMonoid() const
Retrieves the underlying multiplicative monoid.
Definition: semiring.hpp:332
Used to inspect whether a given type is an ALP semiring.
Definition: type_traits.hpp:66
_ID1< ZeroType > Zero
The identity under addition.
Definition: semiring.hpp:246
_OP2::D3 D3
The output domain of the multiplicative operator.
Definition: semiring.hpp:224
AdditiveMonoid getAdditiveMonoid() const
Retrieves the underlying additive monoid.
Definition: semiring.hpp:323
Provides a set of standard identities for use with ALP.
D getZero() const
Retrieves the zero corresponding to this semiring.
Definition: semiring.hpp:298
_OP2 MultiplicativeOperator
The multiplicative operator type.
Definition: semiring.hpp:236
_OP1 AdditiveOperator
The additive operator type.
Definition: semiring.hpp:233
Monoid< _OP2, _ID2 > MultiplicativeMonoid
The multiplicative monoid type.
Definition: semiring.hpp:242
Operator getOperator() const
Retrieves the underlying operator.
Definition: monoid.hpp:120
_OP2::D1 D1
The first input domain of the multiplicative operator.
Definition: semiring.hpp:194
static constexpr size_t blocksize
Blocksize for element-wise multiply-adds.
Definition: semiring.hpp:281
Monoid< _OP1, _ID1 > AdditiveMonoid
The additive monoid type.
Definition: semiring.hpp:239
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:477
D getOne() const
Sets the given value equal to one, corresponding to this semiring.
Definition: semiring.hpp:314
_OP2::D2 D2
The second input domain of the multiplicative operator.
Definition: semiring.hpp:218
The logical or.
Definition: ops.hpp:462
A generalised semiring.
Definition: semiring.hpp:190
_ID2< OneType > One
The identity under multiplication.
Definition: semiring.hpp:250
static const constexpr bool value
Whether T a semiring where nonzeroes are immutable.
Definition: type_traits.hpp:286
Provides a set of standard binary operators.
static constexpr size_t blocksize_mul
Blocksize for element-wise multiplication.
Definition: semiring.hpp:276