27#ifndef _H_GRB_BASE_BLAS1
28#define _H_GRB_BASE_BLAS1
37#include <graphblas/internalops.hpp>
154 #define NO_MASK Vector< bool >( 0 )
203 class OP,
enum Backend backend,
205 typename InputType1,
typename InputType2,
210 const InputType1 alpha,
211 const InputType2 beta,
214 const typename std::enable_if<
219 >::type *
const =
nullptr
222 std::cout <<
"In eWiseApply ([T1]<-T2<-T3), operator, base\n";
225 const bool should_not_call_eWiseApplyOpASS_base =
false;
226 assert( should_not_call_eWiseApplyOpASS_base );
286 class OP,
enum Backend backend,
287 typename OutputType,
typename MaskType,
288 typename InputType1,
typename InputType2,
294 const InputType1 alpha,
295 const InputType2 beta,
298 const typename std::enable_if<
304 >::type *
const =
nullptr
307 std::cout <<
"In masked eWiseApply ([T1]<-T2<-T3), operator, base\n";
310 const bool should_not_call_eWiseApplyOpAMSS_base =
false;
311 assert( should_not_call_eWiseApplyOpAMSS_base );
369 class Monoid,
enum Backend backend,
371 typename InputType1,
typename InputType2,
376 const InputType1 alpha,
377 const InputType2 beta,
380 const typename std::enable_if<
385 >::type *
const =
nullptr
388 std::cout <<
"In eWiseApply ([T1]<-T2<-T3), monoid, base\n";
391 const bool should_not_call_eWiseApplyMonASS_base =
false;
392 assert( should_not_call_eWiseApplyMonASS_base );
452 class Monoid,
enum Backend backend,
453 typename OutputType,
typename MaskType,
454 typename InputType1,
typename InputType2,
460 const InputType1 alpha,
461 const InputType2 beta,
464 const typename std::enable_if<
470 >::type *
const =
nullptr
473 std::cout <<
"In masked eWiseApply ([T1]<-T2<-T3), monoid, base\n";
476 const bool should_not_call_eWiseApplyMonAMSS_base =
false;
477 assert( should_not_call_eWiseApplyMonAMSS_base );
565 class OP,
enum Backend backend,
566 typename OutputType,
typename InputType1,
typename InputType2,
571 const InputType1 alpha,
575 const typename std::enable_if<
580 >::type *
const =
nullptr
583 std::cout <<
"In eWiseApply ([T1]<-T2<-[T3]), operator, base\n";
586 const bool should_not_call_eWiseApplyOpASA_base =
false;
587 assert( should_not_call_eWiseApplyOpASA_base );
674 class OP,
enum Backend backend,
675 typename OutputType,
typename MaskType,
676 typename InputType1,
typename InputType2,
682 const InputType1 alpha,
686 const typename std::enable_if<
692 >::type *
const =
nullptr
695 std::cout <<
"In masked eWiseApply ([T1]<-T2<-[T3], operator, base)\n";
698 const bool should_not_call_eWiseApplyOpAMSA_base =
false;
699 assert( should_not_call_eWiseApplyOpAMSA_base );
786 class Monoid,
enum Backend backend,
787 typename OutputType,
typename InputType1,
typename InputType2,
792 const InputType1 alpha,
800 >::type *
const =
nullptr
803 std::cout <<
"In unmasked eWiseApply ([T1]<-T2<-[T3], monoid, base)\n";
806 const bool should_not_call_eWiseApplyMonoidASA_base =
false;
807 assert( should_not_call_eWiseApplyMonoidASA_base );
897 class Monoid,
enum Backend backend,
898 typename OutputType,
typename MaskType,
899 typename InputType1,
typename InputType2,
905 const InputType1 alpha,
914 void >::type *
const =
nullptr
917 std::cout <<
"In masked eWiseApply ([T1]<-T2<-[T3], using monoid)\n";
920 const bool should_not_call_eWiseApplyMonoidAMSA_base =
false;
921 assert( should_not_call_eWiseApplyMonoidAMSA_base );
1010 class OP,
enum Backend backend,
1011 typename OutputType,
typename InputType1,
typename InputType2,
1017 const InputType2 beta,
1018 const OP &op = OP(),
1020 const typename std::enable_if<
1025 >::type *
const =
nullptr
1028 std::cout <<
"In eWiseApply ([T1]<-[T2]<-T3), operator, base\n";
1031 const bool should_not_call_eWiseApplyOpAAS_base =
false;
1032 assert( should_not_call_eWiseApplyOpAAS_base );
1121 class OP,
enum Backend backend,
1122 typename OutputType,
typename MaskType,
1123 typename InputType1,
typename InputType2,
1130 const InputType2 beta,
1131 const OP &op = OP(),
1138 >::type *
const =
nullptr
1141 std::cout <<
"In masked eWiseApply ([T1]<-[T2]<-T3, operator, base)\n";
1144 const bool should_not_call_eWiseApplyOpAMAS_base =
false;
1145 assert( should_not_call_eWiseApplyOpAMAS_base );
1232 class Monoid,
enum Backend backend,
1233 typename OutputType,
typename InputType1,
typename InputType2,
1239 const InputType2 beta,
1246 void >::type *
const =
nullptr
1249 std::cout <<
"In unmasked eWiseApply ([T1]<-[T2]<-T3, monoid, base)\n";
1252 const bool should_not_call_eWiseApplyMonoidAAS_base =
false;
1253 assert( should_not_call_eWiseApplyMonoidAAS_base );
1343 class Monoid,
enum Backend backend,
1344 typename OutputType,
typename MaskType,
1345 typename InputType1,
typename InputType2,
1352 const InputType2 beta,
1360 >::type *
const =
nullptr
1363 std::cout <<
"In masked eWiseApply ([T1]<-[T2]<-T3, monoid, base)\n";
1366 const bool should_not_call_eWiseApplyMonoidAMAS_base =
false;
1367 assert( should_not_call_eWiseApplyMonoidAMAS_base );
1456 class OP,
enum Backend backend,
1457 typename OutputType,
typename InputType1,
typename InputType2,
1464 const OP &op = OP(),
1470 >::type *
const =
nullptr
1473 std::cout <<
"In eWiseApply ([T1]<-[T2]<-[T3]), operator variant\n";
1476 const bool should_not_call_eWiseApplyOpAAA_base =
false;
1477 assert( should_not_call_eWiseApplyOpAAA_base );
1568 class OP,
enum Backend backend,
1569 typename OutputType,
typename MaskType,
1570 typename InputType1,
typename InputType2,
1578 const OP &op = OP(),
1580 const typename std::enable_if<
1586 >::type *
const =
nullptr
1589 std::cout <<
"In masked eWiseApply ([T1]<-[T2]<-[T3], operator, base)\n";
1592 const bool should_not_call_eWiseApplyOpAMAA_base =
false;
1593 assert( should_not_call_eWiseApplyOpAMAA_base );
1683 class Monoid,
enum Backend backend,
1684 typename OutputType,
typename InputType1,
typename InputType2,
1697 >::type *
const =
nullptr
1700 std::cout <<
"In unmasked eWiseApply ([T1]<-[T2]<-[T3], monoid, base)\n";
1703 const bool should_not_call_eWiseApplyOpAMAA_base =
false;
1704 assert( should_not_call_eWiseApplyOpAMAA_base );
1791 class Monoid,
enum Backend backend,
1792 typename OutputType,
typename MaskType,
1793 typename InputType1,
typename InputType2,
1803 const typename std::enable_if<
1809 >::type *
const =
nullptr
1812 std::cout <<
"In masked eWiseApply ([T1]<-[T2]<-[T3], monoid, base)\n";
1815 const bool should_not_call_eWiseApplyMonoidAMAA_base =
false;
1816 assert( should_not_call_eWiseApplyMonoidAMAA_base );
1908 class Ring,
enum Backend backend,
1909 typename OutputType,
typename InputType1,
typename InputType2,
1916 const Ring &ring = Ring(),
1922 >::type *
const =
nullptr
1925 std::cout <<
"in eWiseAdd ([T1] <- [T2] + [T3]), unmasked, base";
1928 const bool should_not_call_eWiseAddAAA_base =
false;
1929 assert( should_not_call_eWiseAddAAA_base );
2015 class Ring,
enum Backend backend,
2016 typename InputType1,
typename InputType2,
typename OutputType,
2021 const InputType1 alpha,
2023 const Ring &ring = Ring(),
2029 >::type *
const =
nullptr
2032 std::cout <<
"in eWiseAdd ([T1] <- T2 + [T3]), unmasked, base";
2035 const bool should_not_call_eWiseAddASA_base =
false;
2036 assert( should_not_call_eWiseAddASA_base );
2122 class Ring,
enum Backend backend,
2123 typename InputType1,
typename InputType2,
typename OutputType,
2129 const InputType2 beta,
2130 const Ring &ring = Ring(),
2136 >::type *
const =
nullptr
2139 std::cout <<
"in eWiseAdd ([T1] <- [T2] + T3), unmasked, base";
2142 const bool should_not_call_eWiseAddAAS_base =
false;
2143 assert( should_not_call_eWiseAddAAS_base );
2225 class Ring,
enum Backend backend,
2226 typename InputType1,
typename InputType2,
typename OutputType,
2231 const InputType1 alpha,
2232 const InputType2 beta,
2233 const Ring &ring = Ring(),
2239 >::type *
const =
nullptr
2242 std::cout <<
"in eWiseAdd ([T1] <- T2 + T3), unmasked, base";
2245 const bool should_not_call_eWiseAddASS_base =
false;
2246 assert( should_not_call_eWiseAddASS_base );
2343 class Ring,
enum Backend backend,
2344 typename OutputType,
typename MaskType,
2345 typename InputType1,
typename InputType2,
2353 const Ring &ring = Ring(),
2359 >::type *
const =
nullptr
2362 std::cout <<
"in eWiseAdd ([T1] <- [T2] + [T3]), masked, base";
2365 const bool should_not_call_eWiseAddAMAA_base =
false;
2366 assert( should_not_call_eWiseAddAMAA_base );
2460 class Ring,
enum Backend backend,
2461 typename InputType1,
typename InputType2,
2462 typename OutputType,
typename MaskType,
2468 const InputType1 alpha,
2470 const Ring &ring = Ring(),
2476 >::type *
const =
nullptr
2479 std::cout <<
"in eWiseAdd ([T1] <- T2 + [T3]), masked, base";
2482 const bool should_not_call_eWiseAddAMSA_base =
false;
2483 assert( should_not_call_eWiseAddAMSA_base );
2577 class Ring,
enum Backend backend,
2578 typename InputType1,
typename InputType2,
2579 typename OutputType,
typename MaskType,
2586 const InputType2 beta,
2587 const Ring &ring = Ring(),
2593 >::type *
const =
nullptr
2596 std::cout <<
"in eWiseAdd ([T1] <- [T2] + T3), masked, base";
2599 const bool should_not_call_eWiseAddAMAS_base =
false;
2600 assert( should_not_call_eWiseAddAMAS_base );
2690 class Ring,
enum Backend backend,
2691 typename InputType1,
typename InputType2,
2692 typename OutputType,
typename MaskType,
2698 const InputType1 alpha,
2699 const InputType2 beta,
2700 const Ring &ring = Ring(),
2706 >::type *
const =
nullptr
2709 std::cout <<
"in eWiseAdd ([T1] <- T2 + T3), masked, base";
2712 const bool should_not_call_eWiseAddAMSS_base =
false;
2713 assert( should_not_call_eWiseAddAMSS_base );
2790 class Ring,
enum Backend backend,
2791 typename InputType1,
typename InputType2,
typename OutputType,
2798 const Ring &ring = Ring(),
2804 >::type *
const =
nullptr
2807 std::cout <<
"in eWiseMul ([T1] <- [T2] * [T3]), unmasked, base";
2810 const bool should_not_call_eWiseMulAAA_base =
false;
2811 assert( should_not_call_eWiseMulAAA_base );
2887 class Ring,
enum Backend backend,
2888 typename InputType1,
typename InputType2,
typename OutputType,
2893 const InputType1 alpha,
2895 const Ring &ring = Ring(),
2901 >::type *
const =
nullptr
2904 std::cout <<
"in eWiseMul ([T1] <- T2 * [T3]), unmasked, base";
2907 const bool should_not_call_eWiseMulASA_base =
false;
2908 assert( should_not_call_eWiseMulASA_base );
2984 class Ring,
enum Backend backend,
2985 typename InputType1,
typename InputType2,
typename OutputType,
2991 const InputType2 beta,
2992 const Ring &ring = Ring(),
2998 >::type *
const =
nullptr
3001 std::cout <<
"in eWiseMul ([T1] <- [T2] * T3), unmasked, base";
3004 const bool should_not_call_eWiseMulAAS_base =
false;
3005 assert( should_not_call_eWiseMulAAS_base );
3077 class Ring,
enum Backend backend,
3078 typename InputType1,
typename InputType2,
typename OutputType,
3083 const InputType1 alpha,
3084 const InputType2 beta,
3085 const Ring &ring = Ring(),
3091 >::type *
const =
nullptr
3094 std::cout <<
"in eWiseMul ([T1] <- T2 * T3), unmasked, base";
3097 const bool should_not_call_eWiseMulASS_base =
false;
3098 assert( should_not_call_eWiseMulASS_base );
3179 class Ring,
enum Backend backend,
3180 typename InputType1,
typename InputType2,
3181 typename OutputType,
typename MaskType,
3189 const Ring &ring = Ring(),
3195 >::type *
const =
nullptr
3198 std::cout <<
"in eWiseMul ([T1] <- [T2] * [T3]), masked, base";
3201 const bool should_not_call_eWiseMulAMAA_base =
false;
3202 assert( should_not_call_eWiseMulAMAA_base );
3284 class Ring,
enum Backend backend,
3285 typename InputType1,
typename InputType2,
3286 typename OutputType,
typename MaskType,
3292 const InputType1 alpha,
3294 const Ring &ring = Ring(),
3300 >::type *
const =
nullptr
3303 std::cout <<
"in eWiseMul ([T1] <- T2 * [T3]), masked, base";
3306 const bool should_not_call_eWiseMulAMSA_base =
false;
3307 assert( should_not_call_eWiseMulAMSA_base );
3389 class Ring,
enum Backend backend,
3390 typename InputType1,
typename InputType2,
3391 typename OutputType,
typename MaskType,
3398 const InputType2 beta,
3399 const Ring &ring = Ring(),
3405 >::type *
const =
nullptr
3408 std::cout <<
"in eWiseMul ([T1] <- [T2] * T3), masked, base";
3411 const bool should_not_call_eWiseMulAMAS_base =
false;
3412 assert( should_not_call_eWiseMulAMAS_base );
3491 class Ring,
enum Backend backend,
3492 typename InputType1,
typename InputType2,
3493 typename OutputType,
typename MaskType,
3499 const InputType1 alpha,
3500 const InputType2 beta,
3501 const Ring &ring = Ring(),
3507 >::type *
const =
nullptr
3510 std::cout <<
"in eWiseMul ([T1] <- T2 * T3), masked, base";
3513 const bool should_not_call_eWiseMulAMSS_base =
false;
3514 assert( should_not_call_eWiseMulAMSS_base );
3751 const bool should_not_call_base_vector_ewiselambda =
false;
3752 assert( should_not_call_base_vector_ewiselambda );
3837 typename InputType,
typename IOType,
typename MaskType,
3838 Backend backend,
typename Coords
3849 >::type *
const =
nullptr
3852 const bool should_not_call_base_scalar_foldl =
false;
3853 assert( should_not_call_base_scalar_foldl );
3870 typename IOType,
typename InputType,
3878 const typename std::enable_if<
3881 void >::type *
const =
nullptr
3884 const bool should_not_call_base_scalar_foldl_nomask =
false;
3885 assert( should_not_call_base_scalar_foldl_nomask );
3906 typename IOType,
typename InputType,
typename MaskType,
3907 Backend backend,
typename Coords
3913 const OP &op = OP(),
3914 const typename std::enable_if<
3918 void >::type *
const =
nullptr
3921 const bool should_not_call_base_scalar_foldl_op =
false;
3922 assert( should_not_call_base_scalar_foldl_op );
3940 typename InputType,
typename IOType,
typename MaskType,
3941 Backend backend,
typename Coords
3952 >::type *
const =
nullptr
3955 const bool should_not_call_base_scalar_foldr =
false;
3956 assert( should_not_call_base_scalar_foldr );
3974 typename IOType,
typename InputType,
3975 Backend backend,
typename Coords
3981 const typename std::enable_if<
3984 void >::type *
const =
nullptr
3987 const bool should_not_call_base_scalar_foldr_nomask =
false;
3988 assert( should_not_call_base_scalar_foldr_nomask );
4052 class AddMonoid,
class AnyOp,
4053 typename OutputType,
typename InputType1,
typename InputType2,
4054 enum Backend backend,
typename Coords
4060 const AddMonoid &addMonoid = AddMonoid(),
4061 const AnyOp &anyOp = AnyOp(),
4068 void >::type *
const =
nullptr
4071 std::cout <<
"Should not call base grb::dot (monoid-operator version)\n";
4074 const bool should_not_call_base_dot_monOp =
false;
4075 assert( should_not_call_base_dot_monOp );
4131 typename IOType,
typename InputType1,
typename InputType2,
4132 Backend backend,
typename Coords
4138 const Ring &ring = Ring(),
4140 const typename std::enable_if<
4145 void >::type *
const =
nullptr
4148 std::cout <<
"Should not call base grb::dot (semiring version)\n";
4151 const bool should_not_call_base_dot_semiring =
false;
4152 assert( should_not_call_base_dot_semiring );
This file contains a register of all backends that are either implemented, under implementation,...
A generalised monoid.
Definition: monoid.hpp:54
A GraphBLAS vector.
Definition: vector.hpp:64
Defines all ALP/GraphBLAS descriptors.
RC foldr(const Vector< InputType, backend, Coords > &x, const Vector< MaskType, backend, Coords > &mask, IOType &y, const Monoid &monoid=Monoid(), const typename std::enable_if< !grb::is_object< IOType >::value &&!grb::is_object< InputType >::value &&!grb::is_object< MaskType >::value &&grb::is_monoid< Monoid >::value, void >::type *const =nullptr)
Folds a vector into a scalar, right-to-left.
Definition: blas1.hpp:3943
RC eWiseMul(Vector< OutputType, backend, Coords > &z, const Vector< InputType1, backend, Coords > &x, const Vector< InputType2, backend, Coords > &y, const Ring &ring=Ring(), const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< OutputType >::value &&!grb::is_object< InputType1 >::value &&!grb::is_object< InputType2 >::value &&grb::is_semiring< Ring >::value, void >::type *const =nullptr)
In-place element-wise multiplication of two vectors, , under a given semiring.
Definition: blas1.hpp:2794
RC eWiseAdd(Vector< OutputType, backend, Coords > &z, const Vector< InputType1, backend, Coords > &x, const Vector< InputType2, backend, Coords > &y, const Ring &ring=Ring(), const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< OutputType >::value &&!grb::is_object< InputType1 >::value &&!grb::is_object< InputType2 >::value &&grb::is_semiring< Ring >::value, void >::type *const =nullptr)
Calculates the element-wise addition of two vectors, , under a given semiring.
Definition: blas1.hpp:1912
RC eWiseLambda(const Func f, const Vector< DataType, backend, Coords > &x, Args...)
Executes an arbitrary element-wise user-defined function f on any number of vectors of equal length.
Definition: blas1.hpp:3746
RC eWiseApply(Vector< OutputType, backend, Coords > &z, const InputType1 alpha, const InputType2 beta, const OP &op=OP(), const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< OutputType >::value &&!grb::is_object< InputType1 >::value &&!grb::is_object< InputType2 >::value &&grb::is_operator< OP >::value, void >::type *const =nullptr)
Computes , out of place, operator version.
Definition: blas1.hpp:208
RC foldl(IOType &x, const Vector< InputType, backend, Coords > &y, const Vector< MaskType, backend, Coords > &mask, const Monoid &monoid=Monoid(), const typename std::enable_if< !grb::is_object< IOType >::value &&!grb::is_object< InputType >::value &&!grb::is_object< MaskType >::value &&grb::is_monoid< Monoid >::value, void >::type *const =nullptr)
Reduces, or folds, a vector into a scalar.
Definition: blas1.hpp:3840
RC dot(OutputType &z, const Vector< InputType1, backend, Coords > &x, const Vector< InputType2, backend, Coords > &y, const AddMonoid &addMonoid=AddMonoid(), const AnyOp &anyOp=AnyOp(), const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< OutputType >::value &&!grb::is_object< InputType1 >::value &&!grb::is_object< InputType2 >::value &&grb::is_monoid< AddMonoid >::value &&grb::is_operator< AnyOp >::value, void >::type *const =nullptr)
Calculates the dot product, , under a given additive monoid and multiplicative operator.
Definition: blas1.hpp:4056
Backend
A collection of all backends.
Definition: backends.hpp:46
static constexpr Descriptor no_operation
Indicates no additional pre- or post-processing on any of the GraphBLAS function arguments.
Definition: descriptors.hpp:63
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
@ UNSUPPORTED
Indicates that the execution of the requested primitive with the given arguments is not supported by ...
Definition: rc.hpp:129
unsigned int Descriptor
Descriptors indicate pre- or post-processing for some or all of the arguments to an ALP/GraphBLAS cal...
Definition: descriptors.hpp:54
Phase
Primitives with sparse ALP/GraphBLAS output containers may run into the issue where an appropriate gr...
Definition: phase.hpp:152
@ EXECUTE
Speculatively assumes that the output container of the requested operation has enough capacity to com...
Definition: phase.hpp:257
Provides a set of standard binary operators.
Defines the various phases an ALP/GraphBLAS primitive may be executed with.
Defines the ALP error codes.
Provides an ALP semiring.
Used to inspect whether a given type is an ALP monoid.
Definition: type_traits.hpp:85
Used to inspect whether a given type is an ALP/GraphBLAS object.
Definition: type_traits.hpp:130
Used to inspect whether a given type is an ALP operator.
Definition: type_traits.hpp:104
Used to inspect whether a given type is an ALP semiring.
Definition: type_traits.hpp:66