Skip to content

GxB sort with smaller (or larger) output objects #180

@eriknw

Description

@eriknw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions