Open rayegun opened 1 year ago
This may be related to (or part of) the rank promotion issue: https://github.com/GraphBLAS/graphblas-api-c/issues/24
We have found this functionality to be useful for many algorithms--we use it all the time. We added syntax in python-graphblas
that performs recipes for ewise-multiply, ewise-add, and ewise-union (Tim's GxB extension with left and right defaults) between Matrix and Vector objects. We apply masks as appropriate for the latter two operations.
So, +1 from me.
Yes, one can use GrB_Matrix_diag
to first expand the vector to matrix. One then needs to do mxm with a semiring where only the binaryop is used. If we added methods to do this instead, it could take a BinaryOp (and/or Monoid--or even IndexUnaryOp if you're twisted) instead of a Semiring.
How do you implement the add and union rank promotion? The emul is clear to me.
How do you implement the add and union rank promotion? The emul is clear to me.
See the important bits here: https://github.com/python-graphblas/python-graphblas/blob/856356bd02e28936059e5b8af22c6cb327495d98/graphblas/core/matrix.py#L50-L65
Forgive me if this is already an open issue.
It would be very nice to add broadcasting of vectors into matrices to the spec. See Python/Julia and more languages for prior art. For instance if you
ewise_mul(A::GrB_Matrix, v::GrB_Vector)
v
would expand across columns. Transpose operator could be used to expand across rows.Note that this treats
GrB_Vector
explicitly as a column vector, which may not be in line with the spec.This can already be achieved with a Diagonal matrix multiplication, but this has a few issues: