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 >
864 typename IN1,
typename IN2,
typename OUT,
bool conj_left,
865 enum Backend implementation = config::default_backend
868 internal::conjugate_mul< IN1, IN2, OUT, conj_left, implementation >
873 template<
typename A,
typename B,
typename C,
bool D, enum Backend E >
915 typename IN1,
typename IN2 = IN1,
typename OUT = IN2,
916 enum Backend implementation = config::default_backend
919 internal::conjugate_mul< IN1, IN2, OUT, false, implementation >
924 template<
typename A,
typename B,
typename C, enum Backend D >
966 typename IN1,
typename IN2 = IN1,
typename OUT = IN2,
967 enum Backend implementation = config::default_backend
970 internal::conjugate_mul< IN1, IN2, OUT, true, implementation >
975 template<
typename A,
typename B,
typename C, enum Backend D >
984 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
985 struct is_operator< operators::left_assign_if< D1, D2, D3, implementation > > {
986 static const constexpr
bool value =
true;
989 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
990 struct is_operator< operators::right_assign_if< D1, D2, D3, implementation > > {
991 static const constexpr
bool value =
true;
994 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
995 struct is_operator< operators::left_assign< D1, D2, D3, implementation > > {
996 static const constexpr
bool value =
true;
999 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1000 struct is_operator< operators::right_assign< D1, D2, D3, implementation > > {
1001 static const constexpr
bool value =
true;
1005 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1006 struct is_operator< operators::add< D1, D2, D3, implementation > > {
1007 static const constexpr
bool value =
true;
1011 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1012 struct is_operator< operators::mul< D1, D2, D3, implementation > > {
1013 static const constexpr
bool value =
true;
1016 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1017 struct is_operator< operators::max< D1, D2, D3, implementation > > {
1018 static const constexpr
bool value =
true;
1021 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1022 struct is_operator< operators::min< D1, D2, D3, implementation > > {
1023 static const constexpr
bool value =
true;
1026 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1027 struct is_operator< operators::subtract< D1, D2, D3, implementation > > {
1028 static const constexpr
bool value =
true;
1031 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1032 struct is_operator< operators::divide< D1, D2, D3, implementation > > {
1033 static const constexpr
bool value =
true;
1036 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1037 struct is_operator< operators::divide_reverse< D1, D2, D3, implementation > > {
1038 static const constexpr
bool value =
true;
1041 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1042 struct is_operator< operators::equal< D1, D2, D3, implementation > > {
1043 static const constexpr
bool value =
true;
1046 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1047 struct is_operator< operators::not_equal< D1, D2, D3, implementation > > {
1048 static const constexpr
bool value =
true;
1051 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1052 struct is_operator< operators::any_or< D1, D2, D3, implementation > > {
1053 static const constexpr
bool value =
true;
1056 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1057 struct is_operator< operators::logical_or< D1, D2, D3, implementation > > {
1058 static const constexpr
bool value =
true;
1061 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1062 struct is_operator< operators::logical_and< D1, D2, D3, implementation > > {
1063 static const constexpr
bool value =
true;
1066 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1067 struct is_operator< operators::abs_diff< D1, D2, D3, implementation > > {
1068 static const constexpr
bool value =
true;
1071 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1072 struct is_operator< operators::relu< D1, D2, D3, implementation > > {
1073 static const constexpr
bool value =
true;
1076 template<
typename IType,
typename VType >
1077 struct is_operator< operators::argmin< IType, VType > > {
1078 static const constexpr
bool value =
true;
1081 template<
typename IType,
typename VType >
1082 struct is_operator< operators::argmax< IType, VType > > {
1083 static const constexpr
bool value =
true;
1086 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1087 struct is_operator< operators::square_diff< D1, D2, D3, implementation > > {
1088 static const constexpr
bool value =
true;
1091 template<
typename IN1,
typename IN2, enum Backend implementation >
1092 struct is_operator< operators::
zip< IN1, IN2, implementation > > {
1093 static const constexpr
bool value =
true;
1096 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1097 struct is_operator< operators::equal_first< D1, D2, D3, implementation > > {
1098 static const constexpr
bool value =
true;
1101 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1102 struct is_operator< operators::less_than< D1, D2, D3, implementation > > {
1103 static const constexpr
bool value =
true;
1106 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1107 struct is_operator< operators::leq< D1, D2, D3, implementation > > {
1108 static const constexpr
bool value =
true;
1111 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1112 struct is_operator< operators::greater_than< D1, D2, D3, implementation > > {
1113 static const constexpr
bool value =
true;
1116 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1117 struct is_operator< operators::geq< D1, D2, D3, implementation > > {
1118 static const constexpr
bool value =
true;
1122 typename D1,
typename D2,
typename D3,
1123 bool cl,
enum Backend implementation
1126 operators::conjugate_mul< D1, D2, D3, cl, implementation >
1128 static const constexpr
bool value =
true;
1131 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1133 operators::conjugate_left_mul< D1, D2, D3, implementation >
1135 static const constexpr
bool value =
true;
1138 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1140 operators::conjugate_right_mul< D1, D2, D3, implementation >
1142 static const constexpr
bool value =
true;
1145 template<
typename D1,
typename D2,
typename D3 >
1146 struct is_idempotent< operators::min< D1, D2, D3 >, void > {
1147 static const constexpr
bool value =
true;
1150 template<
typename D1,
typename D2,
typename D3 >
1151 struct is_idempotent< operators::max< D1, D2, D3 >, void > {
1152 static const constexpr
bool value =
true;
1155 template<
typename D1,
typename D2,
typename D3 >
1156 struct is_idempotent< operators::any_or< D1, D2, D3 >, void > {
1157 static const constexpr
bool value =
true;
1160 template<
typename D1,
typename D2,
typename D3 >
1161 struct is_idempotent< operators::logical_or< D1, D2, D3 >, void > {
1162 static const constexpr
bool value =
true;
1165 template<
typename D1,
typename D2,
typename D3 >
1166 struct is_idempotent< operators::logical_and< D1, D2, D3 >, void > {
1167 static const constexpr
bool value =
true;
1170 template<
typename D1,
typename D2,
typename D3 >
1171 struct is_idempotent< operators::relu< D1, D2, D3 >, void > {
1172 static const constexpr
bool value =
true;
1175 template<
typename D1,
typename D2,
typename D3 >
1176 struct is_idempotent< operators::left_assign_if< D1, D2, D3 >, void > {
1177 static const constexpr
bool value =
true;
1180 template<
typename D1,
typename D2,
typename D3 >
1181 struct is_idempotent< operators::right_assign_if< D1, D2, D3 >, void > {
1182 static const constexpr
bool value =
true;
1185 template<
typename IType,
typename VType >
1186 struct is_idempotent< operators::argmin< IType, VType >, void > {
1187 static const constexpr
bool value =
true;
1190 template<
typename IType,
typename VType >
1191 struct is_idempotent< operators::argmax< IType, VType >, void > {
1192 static const constexpr
bool value =
true;
1195 template<
typename OP >
1196 struct is_associative<
1198 typename std::enable_if< is_operator< OP >::value, void >::type
1200 static constexpr
const bool value = OP::is_associative();
1203 template<
typename OP >
1204 struct is_commutative<
1206 typename std::enable_if< is_operator< OP >::value, void >::type
1208 static constexpr
const bool value = OP::is_commutative();
1213 namespace internal {
1215 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1216 struct maybe_noop< operators::left_assign_if< D1, D2, D3, implementation > > {
1217 static const constexpr
bool value =
true;
1220 template<
typename D1,
typename D2,
typename D3, enum Backend implementation >
1221 struct maybe_noop< operators::right_assign_if< D1, D2, D3, implementation > > {
1222 static const constexpr
bool value =
true;
1235 #define _DEBUG_NO_IOSTREAM_PAIR_CONVERTER 1239 #ifndef _DEBUG_NO_IOSTREAM_PAIR_CONVERTER 1241 template<
typename U,
typename V >
1242 std::ostream & operator<<( std::ostream &out,
const std::pair< U, V > &pair ) {
1243 out <<
"( " << pair.first <<
", " << pair.second <<
" )";
1250 #endif // end ``_H_GRB_OPERATORS'' This operator is a generalisation of the logical or.
Definition: ops.hpp:434
This operation returns whether the left operand compares less-than the right operand.
Definition: ops.hpp:707
static const constexpr bool value
Whether T is commutative.
Definition: type_traits.hpp:246
Operator that returns false whenever its inputs compare equal, and true otherwise.
Definition: ops.hpp:405
The argmax operator on key-value pairs.
Definition: ops.hpp:600
Numerical substraction of two numbers.
Definition: ops.hpp:301
Conjugate-multiply operator that conjugates the left-hand operand before multiplication.
Definition: ops.hpp:969
Compares std::pair inputs taking the first entry in every pair as the comparison key,...
Definition: ops.hpp:678
Operator which returns true if its inputs compare equal, and false otherwise.
Definition: ops.hpp:379
Conjugate-multiply operator that conjugates the left- or right-hand operand before multiplication.
Definition: ops.hpp:867
This operation returns whether the left operand compares less-than or equal to the right operand.
Definition: ops.hpp:736
This operator multiplies the two input parameters and writes the result to the output variable.
Definition: ops.hpp:208
static const constexpr bool value
Wheter T is idempotent.
Definition: type_traits.hpp:167
This operation returns whether the left operand compares greater-than or equal to the right operand.
Definition: ops.hpp:794
The zip operator that operators on keys as a left-hand input and values as a right hand input,...
Definition: ops.hpp:649
This operator assigns the left-hand input if the right-hand input evaluates true.
Definition: ops.hpp:85
This operation returns whether the left operand compares greater-than the right operand.
Definition: ops.hpp:765
Conjugate-multiply operator that conjugates the right-hand operand before multiplication.
Definition: ops.hpp:918
This operation returns the squared difference between two numbers.
Definition: ops.hpp:623
This operator assigns the right-hand input if the left-hand input evaluates true.
Definition: ops.hpp:141
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 discards all left-hand side input and simply copies the right-hand side input to the ou...
Definition: ops.hpp:115
Backend
A collection of all backends.
Definition: backends.hpp:49
Reversed division of two numbers.
Definition: ops.hpp:353
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:183
Specifies the ALP algebraic type traits.
static const constexpr bool value
Whether T is an ALP operator.
Definition: type_traits.hpp:111
This operator takes the sum of the two input parameters and writes it to the output variable.
Definition: ops.hpp:175
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:477
Numerical division of two numbers.
Definition: ops.hpp:328
The logical and.
Definition: ops.hpp:490
The argmin operator on key-value pairs.
Definition: ops.hpp:573
The logical or.
Definition: ops.hpp:462
Used to inspect whether a given type is an ALP operator.
Definition: type_traits.hpp:104
This operator discards all right-hand side input and simply copies the left-hand side input to the ou...
Definition: ops.hpp:58
static const constexpr bool value
Whether T is associative.
Definition: type_traits.hpp:208
This operator returns the absolute difference between two numbers.
Definition: ops.hpp:541
This operation is equivalent to grb::operators::min.
Definition: ops.hpp:514