27#ifndef _H_GRB_OPERATORS
28#define _H_GRB_OPERATORS
30#include "internalops.hpp"
55 typename D1,
typename D2 = D1,
typename D3 = D2,
56 enum Backend implementation = config::default_backend
59 public internal::Operator<
60 internal::left_assign< D1, D2, D3, implementation >
65 template<
typename A,
typename B,
typename C, enum Backend D >
81 typename D1,
typename D2 = D1,
typename D3 = D2,
82 enum Backend implementation = config::default_backend
85 public internal::Operator<
86 internal::left_assign_if< D1, D2, D3, implementation >
91 template<
typename A,
typename B,
typename C, enum Backend D >
110 typename D1,
typename D2 = D1,
typename D3 = D2,
111 enum Backend implementation = config::default_backend
114 internal::right_assign< D1, D2, D3, implementation >
119 template<
typename A,
typename B,
typename C, enum Backend D >
135 typename D1,
typename D2 = D1,
typename D3 = D2,
136 enum Backend implementation = config::default_backend
139 internal::right_assign_if< D1, D2, D3, implementation >
144 template<
typename A,
typename B,
typename C, enum Backend D >
168 typename D1,
typename D2 = D1,
typename D3 = D2,
169 enum Backend implementation = config::default_backend
171 class add :
public internal::Operator<
172 internal::add< D1, D2, D3, implementation >
178 template<
typename A,
typename B,
typename C, enum Backend D >
202 typename D1,
typename D2 = D1,
typename D3 = D2,
203 enum Backend implementation = config::default_backend
205 class mul :
public internal::Operator<
206 internal::mul< D1, D2, D3, implementation >
211 template<
typename A,
typename B,
typename C, enum Backend D >
235 typename D1,
typename D2 = D1,
typename D3 = D2,
236 enum Backend implementation = config::default_backend
238 class max :
public internal::Operator<
239 internal::max< D1, D2, D3, implementation >
244 template<
typename A,
typename B,
typename C, enum Backend D >
268 typename D1,
typename D2 = D1,
typename D3 = D2,
269 enum Backend implementation = config::default_backend
271 class min :
public internal::Operator<
272 internal::min< D1, D2, D3, implementation >
277 template<
typename A,
typename B,
typename C, enum Backend D >
295 typename D1,
typename D2 = D1,
typename D3 = D2,
296 enum Backend implementation = config::default_backend
299 internal::substract< D1, D2, D3, implementation >
304 template<
typename A,
typename B,
typename C, enum Backend D >
322 typename D1,
typename D2 = D1,
typename D3 = D2,
323 enum Backend implementation = config::default_backend
325 class divide :
public internal::Operator<
326 internal::divide< D1, D2, D3, implementation >
331 template<
typename A,
typename B,
typename C, enum Backend D >
347 typename D1,
typename D2 = D1,
typename D3 = D2,
348 enum Backend implementation = config::default_backend
351 internal::divide_reverse< D1, D2, D3, implementation >
356 template<
typename A,
typename B,
typename C, enum Backend D >
373 typename D1,
typename D2 = D1,
typename D3 = D2,
374 enum Backend implementation = config::default_backend
376 class equal :
public internal::Operator<
377 internal::equal< D1, D2, D3, implementation >
382 template<
typename A,
typename B,
typename C, enum Backend D >
399 typename D1,
typename D2 = D1,
typename D3 = D2,
400 enum Backend implementation = config::default_backend
403 internal::not_equal< D1, D2, D3, implementation >
408 template<
typename A,
typename B,
typename C, enum Backend D >
428 typename D1,
typename D2 = D1,
typename D3 = D2,
429 enum Backend implementation = config::default_backend
431 class any_or :
public internal::Operator<
432 internal::any_or< D1, D2, D3, implementation >
437 template<
typename A,
typename B,
typename C, enum Backend D >
456 typename D1,
typename D2 = D1,
typename D3 = D2,
457 enum Backend implementation = config::default_backend
460 internal::logical_or< D1, D2, D3, implementation >
466 template<
typename A,
typename B,
typename C, enum Backend D >
485 typename D1,
typename D2 = D1,
typename D3 = D2,
486 enum Backend implementation = config::default_backend
489 internal::logical_and< D1, D2, D3, implementation >
494 template<
typename A,
typename B,
typename C, enum Backend D >
509 typename D1,
typename D2 = D1,
typename D3 = D2,
510 enum Backend implementation = config::default_backend
512 class relu :
public internal::Operator<
513 internal::relu< D1, D2, D3, implementation >
518 template<
typename A,
typename B,
typename C, enum Backend D >
536 typename D1,
typename D2 = D1,
typename D3 = D2,
537 enum Backend implementation = config::default_backend
540 internal::abs_diff< D1, D2, D3, implementation >
545 template<
typename A,
typename B,
typename C, enum Backend D >
569 template<
typename IType,
typename VType >
570 class argmin :
public internal::Operator< internal::argmin< IType, VType > > {
593 template<
typename IType,
typename VType >
594 class argmax :
public internal::Operator< internal::argmax< IType, VType > > {
611 typename D1,
typename D2,
typename D3,
612 enum Backend implementation = config::default_backend
615 internal::square_diff< D1, D2, D3, implementation >
620 template<
typename A,
typename B,
typename C, enum Backend D >
636 typename IN1,
typename IN2,
637 enum Backend implementation = config::default_backend
639 class zip :
public internal::Operator<
640 internal::zip< IN1, IN2, implementation >
645 template<
typename A,
typename B, enum Backend D >
664 typename D1,
typename D2 = D1,
typename D3 = D2,
665 enum Backend implementation = config::default_backend
668 internal::equal_first< D1, D2, D3, implementation >
673 template<
typename A,
typename B,
typename C, enum Backend D >
681 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
682 struct is_operator< operators::left_assign_if< D1, D2, D3, implementation > > {
683 static const constexpr bool value =
true;
686 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
687 struct is_operator< operators::right_assign_if< D1, D2, D3, implementation > > {
688 static const constexpr bool value =
true;
691 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
692 struct is_operator< operators::left_assign< D1, D2, D3, implementation > > {
693 static const constexpr bool value =
true;
696 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
697 struct is_operator< operators::right_assign< D1, D2, D3, implementation > > {
698 static const constexpr bool value =
true;
702 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
703 struct is_operator< operators::add< D1, D2, D3, implementation > > {
704 static const constexpr bool value =
true;
708 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
709 struct is_operator< operators::mul< D1, D2, D3, implementation > > {
710 static const constexpr bool value =
true;
713 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
714 struct is_operator< operators::max< D1, D2, D3, implementation > > {
715 static const constexpr bool value =
true;
718 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
719 struct is_operator< operators::min< D1, D2, D3, implementation > > {
720 static const constexpr bool value =
true;
723 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
724 struct is_operator< operators::subtract< D1, D2, D3, implementation > > {
725 static const constexpr bool value =
true;
728 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
729 struct is_operator< operators::divide< D1, D2, D3, implementation > > {
730 static const constexpr bool value =
true;
733 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
734 struct is_operator< operators::divide_reverse< D1, D2, D3, implementation > > {
735 static const constexpr bool value =
true;
738 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
739 struct is_operator< operators::equal< D1, D2, D3, implementation > > {
740 static const constexpr bool value =
true;
743 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
744 struct is_operator< operators::not_equal< D1, D2, D3, implementation > > {
745 static const constexpr bool value =
true;
748 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
749 struct is_operator< operators::any_or< D1, D2, D3, implementation > > {
750 static const constexpr bool value =
true;
753 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
754 struct is_operator< operators::logical_or< D1, D2, D3, implementation > > {
755 static const constexpr bool value =
true;
758 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
759 struct is_operator< operators::logical_and< D1, D2, D3, implementation > > {
760 static const constexpr bool value =
true;
763 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
764 struct is_operator< operators::abs_diff< D1, D2, D3, implementation > > {
765 static const constexpr bool value =
true;
768 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
769 struct is_operator< operators::relu< D1, D2, D3, implementation > > {
770 static const constexpr bool value =
true;
773 template<
typename IType,
typename VType >
774 struct is_operator< operators::argmin< IType, VType > > {
775 static const constexpr bool value =
true;
778 template<
typename IType,
typename VType >
779 struct is_operator< operators::argmax< IType, VType > > {
780 static const constexpr bool value =
true;
783 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
784 struct is_operator< operators::square_diff< D1, D2, D3, implementation > > {
785 static const constexpr bool value =
true;
788 template<
typename IN1,
typename IN2, enum Backend implementation >
789 struct is_operator< operators::
zip< IN1, IN2, implementation > > {
790 static const constexpr bool value =
true;
793 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
794 struct is_operator< operators::equal_first< D1, D2, D3, implementation > > {
795 static const constexpr bool value =
true;
798 template<
typename D1,
typename D2,
typename D3 >
799 struct is_idempotent< operators::min< D1, D2, D3 >, void > {
800 static const constexpr bool value =
true;
803 template<
typename D1,
typename D2,
typename D3 >
804 struct is_idempotent< operators::max< D1, D2, D3 >, void > {
805 static const constexpr bool value =
true;
808 template<
typename D1,
typename D2,
typename D3 >
809 struct is_idempotent< operators::any_or< D1, D2, D3 >, void > {
810 static const constexpr bool value =
true;
813 template<
typename D1,
typename D2,
typename D3 >
814 struct is_idempotent< operators::logical_or< D1, D2, D3 >, void > {
815 static const constexpr bool value =
true;
818 template<
typename D1,
typename D2,
typename D3 >
819 struct is_idempotent< operators::logical_and< D1, D2, D3 >, void > {
820 static const constexpr bool value =
true;
823 template<
typename D1,
typename D2,
typename D3 >
824 struct is_idempotent< operators::relu< D1, D2, D3 >, void > {
825 static const constexpr bool value =
true;
828 template<
typename D1,
typename D2,
typename D3 >
829 struct is_idempotent< operators::left_assign_if< D1, D2, D3 >, void > {
830 static const constexpr bool value =
true;
833 template<
typename D1,
typename D2,
typename D3 >
834 struct is_idempotent< operators::right_assign_if< D1, D2, D3 >, void > {
835 static const constexpr bool value =
true;
838 template<
typename IType,
typename VType >
839 struct is_idempotent< operators::argmin< IType, VType >, void > {
840 static const constexpr bool value =
true;
843 template<
typename IType,
typename VType >
844 struct is_idempotent< operators::argmax< IType, VType >, void > {
845 static const constexpr bool value =
true;
848 template<
typename OP >
849 struct is_associative<
851 typename std::enable_if< is_operator< OP >::value, void >::type
853 static constexpr const bool value = OP::is_associative();
856 template<
typename OP >
857 struct is_commutative<
859 typename std::enable_if< is_operator< OP >::value, void >::type
861 static constexpr const bool value = OP::is_commutative();
868 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
869 struct maybe_noop< operators::left_assign_if< D1, D2, D3, implementation > > {
870 static const constexpr bool value =
true;
873 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
874 struct maybe_noop< operators::right_assign_if< D1, D2, D3, implementation > > {
875 static const constexpr bool value =
true;
888 #define _DEBUG_NO_IOSTREAM_PAIR_CONVERTER
892 #ifndef _DEBUG_NO_IOSTREAM_PAIR_CONVERTER
894 template<
typename U,
typename V >
895 std::ostream & operator<<( std::ostream &out,
const std::pair< U, V > &pair ) {
896 out <<
"( " << pair.first <<
", " << pair.second <<
" )";
This operator returns the absolute difference between two numbers.
Definition: ops.hpp:542
This operator takes the sum of the two input parameters and writes it to the output variable.
Definition: ops.hpp:174
This operator is a generalisation of the logical or.
Definition: ops.hpp:434
The argmax operator on key-value pairs.
Definition: ops.hpp:594
The argmin operator on key-value pairs.
Definition: ops.hpp:570
Reversed division of two numbers.
Definition: ops.hpp:353
Numerical division of two numbers.
Definition: ops.hpp:328
Compares std::pair inputs taking the first entry in every pair as the comparison key,...
Definition: ops.hpp:670
Operator which returns true if its inputs compare equal, and false otherwise.
Definition: ops.hpp:379
This operator assigns the left-hand input if the right-hand input evaluates true.
Definition: ops.hpp:88
This operator discards all right-hand side input and simply copies the left-hand side input to the ou...
Definition: ops.hpp:62
The logical and.
Definition: ops.hpp:491
The logical or.
Definition: ops.hpp:462
This operator takes the maximum of the two input parameters and writes the result to the output varia...
Definition: ops.hpp:241
This operator takes the minimum of the two input parameters and writes the result to the output varia...
Definition: ops.hpp:274
This operator multiplies the two input parameters and writes the result to the output variable.
Definition: ops.hpp:208
Operator that returns false whenever its inputs compare equal, and true otherwise.
Definition: ops.hpp:405
This operation is equivalent to grb::operators::min.
Definition: ops.hpp:515
This operator assigns the right-hand input if the left-hand input evaluates true.
Definition: ops.hpp:141
This operator discards all left-hand side input and simply copies the right-hand side input to the ou...
Definition: ops.hpp:116
This operation returns the squared difference between two numbers.
Definition: ops.hpp:617
Numerical substraction of two numbers.
Definition: ops.hpp:301
The zip operator that operators on keys as a left-hand input and values as a right hand input,...
Definition: ops.hpp:642
RC zip(Matrix< OutputType, backend, RIT, CIT, NIT > &A, const Vector< InputType1, backend, Coords > &x, const Vector< InputType2, backend, Coords > &y, const Vector< InputType3, backend, Coords > &z, const Phase &phase=EXECUTE)
The grb::zip merges three vectors into a matrix.
Definition: blas3.hpp:181
Backend
A collection of all backends.
Definition: backends.hpp:46
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:450
static const constexpr bool value
Whether T is associative.
Definition: type_traits.hpp:208
static const constexpr bool value
Whether T is commutative.
Definition: type_traits.hpp:246
static const constexpr bool value
Wheter T is idempotent.
Definition: type_traits.hpp:167
Used to inspect whether a given type is an ALP operator.
Definition: type_traits.hpp:104
static const constexpr bool value
Whether T is an ALP operator.
Definition: type_traits.hpp:111
Specifies the ALP algebraic type traits.