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 >
82 typename D1,
typename D2 = D1,
typename D3 = D2,
83 enum Backend implementation = config::default_backend
86 public internal::Operator<
87 internal::left_assign_if< D1, D2, D3, implementation >
92 template<
typename A,
typename B,
typename C, enum Backend D >
112 typename D1,
typename D2 = D1,
typename D3 = D2,
113 enum Backend implementation = config::default_backend
116 internal::right_assign< D1, D2, D3, implementation >
121 template<
typename A,
typename B,
typename C, enum Backend D >
138 typename D1,
typename D2 = D1,
typename D3 = D2,
139 enum Backend implementation = config::default_backend
142 internal::right_assign_if< D1, D2, D3, implementation >
147 template<
typename A,
typename B,
typename C, enum Backend D >
172 typename D1,
typename D2 = D1,
typename D3 = D2,
173 enum Backend implementation = config::default_backend
175 class add :
public internal::Operator<
176 internal::add< D1, D2, D3, implementation >
181 template<
typename A,
typename B,
typename C, enum Backend D >
205 typename D1,
typename D2 = D1,
typename D3 = D2,
206 enum Backend implementation = config::default_backend
208 class mul :
public internal::Operator<
209 internal::mul< D1, D2, D3, implementation >
214 template<
typename A,
typename B,
typename C, enum Backend D >
238 typename D1,
typename D2 = D1,
typename D3 = D2,
239 enum Backend implementation = config::default_backend
241 class max :
public internal::Operator<
242 internal::max< D1, D2, D3, implementation >
247 template<
typename A,
typename B,
typename C, enum Backend D >
271 typename D1,
typename D2 = D1,
typename D3 = D2,
272 enum Backend implementation = config::default_backend
274 class min :
public internal::Operator<
275 internal::min< D1, D2, D3, implementation >
280 template<
typename A,
typename B,
typename C, enum Backend D >
298 typename D1,
typename D2 = D1,
typename D3 = D2,
299 enum Backend implementation = config::default_backend
302 internal::substract< D1, D2, D3, implementation >
307 template<
typename A,
typename B,
typename C, enum Backend D >
325 typename D1,
typename D2 = D1,
typename D3 = D2,
326 enum Backend implementation = config::default_backend
328 class divide :
public internal::Operator<
329 internal::divide< D1, D2, D3, implementation >
334 template<
typename A,
typename B,
typename C, enum Backend D >
350 typename D1,
typename D2 = D1,
typename D3 = D2,
351 enum Backend implementation = config::default_backend
354 internal::divide_reverse< D1, D2, D3, implementation >
359 template<
typename A,
typename B,
typename C, enum Backend D >
376 typename D1,
typename D2 = D1,
typename D3 = D2,
377 enum Backend implementation = config::default_backend
379 class equal :
public internal::Operator<
380 internal::equal< D1, D2, D3, implementation >
385 template<
typename A,
typename B,
typename C, enum Backend D >
402 typename D1,
typename D2 = D1,
typename D3 = D2,
403 enum Backend implementation = config::default_backend
406 internal::not_equal< D1, D2, D3, implementation >
411 template<
typename A,
typename B,
typename C, enum Backend D >
431 typename D1,
typename D2 = D1,
typename D3 = D2,
432 enum Backend implementation = config::default_backend
434 class any_or :
public internal::Operator<
435 internal::any_or< D1, D2, D3, implementation >
440 template<
typename A,
typename B,
typename C, enum Backend D >
459 typename D1,
typename D2 = D1,
typename D3 = D2,
460 enum Backend implementation = config::default_backend
463 internal::logical_or< D1, D2, D3, implementation >
468 template<
typename A,
typename B,
typename C, enum Backend D >
487 typename D1,
typename D2 = D1,
typename D3 = D2,
488 enum Backend implementation = config::default_backend
491 internal::logical_and< D1, D2, D3, implementation >
496 template<
typename A,
typename B,
typename C, enum Backend D >
511 typename D1,
typename D2 = D1,
typename D3 = D2,
512 enum Backend implementation = config::default_backend
514 class relu :
public internal::Operator<
515 internal::relu< D1, D2, D3, implementation >
520 template<
typename A,
typename B,
typename C, enum Backend D >
538 typename D1,
typename D2 = D1,
typename D3 = D2,
539 enum Backend implementation = config::default_backend
542 internal::abs_diff< D1, D2, D3, implementation >
547 template<
typename A,
typename B,
typename C, enum Backend D >
572 template<
typename IType,
typename VType >
573 class argmin :
public internal::Operator< internal::argmin< IType, VType > > {
599 template<
typename IType,
typename VType >
600 class argmax :
public internal::Operator< internal::argmax< IType, VType > > {
620 typename D1,
typename D2,
typename D3,
621 enum Backend implementation = config::default_backend
624 internal::square_diff< D1, D2, D3, implementation >
629 template<
typename A,
typename B,
typename C, enum Backend D >
646 typename IN1,
typename IN2,
647 enum Backend implementation = config::default_backend
649 class zip :
public internal::Operator<
650 internal::zip< IN1, IN2, implementation >
655 template<
typename A,
typename B, enum Backend D >
675 typename D1,
typename D2 = D1,
typename D3 = D2,
676 enum Backend implementation = config::default_backend
679 internal::equal_first< D1, D2, D3, implementation >
684 template<
typename A,
typename B,
typename C, enum Backend D >
704 typename D1,
typename D2 = D1,
typename D3 = D2,
705 enum Backend implementation = config::default_backend
708 internal::lt< D1, D2, D3, implementation >
713 template<
typename A,
typename B,
typename C, enum Backend D >
733 typename D1,
typename D2 = D1,
typename D3 = D2,
734 enum Backend implementation = config::default_backend
736 class leq :
public internal::Operator<
737 internal::leq< D1, D2, D3, implementation >
742 template<
typename A,
typename B,
typename C, enum Backend D >
762 typename D1,
typename D2 = D1,
typename D3 = D2,
763 enum Backend implementation = config::default_backend
766 internal::gt< D1, D2, D3, implementation >
771 template<
typename A,
typename B,
typename C, enum Backend D >
791 typename D1,
typename D2 = D1,
typename D3 = D2,
792 enum Backend implementation = config::default_backend
794 class geq :
public internal::Operator<
795 internal::geq< D1, D2, D3, implementation >
800 template<
typename A,
typename B,
typename C, enum Backend D >
809 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
810 struct is_operator< operators::left_assign_if< D1, D2, D3, implementation > > {
811 static const constexpr bool value =
true;
814 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
815 struct is_operator< operators::right_assign_if< D1, D2, D3, implementation > > {
816 static const constexpr bool value =
true;
819 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
820 struct is_operator< operators::left_assign< D1, D2, D3, implementation > > {
821 static const constexpr bool value =
true;
824 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
825 struct is_operator< operators::right_assign< D1, D2, D3, implementation > > {
826 static const constexpr bool value =
true;
830 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
831 struct is_operator< operators::add< D1, D2, D3, implementation > > {
832 static const constexpr bool value =
true;
836 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
837 struct is_operator< operators::mul< D1, D2, D3, implementation > > {
838 static const constexpr bool value =
true;
841 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
842 struct is_operator< operators::max< D1, D2, D3, implementation > > {
843 static const constexpr bool value =
true;
846 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
847 struct is_operator< operators::min< D1, D2, D3, implementation > > {
848 static const constexpr bool value =
true;
851 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
852 struct is_operator< operators::subtract< D1, D2, D3, implementation > > {
853 static const constexpr bool value =
true;
856 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
857 struct is_operator< operators::divide< D1, D2, D3, implementation > > {
858 static const constexpr bool value =
true;
861 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
862 struct is_operator< operators::divide_reverse< D1, D2, D3, implementation > > {
863 static const constexpr bool value =
true;
866 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
867 struct is_operator< operators::equal< D1, D2, D3, implementation > > {
868 static const constexpr bool value =
true;
871 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
872 struct is_operator< operators::not_equal< D1, D2, D3, implementation > > {
873 static const constexpr bool value =
true;
876 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
877 struct is_operator< operators::any_or< D1, D2, D3, implementation > > {
878 static const constexpr bool value =
true;
881 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
882 struct is_operator< operators::logical_or< D1, D2, D3, implementation > > {
883 static const constexpr bool value =
true;
886 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
887 struct is_operator< operators::logical_and< D1, D2, D3, implementation > > {
888 static const constexpr bool value =
true;
891 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
892 struct is_operator< operators::abs_diff< D1, D2, D3, implementation > > {
893 static const constexpr bool value =
true;
896 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
897 struct is_operator< operators::relu< D1, D2, D3, implementation > > {
898 static const constexpr bool value =
true;
901 template<
typename IType,
typename VType >
902 struct is_operator< operators::argmin< IType, VType > > {
903 static const constexpr bool value =
true;
906 template<
typename IType,
typename VType >
907 struct is_operator< operators::argmax< IType, VType > > {
908 static const constexpr bool value =
true;
911 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
912 struct is_operator< operators::square_diff< D1, D2, D3, implementation > > {
913 static const constexpr bool value =
true;
916 template<
typename IN1,
typename IN2, enum Backend implementation >
917 struct is_operator< operators::
zip< IN1, IN2, implementation > > {
918 static const constexpr bool value =
true;
921 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
922 struct is_operator< operators::equal_first< D1, D2, D3, implementation > > {
923 static const constexpr bool value =
true;
926 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
927 struct is_operator< operators::less_than< D1, D2, D3, implementation > > {
928 static const constexpr bool value =
true;
931 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
932 struct is_operator< operators::leq< D1, D2, D3, implementation > > {
933 static const constexpr bool value =
true;
936 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
937 struct is_operator< operators::greater_than< D1, D2, D3, implementation > > {
938 static const constexpr bool value =
true;
941 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
942 struct is_operator< operators::geq< D1, D2, D3, implementation > > {
943 static const constexpr bool value =
true;
946 template<
typename D1,
typename D2,
typename D3 >
947 struct is_idempotent< operators::min< D1, D2, D3 >, void > {
948 static const constexpr bool value =
true;
951 template<
typename D1,
typename D2,
typename D3 >
952 struct is_idempotent< operators::max< D1, D2, D3 >, void > {
953 static const constexpr bool value =
true;
956 template<
typename D1,
typename D2,
typename D3 >
957 struct is_idempotent< operators::any_or< D1, D2, D3 >, void > {
958 static const constexpr bool value =
true;
961 template<
typename D1,
typename D2,
typename D3 >
962 struct is_idempotent< operators::logical_or< D1, D2, D3 >, void > {
963 static const constexpr bool value =
true;
966 template<
typename D1,
typename D2,
typename D3 >
967 struct is_idempotent< operators::logical_and< D1, D2, D3 >, void > {
968 static const constexpr bool value =
true;
971 template<
typename D1,
typename D2,
typename D3 >
972 struct is_idempotent< operators::relu< D1, D2, D3 >, void > {
973 static const constexpr bool value =
true;
976 template<
typename D1,
typename D2,
typename D3 >
977 struct is_idempotent< operators::left_assign_if< D1, D2, D3 >, void > {
978 static const constexpr bool value =
true;
981 template<
typename D1,
typename D2,
typename D3 >
982 struct is_idempotent< operators::right_assign_if< D1, D2, D3 >, void > {
983 static const constexpr bool value =
true;
986 template<
typename IType,
typename VType >
987 struct is_idempotent< operators::argmin< IType, VType >, void > {
988 static const constexpr bool value =
true;
991 template<
typename IType,
typename VType >
992 struct is_idempotent< operators::argmax< IType, VType >, void > {
993 static const constexpr bool value =
true;
996 template<
typename OP >
997 struct is_associative<
999 typename std::enable_if< is_operator< OP >::value, void >::type
1001 static constexpr const bool value = OP::is_associative();
1004 template<
typename OP >
1005 struct is_commutative<
1007 typename std::enable_if< is_operator< OP >::value, void >::type
1009 static constexpr const bool value = OP::is_commutative();
1014 namespace internal {
1016 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1017 struct maybe_noop< operators::left_assign_if< D1, D2, D3, implementation > > {
1018 static const constexpr bool value =
true;
1021 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1022 struct maybe_noop< operators::right_assign_if< D1, D2, D3, implementation > > {
1023 static const constexpr bool value =
true;
1036 #define _DEBUG_NO_IOSTREAM_PAIR_CONVERTER
1040 #ifndef _DEBUG_NO_IOSTREAM_PAIR_CONVERTER
1042 template<
typename U,
typename V >
1043 std::ostream & operator<<( std::ostream &out,
const std::pair< U, V > &pair ) {
1044 out <<
"( " << pair.first <<
", " << pair.second <<
" )";
This operator returns the absolute difference between two numbers.
Definition: ops.hpp:543
This operator takes the sum of the two input parameters and writes it to the output variable.
Definition: ops.hpp:177
This operator is a generalisation of the logical or.
Definition: ops.hpp:436
The argmax operator on key-value pairs.
Definition: ops.hpp:600
The argmin operator on key-value pairs.
Definition: ops.hpp:573
Reversed division of two numbers.
Definition: ops.hpp:355
Numerical division of two numbers.
Definition: ops.hpp:330
Compares std::pair inputs taking the first entry in every pair as the comparison key,...
Definition: ops.hpp:680
Operator which returns true if its inputs compare equal, and false otherwise.
Definition: ops.hpp:381
This operation returns whether the left operand compares greater-than or equal to the right operand.
Definition: ops.hpp:796
This operation returns whether the left operand compares greater-than the right operand.
Definition: ops.hpp:767
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:61
This operation returns whether the left operand compares less-than or equal to the right operand.
Definition: ops.hpp:738
This operation returns whether the left operand compares less-than the right operand.
Definition: ops.hpp:709
The logical and.
Definition: ops.hpp:492
The logical or.
Definition: ops.hpp:464
This operator takes the maximum of the two input parameters and writes the result to the output varia...
Definition: ops.hpp:243
This operator takes the minimum of the two input parameters and writes the result to the output varia...
Definition: ops.hpp:276
This operator multiplies the two input parameters and writes the result to the output variable.
Definition: ops.hpp:210
Operator that returns false whenever its inputs compare equal, and true otherwise.
Definition: ops.hpp:407
This operation is equivalent to grb::operators::min.
Definition: ops.hpp:516
This operator assigns the right-hand input if the left-hand input evaluates true.
Definition: ops.hpp:143
This operator discards all left-hand side input and simply copies the right-hand side input to the ou...
Definition: ops.hpp:117
This operation returns the squared difference between two numbers.
Definition: ops.hpp:625
Numerical substraction of two numbers.
Definition: ops.hpp:303
The zip operator that operators on keys as a left-hand input and values as a right hand input,...
Definition: ops.hpp:651
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:452
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.