1 //------------------------------------------------------------------------------
2 // GB_positional_offset: return the offset of a positional operator
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 #include "GB.h"
11 
GB_positional_offset(GB_Opcode opcode)12 int64_t GB_positional_offset        // return 0 or 1
13 (
14     GB_Opcode opcode                // opcode of positional operator
15 )
16 {
17 
18     switch (opcode)
19     {
20 
21         // these operators are offset by one
22         case GB_POSITIONI1_opcode : // z = position_i1(A(i,j)) == i+1
23         case GB_FIRSTI1_opcode    : // z = first_i1(A(i,j),y) == i+1
24         case GB_SECONDI1_opcode   : // z = second_i1(x,A(i,j)) == i+1
25         case GB_POSITIONJ1_opcode : // z = position_j1(A(i,j)) == j+1
26         case GB_FIRSTJ1_opcode    : // z = first_j1(A(i,j),y) == j+1
27         case GB_SECONDJ1_opcode   : // z = second_j1(x,A(i,j)) == j+1
28             return (1) ;
29 
30         // all other operators have no offset
31         default:
32             return (0) ;
33     }
34 }
35 
36