Open mcmillan03 opened 3 years ago
Most of the variants of extract and apply are handled by some combination of:
1) submatrix_view
, and then copying or assigning the submatrix
2) mask_view
3) grb::assign
We should take a deeper look as we go through algorithms over the next few weeks and see if we need to expand these features or add new ones to handle all of the C API's extract/assign.
The GraphBLAS C API v. 2.0 has the following variants and signatures (pseudocode)
Standard Variants
apply(Vec w, Vec mask, BinaryOp accum, UnaryOp op, Vec U, ...)
apply(Mat C, Mat Mask, BinaryOp accum, UnaryOp op, Mat A, ...)
BinaryOp bind 1st/2nd Variants
apply(Vec w, Vec mask, BinaryOp accum, BinaryOp op, Scalar s, Vec U, ...)
apply(Vec w, Vec mask, BinaryOp accum, BinaryOp op, Vec U, Scalar s, ...)
apply(Mat C, Mat Mask, BinaryOp accum, BinaryOp op, Scalar s, Mat A, ...)
apply(Mat C, Mat Mask, BinaryOp accum, BinaryOp op, Mat A, Scalar s, ...)
IndexUnaryOp Variants
apply(Vec w, Vec mask, BinaryOp accum, IndexUnaryOp op, Vec U, Scalar s, ...)
apply(Mat C, Mat Mask, BinaryOp accum, IndexUnaryOp op, Mat A, Scalar s, ...)
The C++ API way of defining the standard vector signature is as follows (matrix follows the same pattern):
The one might define the BinaryOp+bind as follows but bind-1st and bind-second have the same templated signature and need to be dealt with with a static assert in the body as follows:
However this signature is not recommended for the C++ API was we should be using std::bind at the call site and call the standard variant as follows (for bind-2nd):
Without the BinaryOp-bind variants then there is no collision with what the IndexUnaryOp variant would be, but one may still want to asser that u is a vector:
Is this approach the best? I see no way to do binding for index unary ops and call the standard variant because. While I could find a way to bind the val parameter, the element location indices need to be provided at the call site inside the implementation of apply.