Skip to content

"ZEROB" Binary Operator #179

@eriknw

Description

@eriknw

I think it would be useful to have a "pair"-like binary operator that returns 0 instead of 1. The C spec uses "ONEB" instead of "PAIR", so perhaps "ZEROB" is an okay name.

This is known to be missing in this table:

GraphBLAS/Include/GraphBLAS.h

Lines 1442 to 1468 in 502e16a

// is complete. Below is a list of all operators and their equivalents.
// x: 0 0 1 1
// y: 0 1 0 1
// z: see below
//
// z = 0 0 0 0 0 (zero function, not predefined)
// z = (x && y) 0 0 0 1 AND, MIN, TIMES
// z = (x > y) 0 0 1 0 GT, ISGT, and set diff (x\y)
// z = x 0 0 1 1 FIRST, DIV
//
// z = (x < y) 0 1 0 0 LT, ISLT, and set diff (y\x)
// z = y 0 1 0 1 SECOND, RDIV
// z = (x != y) 0 1 1 0 XOR, MINUS, RMINUS, NE, ISNE
// z = (x || y) 0 1 1 1 OR, MAX, PLUS
//
// z = ~(x || y) 1 0 0 0 (nor(x,y) function, not predefined)
// z = (x == y) 1 0 0 1 LXNOR, EQ, ISEQ
// z = ~y 1 0 1 0 (not(y), not predefined)
// z = (x >= y) 1 0 1 1 GE, ISGE, POW, and "x implies y"
//
// z = ~x 1 1 0 0 (not(x), not predefined)
// z = (x <= y) 1 1 0 1 LE, ISLE, and "y implies x"
// z = ~(x && y) 1 1 1 0 (nand(x,y) function, not predefined)
// z = 1 1 1 1 1 PAIR, ONEB
//
// z = any(x,y) 0 . . 1 ANY (pick x or y arbitrarily)

"Why?", you ask? I want to use GxB_Vector_sort and GxB_Matrix_sort to "compactify" the values to the left or top. When using GxB_PAIR_BOOL, the values are reversed. The values would not be reversed with GxB_ZEROB_BOOL. Is this abusing the sort functions? Maybe :-P

I don't see any reason for building predefined semirings with ZEROB instead of PAIR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions