Why do the output vectors and matrices need to be the same size as the inputs?
If one wants e.g. the k smallest elements, it makes sense to me to pass a vector of size k to GxB_Vector_sort. Similarly, the number of columns (by default) or rows (if transposed descriptor is set) can also be used to limit the number of results.
This operation is commonly known as e.g. nsmallest and nlargest. With PAIR/ONEB and ZEROB, one can also get firstn and lastn.
Small aside: what I really want is to randomly sample k elements per row or column, but there is not yet a "random" binary operator or monoid.
Btw, we implemented compactify (very similar to your sort) in python-graphblas years ago that supports first, last, smallest, largest, and random, because we needed it for multiple workloads.
Why do the output vectors and matrices need to be the same size as the inputs?
If one wants e.g. the k smallest elements, it makes sense to me to pass a vector of size k to
GxB_Vector_sort. Similarly, the number of columns (by default) or rows (if transposed descriptor is set) can also be used to limit the number of results.This operation is commonly known as e.g. nsmallest and nlargest. With
PAIR/ONEBandZEROB, one can also get firstn and lastn.Small aside: what I really want is to randomly sample
kelements per row or column, but there is not yet a "random" binary operator or monoid.Btw, we implemented
compactify(very similar to your sort) inpython-graphblasyears ago that supports first, last, smallest, largest, and random, because we needed it for multiple workloads.