1 //------------------------------------------------------------------------------
2 // GraphBLAS.h: definitions for the GraphBLAS package
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 // SuiteSparse:GraphBLAS is a complete implementation of the GraphBLAS
11 // standard, which defines a set of sparse matrix operations on an extended
12 // algebra of semirings, using an almost unlimited variety of operators and
13 // types.  When applied to sparse adjacency matrices, these algebraic
14 // operations are equivalent to computations on graphs.  GraphBLAS provides a
15 // powerful and expressive framework creating graph algorithms based on the
16 // elegant mathematics of sparse matrix operations on a semiring.
17 
18 // This GraphBLAS.h file contains GraphBLAS definitions for user applications
19 // to #include.  A few functions and variables with the prefix GB_ need to be
20 // defined in this file and are thus technically visible to the user, but they
21 // must not be accessed in user code.  They are here only so that the ANSI C11
22 // _Generic feature can be used in the user-accessible polymorphic functions.
23 // For example GrB_free is a macro that uses _Generic to select the right
24 // method, depending on the type of its argument.
25 
26 // This implementation conforms to the GraphBLAS API Specification and also
27 // includes functions and features that are extensions to the spec, which are
28 // given names of the form GxB_* for functions, built-in objects, and macros,
29 // so it is clear which are in the spec and which are extensions.  Extensions
30 // with the name GxB_* are user-accessible in SuiteSparse:GraphBLAS but cannot
31 // be guaranteed to appear in all GraphBLAS implementations.
32 
33 // Regarding "historical" functions and symbols:  when a GxB_* function or
34 // symbol is added to the C API Specification, the new GrB_* name should be
35 // used instead.  The old GxB_* name will be kept for historical reasons,
36 // documented here and in working order; it might no longer be mentioned in the
37 // user guide.  Historical functions and symbols would only be removed in the
38 // rare case that they cause a serious conflict with future methods.
39 
40 #ifndef GRAPHBLAS_H
41 #define GRAPHBLAS_H
42 
43 //==============================================================================
44 // include files required by GraphBLAS
45 //==============================================================================
46 
47 #include <stdio.h>
48 #include <errno.h>
49 #include <string.h>
50 #include <stdlib.h>
51 #include <stdbool.h>
52 #include <stdint.h>
53 #include <inttypes.h>
54 #include <stddef.h>
55 #include <limits.h>
56 #include <math.h>
57 #include <stdarg.h>
58 
59 //==============================================================================
60 // renaming for use in MATLAB
61 //==============================================================================
62 
63 #define GB_CAT2(x,y) x ## y
64 #define GB_EVAL2(x,y) GB_CAT2 (x,y)
65 
66 #ifdef GBRENAME
67     // All symbols must be renamed for the MATLAB interface when using MATLAB
68     // R2021a and following, since those versions of MATLAB include an earlier
69     // version of SuiteSparse:GraphBLAS.
70     #define GB(x)   GB_EVAL2 (GM_, x)
71     #define GRB(x)  GB_EVAL2 (GrM_, x)
72     #define GXB(x)  GB_EVAL2 (GxM_, x)
73     #define GrB GrM
74     #define GxB GxM
75     #include "GB_rename.h"
76 #else
77     // Use the standard GraphBLAS prefix.
78     #define GB(x)   GB_EVAL2 (GB_, x)
79     #define GRB(x)  GB_EVAL2 (GrB_, x)
80     #define GXB(x)  GB_EVAL2 (GxB_, x)
81 #endif
82 
83 //==============================================================================
84 // compiler variations
85 //==============================================================================
86 
87 // Exporting/importing symbols for Microsoft Visual Studio
88 
89 #if ( _MSC_VER && !__INTEL_COMPILER )
90 #ifdef GB_LIBRARY
91 // compiling SuiteSparse:GraphBLAS itself, exporting symbols to user apps
92 #define GB_PUBLIC extern __declspec ( dllexport )
93 #else
94 // compiling the user application, importing symbols from SuiteSparse:GraphBLAS
95 #define GB_PUBLIC extern __declspec ( dllimport )
96 #endif
97 #else
98 // for other compilers
99 #define GB_PUBLIC extern
100 #endif
101 
102 // GraphBLAS requires an ANSI C11 compiler for its polymorphic functions (using
103 // the _Generic keyword), but it can be used in an C90 compiler if those
104 // functions are disabled.
105 
106 // With ANSI C11 and later, _Generic keyword and polymorphic functions can be
107 // used.  Earlier versions of the language do not have this feature.
108 
109 #ifdef __STDC_VERSION__
110 // ANSI C11: 201112L
111 // ANSI C99: 199901L
112 // ANSI C95: 199409L
113 #define GxB_STDC_VERSION __STDC_VERSION__
114 #else
115 // assume ANSI C90 / C89
116 #define GxB_STDC_VERSION 199001L
117 #endif
118 
119 //------------------------------------------------------------------------------
120 // definitions for complex types
121 //------------------------------------------------------------------------------
122 
123 // See:
124 // https://www.drdobbs.com/complex-arithmetic-in-the-intersection-o/184401628#
125 
126 #if defined ( __cplusplus )
127 
128     extern "C++" {
129         // C++ complex types
130         #include <cmath>
131         #include <complex>
132         #undef I
133         typedef std::complex<float>  GxB_FC32_t ;
134         typedef std::complex<double> GxB_FC64_t ;
135     }
136 
137     #define GxB_CMPLXF(r,i) GxB_FC32_t(r,i)
138     #define GxB_CMPLX(r,i)  GxB_FC64_t(r,i)
139 
140 #elif ( _MSC_VER && !__INTEL_COMPILER )
141 
142     // Microsoft Windows complex types
143     #include <complex.h>
144     #undef I
145     typedef _Fcomplex GxB_FC32_t ;
146     typedef _Dcomplex GxB_FC64_t ;
147 
148     #define GxB_CMPLXF(r,i) (_FCbuild (r,i))
149     #define GxB_CMPLX(r,i)  ( _Cbuild (r,i))
150 
151 #else
152 
153     // ANSI C11 complex types
154     #include <complex.h>
155     #undef I
156     typedef float  complex GxB_FC32_t ;
157     typedef double complex GxB_FC64_t ;
158 
159     #ifndef CMPLX
160         // gcc 6.2 on the the Mac doesn't #define CMPLX
161         #define GxB_CMPLX(r,i) \
162         ((GxB_FC64_t)((double)(r)) + (GxB_FC64_t)((double)(i) * _Complex_I))
163     #else
164         // use the ANSI C11 CMPLX macro
165         #define GxB_CMPLX(r,i) CMPLX (r,i)
166     #endif
167 
168     #ifndef CMPLXF
169         // gcc 6.2 on the the Mac doesn't #define CMPLXF
170         #define GxB_CMPLXF(r,i) \
171         ((GxB_FC32_t)((float)(r)) + (GxB_FC32_t)((float)(i) * _Complex_I))
172     #else
173         // use the ANSI C11 CMPLX macro
174         #define GxB_CMPLXF(r,i) CMPLXF (r,i)
175     #endif
176 
177 #endif
178 
179 //==============================================================================
180 // version control
181 //==============================================================================
182 
183 // There are two version numbers that user codes can check against with
184 // compile-time #if tests:  the version of this GraphBLAS implementation,
185 // and the version of the GraphBLAS specification it conforms to.  User code
186 // can use tests like this:
187 //
188 //      #if GxB_SPEC_VERSION >= GxB_VERSION (2,0,3)
189 //      ... use features in GraphBLAS specification 2.0.3 ...
190 //      #else
191 //      ... only use features in early specifications
192 //      #endif
193 //
194 //      #if GxB_IMPLEMENTATION > GxB_VERSION (1,4,0)
195 //      ... use features from version 1.4.0 of a GraphBLAS package
196 //      #endif
197 
198 // X_GRAPHBLAS: names this particular implementation:
199 #define GxB_SUITESPARSE_GRAPHBLAS
200 
201 // GxB_VERSION: a single integer for comparing spec and version levels
202 #define GxB_VERSION(major,minor,sub) \
203     (((major)*1000ULL + (minor))*1000ULL + (sub))
204 
205 // The version of this implementation, and the GraphBLAS API version:
206 #define GxB_IMPLEMENTATION_NAME "SuiteSparse:GraphBLAS"
207 #define GxB_IMPLEMENTATION_DATE "May 17, 2021"
208 #define GxB_IMPLEMENTATION_MAJOR 5
209 #define GxB_IMPLEMENTATION_MINOR 0
210 #define GxB_IMPLEMENTATION_SUB   5
211 #define GxB_SPEC_DATE "Sept 25, 2019"
212 #define GxB_SPEC_MAJOR 1
213 #define GxB_SPEC_MINOR 3
214 #define GxB_SPEC_SUB   0
215 
216 #define GxB_IMPLEMENTATION \
217         GxB_VERSION (GxB_IMPLEMENTATION_MAJOR, \
218                      GxB_IMPLEMENTATION_MINOR, \
219                      GxB_IMPLEMENTATION_SUB)
220 
221 // The 'about' string the describes this particular implementation of GraphBLAS:
222 #define GxB_IMPLEMENTATION_ABOUT \
223 "SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved." \
224 "\nhttp://suitesparse.com  Dept of Computer Sci. & Eng, Texas A&M University.\n"
225 
226 // The GraphBLAS license for this particular implementation of GraphBLAS:
227 #define GxB_IMPLEMENTATION_LICENSE \
228 "SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved." \
229 "\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may\n"\
230 "not use SuiteSparse:GraphBLAS except in compliance with the License.  You\n"  \
231 "may obtain a copy of the License at\n\n"                                      \
232 "    http://www.apache.org/licenses/LICENSE-2.0\n\n"                           \
233 "Unless required by applicable law or agreed to in writing, software\n"        \
234 "distributed under the License is distributed on an \"AS IS\" BASIS,\n"        \
235 "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"   \
236 "See the License for the specific language governing permissions and\n"        \
237 "limitations under the License.\n"
238 
239 //------------------------------------------------------------------------------
240 // GraphBLAS C API version
241 //------------------------------------------------------------------------------
242 
243 #define GxB_SPEC_VERSION GxB_VERSION(GxB_SPEC_MAJOR,GxB_SPEC_MINOR,GxB_SPEC_SUB)
244 
245 // The 'spec' string describes the GraphBLAS spec:
246 #define GxB_SPEC_ABOUT \
247 "GraphBLAS C API, by Aydin Buluc, Timothy Mattson, Scott McMillan,\n"         \
248 "Jose' Moreira, Carl Yang, and Benjamin Brock.  Based on 'GraphBLAS\n"        \
249 "Mathematics by Jeremy Kepner.  See also 'Graph Algorithms in the Language\n" \
250 "of Linear Algebra,' edited by J. Kepner and J. Gilbert, SIAM, 2011.\n"
251 
252 //==============================================================================
253 // GrB_Index: the GraphBLAS integer
254 //==============================================================================
255 
256 // GrB_Index: row or column index, or matrix dimension.  This typedef is used
257 // for row and column indices, or matrix and vector dimensions.
258 
259 typedef uint64_t GrB_Index ;
260 
261 // The largest valid dimension permitted in this implementation is 2^60.
262 #define GxB_INDEX_MAX ((GrB_Index) (1ULL << 60))
263 
264 //==============================================================================
265 // GraphBLAS error and informational codes
266 //==============================================================================
267 
268 // All GraphBLAS functions return a code that indicates if it was successful
269 // or not.  If more information is required, the GrB_error function can be
270 // called, which returns a string that provides more information on the last
271 // return value from GraphBLAS.
272 
273 typedef enum
274 {
275 
276     GrB_SUCCESS = 0,            // all is well
277 
278     //--------------------------------------------------------------------------
279     // informational codes, not an error:
280     //--------------------------------------------------------------------------
281 
282     GrB_NO_VALUE = 1,           // A(i,j) requested but not there
283 
284     //--------------------------------------------------------------------------
285     // API errors:
286     //--------------------------------------------------------------------------
287 
288     GrB_UNINITIALIZED_OBJECT = 2,   // object has not been initialized
289     GrB_INVALID_OBJECT = 3,         // object is corrupted
290     GrB_NULL_POINTER = 4,           // input pointer is NULL
291     GrB_INVALID_VALUE = 5,          // generic error code; some value is bad
292     GrB_INVALID_INDEX = 6,          // a row or column index is out of bounds
293     GrB_DOMAIN_MISMATCH = 7,        // object domains are not compatible
294     GrB_DIMENSION_MISMATCH = 8,     // matrix dimensions do not match
295     GrB_OUTPUT_NOT_EMPTY = 9,       // output matrix already has values in it
296 
297     //--------------------------------------------------------------------------
298     // execution errors:
299     //--------------------------------------------------------------------------
300 
301     GrB_OUT_OF_MEMORY = 10,         // out of memory
302     GrB_INSUFFICIENT_SPACE = 11,    // output array not large enough
303     GrB_INDEX_OUT_OF_BOUNDS = 12,   // a row or column index is out of bounds
304     GrB_PANIC = 13                  // unknown error, or GrB_init not called.
305 }
306 GrB_Info ;
307 
308 //==============================================================================
309 // GrB_init / GrB_finalize
310 //==============================================================================
311 
312 // GrB_init must called before any other GraphBLAS operation.  GrB_finalize
313 // must be called as the last GraphBLAS operation.
314 
315 // GrB_init defines the mode that GraphBLAS will use:  blocking or
316 // non-blocking.  With blocking mode, all operations finish before returning to
317 // the user application.  With non-blocking mode, operations can be left
318 // pending, and are computed only when needed.
319 
320 // The extension GxB_init does the work of GrB_init, but it also defines the
321 // memory management functions that SuiteSparse:GraphBLAS will use internally.
322 
323 typedef enum
324 {
325     GrB_NONBLOCKING = 0,    // methods may return with pending computations
326     GrB_BLOCKING = 1        // no computations are ever left pending
327 }
328 GrB_Mode ;
329 
330 GB_PUBLIC
331 GrB_Info GrB_init           // start up GraphBLAS
332 (
333     GrB_Mode mode           // blocking or non-blocking mode
334 ) ;
335 
336 GB_PUBLIC
337 GrB_Info GxB_init           // start up GraphBLAS and also define malloc, etc
338 (
339     GrB_Mode mode,          // blocking or non-blocking mode
340     // pointers to memory management functions
341     void * (* user_malloc_function  ) (size_t),
342     void * (* user_calloc_function  ) (size_t, size_t),
343     void * (* user_realloc_function ) (void *, size_t),
344     void   (* user_free_function    ) (void *),
345     bool user_malloc_is_thread_safe     // ADDED in V3.0: thread_safe arg
346 ) ;
347 
348 // GxB_cuda_init (DRAFT: in progress; do not rely on this function)
349 GB_PUBLIC
350 GrB_Info GxB_cuda_init      // start up GraphBLAS for use with CUDA
351 (
352     GrB_Mode mode           // blocking or non-blocking mode
353 ) ;
354 
355 GB_PUBLIC
356 GrB_Info GrB_finalize (void) ;     // finish GraphBLAS
357 
358 //==============================================================================
359 // GrB_getVersion: GraphBLAS C API version
360 //==============================================================================
361 
362 // compile-time access to the C API Version number of this library.
363 #define GRB_VERSION     GxB_SPEC_MAJOR
364 #define GRB_SUBVERSION  GxB_SPEC_MINOR
365 
366 // GrB_getVersion provides a runtime access of the C API Version.
367 GB_PUBLIC
368 GrB_Info GrB_getVersion         // runtime access to C API version number
369 (
370     unsigned int *version,      // returns GRB_VERSION
371     unsigned int *subversion    // returns GRB_SUBVERSION
372 ) ;
373 
374 //==============================================================================
375 // GrB_Descriptor: the GraphBLAS descriptor
376 //==============================================================================
377 
378 // The GrB_Descriptor is used to modify the behavior of GraphBLAS operations.
379 //
380 // GrB_OUTP: can be GxB_DEFAULT or GrB_REPLACE.  If GrB_REPLACE, then C is
381 //       cleared after taking part in the accum operation but before the mask.
382 //       In other words, C<Mask> = accum (C,T) is split into Z = accum(C,T) ;
383 //       C=0 ; C<Mask> = Z.
384 //
385 // GrB_MASK: can be GxB_DEFAULT, GrB_COMP, GrB_STRUCTURE, or set to both
386 //      GrB_COMP and GrB_STRUCTURE.  If GxB_DEFAULT, the mask is used
387 //      normally, where Mask(i,j)=1 means C(i,j) can be modified by C<Mask>=Z,
388 //      and Mask(i,j)=0 means it cannot be modified even if Z(i,j) is has been
389 //      computed and differs from C(i,j).  If GrB_COMP, this is the same as
390 //      taking the logical complement of the Mask.  If GrB_STRUCTURE is set,
391 //      the value of the mask is not considered, just its pattern.  The
392 //      GrB_COMP and GrB_STRUCTURE settings can be combined.
393 //
394 // GrB_INP0: can be GxB_DEFAULT or GrB_TRAN.  If GxB_DEFAULT, the first input
395 //      is used as-is.  If GrB_TRAN, it is transposed.  Only matrices are
396 //      transposed this way.  Vectors are never transposed via the
397 //      GrB_Descriptor.
398 //
399 // GrB_INP1: the same as GrB_INP0 but for the second input
400 //
401 // GxB_NTHREADS: the maximum number of threads to use in the current method.
402 //      If <= GxB_DEFAULT (which is zero), then the number of threads is
403 //      determined automatically.  This is the default value.
404 //
405 // GxB_CHUNK: an integer parameter that determines the number of threads to use
406 //      for a small problem.  If w is the work to be performed, and chunk is
407 //      the value of this parameter, then the # of threads is limited to floor
408 //      (w/chunk).  The default chunk is currently 64K, but this may change in
409 //      the future.  If chunk is set to <= GxB_DEFAULT (that is, zero), the
410 //      default is used.
411 //
412 // GxB_AxB_METHOD: this is a hint to SuiteSparse:GraphBLAS on which algorithm
413 //      it should use to compute C=A*B, in GrB_mxm, GrB_mxv, and GrB_vxm.
414 //      SuiteSparse:GraphBLAS has four different heuristics, and the default
415 //      method (GxB_DEFAULT) selects between them automatically.  The complete
416 //      rule is in the User Guide.  The brief discussion here assumes all
417 //      matrices are stored by column.  All methods compute the same result,
418 //      except that floating-point roundoff may differ when working on
419 //      floating-point data types.
420 //
421 //      GxB_AxB_SAXPY:  C(:,j)=A*B(:,j) is computed using a mix of Gustavson
422 //          and Hash methods.  Each task in the parallel computation makes its
423 //          own decision between these two methods, via a heuristic.
424 //
425 //      GxB_AxB_GUSTAVSON:  This is the same as GxB_AxB_SAXPY, except that
426 //          every task uses Gustavon's method, computing C(:,j)=A*B(:,j) via a
427 //          gather/scatter workspace of size equal to the number of rows of A.
428 //          Very good general-purpose method, but sometimes the workspace can
429 //          be too large when many threads are used.
430 //
431 //      GxB_AxB_HASH: This is the same as GxB_AxB_SAXPY, except that every
432 //          task uses the Hash method.  It is very good for hypersparse
433 //          matrices and uses very little workspace, and so it scales well to
434 //          many threads.
435 //
436 //      GxB_AxB_DOT: computes C(i,j) = A(:,i)'*B(:,j), for each entry C(i,j).
437 //          A very specialized method that works well only if the mask is
438 //          present, very sparse, and not complemented, or when C is a dense
439 //          vector or matrix, or when C is small.
440 //
441 // GxB_SORT: GrB_mxm and other methods may return a matrix in a 'jumbled'
442 //      state, with indices out of order.  The sort is left pending.  Some
443 //      methods can tolerate jumbled matrices on input, so this can be faster.
444 //      However, in some cases, it can be faster for GrB_mxm to sort its output
445 //      as it is computed.  With GxB_SORT set to GxB_DEFAULT, the sort is left
446 //      pending.  With GxB_SORT set to a nonzero value, GrB_mxm typically sorts
447 //      the resulting matrix C (but not always; this is just a hint).  If
448 //      GrB_init is called with GrB_BLOCKING mode, the sort will always be
449 //      done, and this setting has no effect.
450 
451 // The following are enumerated values in both the GrB_Desc_Field and the
452 // GxB_Option_Field for global options.  They are defined with the same integer
453 // value for both enums, so the user can use them for both.
454 #define GxB_NTHREADS 5
455 #define GxB_CHUNK 7
456 
457 // GPU control (DRAFT: in progress, do not use)
458 #define GxB_GPU_CONTROL 21
459 #define GxB_GPU_CHUNK   22
460 
461 typedef enum
462 {
463     GrB_OUTP = 0,   // descriptor for output of a method
464     GrB_MASK = 1,   // descriptor for the mask input of a method
465     GrB_INP0 = 2,   // descriptor for the first input of a method
466     GrB_INP1 = 3,   // descriptor for the second input of a method
467 
468     GxB_DESCRIPTOR_NTHREADS = GxB_NTHREADS,     // max number of threads to use.
469                     // If <= GxB_DEFAULT, then GraphBLAS selects the number
470                     // of threads automatically.
471 
472     GxB_DESCRIPTOR_CHUNK = GxB_CHUNK,   // chunk size for small problems.
473                     // If <= GxB_DEFAULT, then the default is used.
474 
475     // GPU control (DRAFT: in progress, do not use)
476     GxB_DESCRIPTOR_GPU_CONTROL = GxB_GPU_CONTROL,
477     GxB_DESCRIPTOR_GPU_CHUNK   = GxB_GPU_CHUNK,
478 
479     GxB_AxB_METHOD = 1000,  // descriptor for selecting C=A*B algorithm
480     GxB_SORT = 35           // control sort in GrB_mxm
481 }
482 GrB_Desc_Field ;
483 
484 typedef enum
485 {
486     // for all GrB_Descriptor fields:
487     GxB_DEFAULT = 0,    // default behavior of the method
488 
489     // for GrB_OUTP only:
490     GrB_REPLACE = 1,    // clear the output before assigning new values to it
491 
492     // for GrB_MASK only:
493     GrB_COMP = 2,       // use the structural complement of the input
494     GrB_SCMP = 2,       // same as GrB_COMP (historical; use GrB_COMP instead)
495     GrB_STRUCTURE = 4,  // use the only pattern of the mask, not its values
496 
497     // for GrB_INP0 and GrB_INP1 only:
498     GrB_TRAN = 3,       // use the transpose of the input
499 
500     // for GxB_GPU_CONTROL only (DRAFT: in progress, do not use)
501     GxB_GPU_ALWAYS  = 2001,
502     GxB_GPU_NEVER   = 2002,
503 
504     // for GxB_AxB_METHOD only:
505     GxB_AxB_GUSTAVSON = 1001,   // gather-scatter saxpy method
506     GxB_AxB_DOT       = 1003,   // dot product
507     GxB_AxB_HASH      = 1004,   // hash-based saxpy method
508     GxB_AxB_SAXPY     = 1005    // saxpy method (any kind)
509 }
510 GrB_Desc_Value ;
511 
512 typedef struct GB_Descriptor_opaque *GrB_Descriptor ;
513 
514 GB_PUBLIC
515 GrB_Info GrB_Descriptor_new     // create a new descriptor
516 (
517     GrB_Descriptor *descriptor  // handle of descriptor to create
518 ) ;
519 
520 GB_PUBLIC
521 GrB_Info GrB_Descriptor_set     // set a parameter in a descriptor
522 (
523     GrB_Descriptor desc,        // descriptor to modify
524     GrB_Desc_Field field,       // parameter to change
525     GrB_Desc_Value val          // value to change it to
526 ) ;
527 
528 GB_PUBLIC
529 GrB_Info GxB_Descriptor_get     // get a parameter from a descriptor
530 (
531     GrB_Desc_Value *val,        // value of the parameter
532     GrB_Descriptor desc,        // descriptor to query; NULL means defaults
533     GrB_Desc_Field field        // parameter to query
534 ) ;
535 
536 GB_PUBLIC
537 GrB_Info GxB_Desc_set           // set a parameter in a descriptor
538 (
539     GrB_Descriptor desc,        // descriptor to modify
540     GrB_Desc_Field field,       // parameter to change
541     ...                         // value to change it to
542 ) ;
543 
544 GB_PUBLIC
545 GrB_Info GxB_Desc_get           // get a parameter from a descriptor
546 (
547     GrB_Descriptor desc,        // descriptor to query; NULL means defaults
548     GrB_Desc_Field field,       // parameter to query
549     ...                         // value of the parameter
550 ) ;
551 
552 GB_PUBLIC
553 GrB_Info GrB_Descriptor_free    // free a descriptor
554 (
555     GrB_Descriptor *descriptor  // handle of descriptor to free
556 ) ;
557 
558 // Predefined descriptors and their values:
559 
560 GB_PUBLIC
561 GrB_Descriptor     // OUTP         MASK           MASK       INP0      INP1
562                    //              structural     complement
563                    // ===========  ============== ========== ========  ========
564 
565 // GrB_NULL        // -            -              -          -         -
566 GrB_DESC_T1      , // -            -              -          -         GrB_TRAN
567 GrB_DESC_T0      , // -            -              -          GrB_TRAN  -
568 GrB_DESC_T0T1    , // -            -              -          GrB_TRAN  GrB_TRAN
569 
570 GrB_DESC_C       , // -            -              GrB_COMP   -         -
571 GrB_DESC_CT1     , // -            -              GrB_COMP   -         GrB_TRAN
572 GrB_DESC_CT0     , // -            -              GrB_COMP   GrB_TRAN  -
573 GrB_DESC_CT0T1   , // -            -              GrB_COMP   GrB_TRAN  GrB_TRAN
574 
575 GrB_DESC_S       , // -            GrB_STRUCTURE  -          -         -
576 GrB_DESC_ST1     , // -            GrB_STRUCTURE  -          -         GrB_TRAN
577 GrB_DESC_ST0     , // -            GrB_STRUCTURE  -          GrB_TRAN  -
578 GrB_DESC_ST0T1   , // -            GrB_STRUCTURE  -          GrB_TRAN  GrB_TRAN
579 
580 GrB_DESC_SC      , // -            GrB_STRUCTURE  GrB_COMP   -         -
581 GrB_DESC_SCT1    , // -            GrB_STRUCTURE  GrB_COMP   -         GrB_TRAN
582 GrB_DESC_SCT0    , // -            GrB_STRUCTURE  GrB_COMP   GrB_TRAN  -
583 GrB_DESC_SCT0T1  , // -            GrB_STRUCTURE  GrB_COMP   GrB_TRAN  GrB_TRAN
584 
585 GrB_DESC_R       , // GrB_REPLACE  -              -          -         -
586 GrB_DESC_RT1     , // GrB_REPLACE  -              -          -         GrB_TRAN
587 GrB_DESC_RT0     , // GrB_REPLACE  -              -          GrB_TRAN  -
588 GrB_DESC_RT0T1   , // GrB_REPLACE  -              -          GrB_TRAN  GrB_TRAN
589 
590 GrB_DESC_RC      , // GrB_REPLACE  -              GrB_COMP   -         -
591 GrB_DESC_RCT1    , // GrB_REPLACE  -              GrB_COMP   -         GrB_TRAN
592 GrB_DESC_RCT0    , // GrB_REPLACE  -              GrB_COMP   GrB_TRAN  -
593 GrB_DESC_RCT0T1  , // GrB_REPLACE  -              GrB_COMP   GrB_TRAN  GrB_TRAN
594 
595 GrB_DESC_RS      , // GrB_REPLACE  GrB_STRUCTURE  -          -         -
596 GrB_DESC_RST1    , // GrB_REPLACE  GrB_STRUCTURE  -          -         GrB_TRAN
597 GrB_DESC_RST0    , // GrB_REPLACE  GrB_STRUCTURE  -          GrB_TRAN  -
598 GrB_DESC_RST0T1  , // GrB_REPLACE  GrB_STRUCTURE  -          GrB_TRAN  GrB_TRAN
599 
600 GrB_DESC_RSC     , // GrB_REPLACE  GrB_STRUCTURE  GrB_COMP   -         -
601 GrB_DESC_RSCT1   , // GrB_REPLACE  GrB_STRUCTURE  GrB_COMP   -         GrB_TRAN
602 GrB_DESC_RSCT0   , // GrB_REPLACE  GrB_STRUCTURE  GrB_COMP   GrB_TRAN  -
603 GrB_DESC_RSCT0T1 ; // GrB_REPLACE  GrB_STRUCTURE  GrB_COMP   GrB_TRAN  GrB_TRAN
604 
605 // GrB_NULL is the default descriptor, with all settings at their defaults:
606 //
607 //      OUTP: do not replace the output
608 //      MASK: mask is valued and not complemented
609 //      INP0: first input not transposed
610 //      INP1: second input not transposed
611 
612 // Predefined descriptors may not be modified or freed.  Attempting to modify
613 // them results in an error (GrB_INVALID_VALUE).  Attempts to free them are
614 // silently ignored.
615 
616 //==============================================================================
617 // GrB_Type: data types
618 //==============================================================================
619 
620 typedef struct GB_Type_opaque *GrB_Type ;
621 
622 // GraphBLAS predefined types and their counterparts in pure C and in MATLAB
623 GB_PUBLIC GrB_Type
624     GrB_BOOL   ,        // in C: bool               in MATLAB: logical
625     GrB_INT8   ,        // in C: int8_t             in MATLAB: int8
626     GrB_INT16  ,        // in C: int16_t            in MATLAB: int16
627     GrB_INT32  ,        // in C: int32_t            in MATLAB: int32
628     GrB_INT64  ,        // in C: int64_t            in MATLAB: int64
629     GrB_UINT8  ,        // in C: uint8_t            in MATLAB: uint8
630     GrB_UINT16 ,        // in C: uint16_t           in MATLAB: uint16
631     GrB_UINT32 ,        // in C: uint32_t           in MATLAB: uint32
632     GrB_UINT64 ,        // in C: uint64_t           in MATLAB: uint64
633     GrB_FP32   ,        // in C: float              in MATLAB: single
634     GrB_FP64   ,        // in C: double             in MATLAB: double
635     GxB_FC32   ,        // in C: float complex      in MATLAB: single complex
636     GxB_FC64   ;        // in C: double complex     in MATLAB: double complex
637 
638 //------------------------------------------------------------------------------
639 // helper macros for polymorphic functions
640 //------------------------------------------------------------------------------
641 
642 #define GB_CAT(w,x,y,z) w ## x ## y ## z
643 #define GB_CONCAT(w,x,y,z) GB_CAT (w, x, y, z)
644 
645 #if GxB_STDC_VERSION >= 201112L
646 #define GB_CASES(p,prefix,func)                                         \
647         const bool       p : GB_CONCAT ( prefix, _, func, _BOOL   ),    \
648               bool       p : GB_CONCAT ( prefix, _, func, _BOOL   ),    \
649         const int8_t     p : GB_CONCAT ( prefix, _, func, _INT8   ),    \
650               int8_t     p : GB_CONCAT ( prefix, _, func, _INT8   ),    \
651         const int16_t    p : GB_CONCAT ( prefix, _, func, _INT16  ),    \
652               int16_t    p : GB_CONCAT ( prefix, _, func, _INT16  ),    \
653         const int32_t    p : GB_CONCAT ( prefix, _, func, _INT32  ),    \
654               int32_t    p : GB_CONCAT ( prefix, _, func, _INT32  ),    \
655         const int64_t    p : GB_CONCAT ( prefix, _, func, _INT64  ),    \
656               int64_t    p : GB_CONCAT ( prefix, _, func, _INT64  ),    \
657         const uint8_t    p : GB_CONCAT ( prefix, _, func, _UINT8  ),    \
658               uint8_t    p : GB_CONCAT ( prefix, _, func, _UINT8  ),    \
659         const uint16_t   p : GB_CONCAT ( prefix, _, func, _UINT16 ),    \
660               uint16_t   p : GB_CONCAT ( prefix, _, func, _UINT16 ),    \
661         const uint32_t   p : GB_CONCAT ( prefix, _, func, _UINT32 ),    \
662               uint32_t   p : GB_CONCAT ( prefix, _, func, _UINT32 ),    \
663         const uint64_t   p : GB_CONCAT ( prefix, _, func, _UINT64 ),    \
664               uint64_t   p : GB_CONCAT ( prefix, _, func, _UINT64 ),    \
665         const float      p : GB_CONCAT ( prefix, _, func, _FP32   ),    \
666               float      p : GB_CONCAT ( prefix, _, func, _FP32   ),    \
667         const double     p : GB_CONCAT ( prefix, _, func, _FP64   ),    \
668               double     p : GB_CONCAT ( prefix, _, func, _FP64   ),    \
669         const GxB_FC32_t p : GB_CONCAT ( GxB   , _, func, _FC32   ),    \
670               GxB_FC32_t p : GB_CONCAT ( GxB   , _, func, _FC32   ),    \
671         const GxB_FC64_t p : GB_CONCAT ( GxB   , _, func, _FC64   ),    \
672               GxB_FC64_t p : GB_CONCAT ( GxB   , _, func, _FC64   ),    \
673         const void       * : GB_CONCAT ( prefix, _, func, _UDT    ),    \
674               void       * : GB_CONCAT ( prefix, _, func, _UDT    )
675 #endif
676 
677 //------------------------------------------------------------------------------
678 // GrB_Type_new:  create a new type
679 //------------------------------------------------------------------------------
680 
681 // GrB_Type_new is implemented both as a macro and a function.  Both are
682 // user-callable.  The default is to use the macro, since this allows the name
683 // of the type to be saved as a string, for subsequent error reporting by
684 // GrB_error.
685 
686 #undef GrB_Type_new
687 #undef GrM_Type_new
688 
689 GB_PUBLIC
690 GrB_Info GRB (Type_new)         // create a new GraphBLAS type
691 (
692     GrB_Type *type,             // handle of user type to create
693     size_t sizeof_ctype         // size = sizeof (ctype) of the C type
694 ) ;
695 
696 // user code should not directly use GB_STR or GB_XSTR
697 // GB_STR: convert the content of x into a string "x"
698 #define GB_XSTR(x) GB_STR(x)
699 #define GB_STR(x) #x
700 
701 // GrB_Type_new as a user-callable macro, which allows the name of the ctype
702 // to be added to the new type.
703 #define GrB_Type_new(utype, sizeof_ctype) \
704     GB_Type_new (utype, sizeof_ctype, GB_STR(sizeof_ctype))
705 #define GrM_Type_new(utype, sizeof_ctype) \
706     GM_Type_new (utype, sizeof_ctype, GB_STR(sizeof_ctype))
707 
708 GB_PUBLIC
709 GrB_Info GB_Type_new            // not user-callable; use GrB_Type_new instead
710 (
711     GrB_Type *type,             // handle of user type to create
712     size_t sizeof_ctype,        // size of the user type
713     const char *name            // name of the type, as "sizeof (ctype)"
714 ) ;
715 
716 GB_PUBLIC
717 GrB_Info GxB_Type_size          // determine the size of the type
718 (
719     size_t *size,               // the sizeof the type
720     GrB_Type type               // type to determine the sizeof
721 ) ;
722 
723 GB_PUBLIC
724 GrB_Info GrB_Type_free          // free a user-defined type
725 (
726     GrB_Type *type              // handle of user-defined type to free
727 ) ;
728 
729 //==============================================================================
730 // GrB_UnaryOp: unary operators
731 //==============================================================================
732 
733 // GrB_UnaryOp: a function z=f(x).  The function f must have the signature:
734 
735 //      void f (void *z, const void *x) ;
736 
737 // The pointers are void * but they are always of pointers to objects of type
738 // ztype and xtype, respectively.  The function must typecast its arguments as
739 // needed from void* to ztype* and xtype*.
740 
741 typedef struct GB_UnaryOp_opaque *GrB_UnaryOp ;
742 
743 //------------------------------------------------------------------------------
744 // built-in unary operators, z = f(x)
745 //------------------------------------------------------------------------------
746 
747 GB_PUBLIC GrB_UnaryOp
748     // For these functions z=f(x), z and x have the same type.
749     // The suffix in the name is the type of x and z.
750     // z = x             z = -x             z = 1/x             z = ! (x != 0)
751     // identity          additive           multiplicative      logical
752     //                   inverse            inverse             negation
753     GrB_IDENTITY_BOOL,   GrB_AINV_BOOL,     GrB_MINV_BOOL,      GxB_LNOT_BOOL,
754     GrB_IDENTITY_INT8,   GrB_AINV_INT8,     GrB_MINV_INT8,      GxB_LNOT_INT8,
755     GrB_IDENTITY_INT16,  GrB_AINV_INT16,    GrB_MINV_INT16,     GxB_LNOT_INT16,
756     GrB_IDENTITY_INT32,  GrB_AINV_INT32,    GrB_MINV_INT32,     GxB_LNOT_INT32,
757     GrB_IDENTITY_INT64,  GrB_AINV_INT64,    GrB_MINV_INT64,     GxB_LNOT_INT64,
758     GrB_IDENTITY_UINT8,  GrB_AINV_UINT8,    GrB_MINV_UINT8,     GxB_LNOT_UINT8,
759     GrB_IDENTITY_UINT16, GrB_AINV_UINT16,   GrB_MINV_UINT16,    GxB_LNOT_UINT16,
760     GrB_IDENTITY_UINT32, GrB_AINV_UINT32,   GrB_MINV_UINT32,    GxB_LNOT_UINT32,
761     GrB_IDENTITY_UINT64, GrB_AINV_UINT64,   GrB_MINV_UINT64,    GxB_LNOT_UINT64,
762     GrB_IDENTITY_FP32,   GrB_AINV_FP32,     GrB_MINV_FP32,      GxB_LNOT_FP32,
763     GrB_IDENTITY_FP64,   GrB_AINV_FP64,     GrB_MINV_FP64,      GxB_LNOT_FP64,
764     // complex unary operators:
765     GxB_IDENTITY_FC32,   GxB_AINV_FC32,     GxB_MINV_FC32,      // no LNOT
766     GxB_IDENTITY_FC64,   GxB_AINV_FC64,     GxB_MINV_FC64,      // for complex
767 
768     // z = 1             z = abs(x)         z = bnot(x)         z = signum
769     // one               absolute value     bitwise negation
770     GxB_ONE_BOOL,        GrB_ABS_BOOL,
771     GxB_ONE_INT8,        GrB_ABS_INT8,      GrB_BNOT_INT8,
772     GxB_ONE_INT16,       GrB_ABS_INT16,     GrB_BNOT_INT16,
773     GxB_ONE_INT32,       GrB_ABS_INT32,     GrB_BNOT_INT32,
774     GxB_ONE_INT64,       GrB_ABS_INT64,     GrB_BNOT_INT64,
775     GxB_ONE_UINT8,       GrB_ABS_UINT8,     GrB_BNOT_UINT8,
776     GxB_ONE_UINT16,      GrB_ABS_UINT16,    GrB_BNOT_UINT16,
777     GxB_ONE_UINT32,      GrB_ABS_UINT32,    GrB_BNOT_UINT32,
778     GxB_ONE_UINT64,      GrB_ABS_UINT64,    GrB_BNOT_UINT64,
779     GxB_ONE_FP32,        GrB_ABS_FP32,
780     GxB_ONE_FP64,        GrB_ABS_FP64,
781     // complex unary operators:
782     GxB_ONE_FC32,        // for complex types, z = abs(x)
783     GxB_ONE_FC64,        // is real; listed below.
784 
785     // Boolean negation, z = !x, where both z and x are boolean.  There is no
786     // suffix since z and x are only boolean.  This operator is identical to
787     // GxB_LNOT_BOOL; it just has a different name.
788     GrB_LNOT ;
789 
790 // GxB_ABS is now in the v1.3 spec, the following names are historical:
791 GB_PUBLIC GrB_UnaryOp
792 
793     // z = abs(x)
794     GxB_ABS_BOOL,
795     GxB_ABS_INT8,
796     GxB_ABS_INT16,
797     GxB_ABS_INT32,
798     GxB_ABS_INT64,
799     GxB_ABS_UINT8,
800     GxB_ABS_UINT16,
801     GxB_ABS_UINT32,
802     GxB_ABS_UINT64,
803     GxB_ABS_FP32,
804     GxB_ABS_FP64 ;
805 
806 //------------------------------------------------------------------------------
807 // Unary operators for floating-point types only
808 //------------------------------------------------------------------------------
809 
810 // The following floating-point unary operators and their ANSI C11 equivalents,
811 // are only defined for floating-point (real and complex) types.
812 
813 GB_PUBLIC GrB_UnaryOp
814 
815     //--------------------------------------------------------------------------
816     // z = f(x) where z and x have the same type (all 4 floating-point types)
817     //--------------------------------------------------------------------------
818 
819     // z = sqrt (x)     z = log (x)         z = exp (x)         z = log2 (x)
820     GxB_SQRT_FP32,      GxB_LOG_FP32,       GxB_EXP_FP32,       GxB_LOG2_FP32,
821     GxB_SQRT_FP64,      GxB_LOG_FP64,       GxB_EXP_FP64,       GxB_LOG2_FP64,
822     GxB_SQRT_FC32,      GxB_LOG_FC32,       GxB_EXP_FC32,       GxB_LOG2_FC32,
823     GxB_SQRT_FC64,      GxB_LOG_FC64,       GxB_EXP_FC64,       GxB_LOG2_FC64,
824 
825     // z = sin (x)      z = cos (x)         z = tan (x)
826     GxB_SIN_FP32,       GxB_COS_FP32,       GxB_TAN_FP32,
827     GxB_SIN_FP64,       GxB_COS_FP64,       GxB_TAN_FP64,
828     GxB_SIN_FC32,       GxB_COS_FC32,       GxB_TAN_FC32,
829     GxB_SIN_FC64,       GxB_COS_FC64,       GxB_TAN_FC64,
830 
831     // z = acos (x)     z = asin (x)        z = atan (x)
832     GxB_ACOS_FP32,      GxB_ASIN_FP32,      GxB_ATAN_FP32,
833     GxB_ACOS_FP64,      GxB_ASIN_FP64,      GxB_ATAN_FP64,
834     GxB_ACOS_FC32,      GxB_ASIN_FC32,      GxB_ATAN_FC32,
835     GxB_ACOS_FC64,      GxB_ASIN_FC64,      GxB_ATAN_FC64,
836 
837     // z = sinh (x)     z = cosh (x)        z = tanh (x)
838     GxB_SINH_FP32,      GxB_COSH_FP32,      GxB_TANH_FP32,
839     GxB_SINH_FP64,      GxB_COSH_FP64,      GxB_TANH_FP64,
840     GxB_SINH_FC32,      GxB_COSH_FC32,      GxB_TANH_FC32,
841     GxB_SINH_FC64,      GxB_COSH_FC64,      GxB_TANH_FC64,
842 
843     // z = acosh (x)    z = asinh (x)       z = atanh (x)       z = signum (x)
844     GxB_ACOSH_FP32,     GxB_ASINH_FP32,     GxB_ATANH_FP32,     GxB_SIGNUM_FP32,
845     GxB_ACOSH_FP64,     GxB_ASINH_FP64,     GxB_ATANH_FP64,     GxB_SIGNUM_FP64,
846     GxB_ACOSH_FC32,     GxB_ASINH_FC32,     GxB_ATANH_FC32,     GxB_SIGNUM_FC32,
847     GxB_ACOSH_FC64,     GxB_ASINH_FC64,     GxB_ATANH_FC64,     GxB_SIGNUM_FC64,
848 
849     // z = ceil (x)     z = floor (x)       z = round (x)       z = trunc (x)
850     GxB_CEIL_FP32,      GxB_FLOOR_FP32,     GxB_ROUND_FP32,     GxB_TRUNC_FP32,
851     GxB_CEIL_FP64,      GxB_FLOOR_FP64,     GxB_ROUND_FP64,     GxB_TRUNC_FP64,
852     GxB_CEIL_FC32,      GxB_FLOOR_FC32,     GxB_ROUND_FC32,     GxB_TRUNC_FC32,
853     GxB_CEIL_FC64,      GxB_FLOOR_FC64,     GxB_ROUND_FC64,     GxB_TRUNC_FC64,
854 
855     // z = exp2 (x)     z = expm1 (x)       z = log10 (x)       z = log1p (x)
856     GxB_EXP2_FP32,      GxB_EXPM1_FP32,     GxB_LOG10_FP32,     GxB_LOG1P_FP32,
857     GxB_EXP2_FP64,      GxB_EXPM1_FP64,     GxB_LOG10_FP64,     GxB_LOG1P_FP64,
858     GxB_EXP2_FC32,      GxB_EXPM1_FC32,     GxB_LOG10_FC32,     GxB_LOG1P_FC32,
859     GxB_EXP2_FC64,      GxB_EXPM1_FC64,     GxB_LOG10_FC64,     GxB_LOG1P_FC64,
860 
861     //--------------------------------------------------------------------------
862     // z = f(x) where z and x are the same type (floating-point real only)
863     //--------------------------------------------------------------------------
864 
865     // z = lgamma (x)   z = tgamma (x)      z = erf (x)         z = erfc (x)
866     GxB_LGAMMA_FP32,    GxB_TGAMMA_FP32,    GxB_ERF_FP32,       GxB_ERFC_FP32,
867     GxB_LGAMMA_FP64,    GxB_TGAMMA_FP64,    GxB_ERF_FP64,       GxB_ERFC_FP64,
868 
869     // frexpx and frexpe return the mantissa and exponent, respectively,
870     // from the ANSI C11 frexp function.  The exponent is returned as a
871     // floating-point value, not an integer.
872 
873     // z = frexpx (x)   z = frexpe (x)
874     GxB_FREXPX_FP32,    GxB_FREXPE_FP32,
875     GxB_FREXPX_FP64,    GxB_FREXPE_FP64,
876 
877     //--------------------------------------------------------------------------
878     // z = f(x) where z and x are the same type (complex only)
879     //--------------------------------------------------------------------------
880 
881     // z = conj (x)
882     GxB_CONJ_FC32,
883     GxB_CONJ_FC64,
884 
885     //--------------------------------------------------------------------------
886     // z = f(x) where z is real and x is complex:
887     //--------------------------------------------------------------------------
888 
889     // z = creal (x)    z = cimag (x)       z = carg (x)       z = abs (x)
890     GxB_CREAL_FC32,     GxB_CIMAG_FC32,     GxB_CARG_FC32,     GxB_ABS_FC32,
891     GxB_CREAL_FC64,     GxB_CIMAG_FC64,     GxB_CARG_FC64,     GxB_ABS_FC64,
892 
893     //--------------------------------------------------------------------------
894     // z = f(x) where z is bool and x is any floating-point type
895     //--------------------------------------------------------------------------
896 
897     // z = isinf (x)
898     GxB_ISINF_FP32,
899     GxB_ISINF_FP64,
900     GxB_ISINF_FC32,     // isinf (creal (x)) || isinf (cimag (x))
901     GxB_ISINF_FC64,     // isinf (creal (x)) || isinf (cimag (x))
902 
903     // z = isnan (x)
904     GxB_ISNAN_FP32,
905     GxB_ISNAN_FP64,
906     GxB_ISNAN_FC32,     // isnan (creal (x)) || isnan (cimag (x))
907     GxB_ISNAN_FC64,     // isnan (creal (x)) || isnan (cimag (x))
908 
909     // z = isfinite (x)
910     GxB_ISFINITE_FP32,
911     GxB_ISFINITE_FP64,
912     GxB_ISFINITE_FC32,  // isfinite (real (x)) && isfinite (cimag (x))
913     GxB_ISFINITE_FC64 ; // isfinite (real (x)) && isfinite (cimag (x))
914 
915 //------------------------------------------------------------------------------
916 // methods for unary operators
917 //------------------------------------------------------------------------------
918 
919 typedef void (*GxB_unary_function)  (void *, const void *) ;
920 
921 #undef GrB_UnaryOp_new
922 #undef GrM_UnaryOp_new
923 
924 GB_PUBLIC
925 GrB_Info GRB (UnaryOp_new)           // create a new user-defined unary operator
926 (
927     GrB_UnaryOp *unaryop,           // handle for the new unary operator
928     GxB_unary_function function,    // pointer to the unary function
929     GrB_Type ztype,                 // type of output z
930     GrB_Type xtype                  // type of input x
931 ) ;
932 
933 #define GrB_UnaryOp_new(op,f,z,x) GB_UnaryOp_new (op,f,z,x, GB_STR(f))
934 #define GrM_UnaryOp_new(op,f,z,x) GM_UnaryOp_new (op,f,z,x, GB_STR(f))
935 
936 GB_PUBLIC
937 GrB_Info GB_UnaryOp_new             // not user-callable; use GrB_UnaryOp_new
938 (
939     GrB_UnaryOp *unaryop,           // handle for the new unary operator
940     GxB_unary_function function,    // pointer to the unary function
941     GrB_Type ztype,                 // type of output z
942     GrB_Type xtype,                 // type of input x
943     const char *name                // name of the underlying function
944 ) ;
945 
946 GB_PUBLIC
947 GrB_Info GxB_UnaryOp_ztype          // return the type of z
948 (
949     GrB_Type *ztype,                // return type of output z
950     GrB_UnaryOp unaryop             // unary operator
951 ) ;
952 
953 GB_PUBLIC
954 GrB_Info GxB_UnaryOp_xtype          // return the type of x
955 (
956     GrB_Type *xtype,                // return type of input x
957     GrB_UnaryOp unaryop             // unary operator
958 ) ;
959 
960 GB_PUBLIC
961 GrB_Info GrB_UnaryOp_free           // free a user-created unary operator
962 (
963     GrB_UnaryOp *unaryop            // handle of unary operator to free
964 ) ;
965 
966 //==============================================================================
967 // GrB_BinaryOp: binary operators
968 //==============================================================================
969 
970 // GrB_BinaryOp: a function z=f(x,y).  The function f must have the signature:
971 
972 //      void f (void *z, const void *x, const void *y) ;
973 
974 // The pointers are void * but they are always of pointers to objects of type
975 // ztype, xtype, and ytype, respectively.  See Demo/usercomplex.c for examples.
976 
977 typedef struct GB_BinaryOp_opaque *GrB_BinaryOp ;
978 
979 //------------------------------------------------------------------------------
980 // built-in binary operators, z = f(x,y), where x,y,z all have the same type
981 //------------------------------------------------------------------------------
982 
983 GB_PUBLIC GrB_BinaryOp
984 
985     // operators for all 13 types (including complex):
986 
987     // z = x            z = y               z = pow (x,y)
988     GrB_FIRST_BOOL,     GrB_SECOND_BOOL,    GxB_POW_BOOL,
989     GrB_FIRST_INT8,     GrB_SECOND_INT8,    GxB_POW_INT8,
990     GrB_FIRST_INT16,    GrB_SECOND_INT16,   GxB_POW_INT16,
991     GrB_FIRST_INT32,    GrB_SECOND_INT32,   GxB_POW_INT32,
992     GrB_FIRST_INT64,    GrB_SECOND_INT64,   GxB_POW_INT64,
993     GrB_FIRST_UINT8,    GrB_SECOND_UINT8,   GxB_POW_UINT8,
994     GrB_FIRST_UINT16,   GrB_SECOND_UINT16,  GxB_POW_UINT16,
995     GrB_FIRST_UINT32,   GrB_SECOND_UINT32,  GxB_POW_UINT32,
996     GrB_FIRST_UINT64,   GrB_SECOND_UINT64,  GxB_POW_UINT64,
997     GrB_FIRST_FP32,     GrB_SECOND_FP32,    GxB_POW_FP32,
998     GrB_FIRST_FP64,     GrB_SECOND_FP64,    GxB_POW_FP64,
999     // complex:
1000     GxB_FIRST_FC32,     GxB_SECOND_FC32,    GxB_POW_FC32,
1001     GxB_FIRST_FC64,     GxB_SECOND_FC64,    GxB_POW_FC64,
1002 
1003     // z = x+y          z = x-y             z = x*y             z = x/y
1004     GrB_PLUS_BOOL,      GrB_MINUS_BOOL,     GrB_TIMES_BOOL,     GrB_DIV_BOOL,
1005     GrB_PLUS_INT8,      GrB_MINUS_INT8,     GrB_TIMES_INT8,     GrB_DIV_INT8,
1006     GrB_PLUS_INT16,     GrB_MINUS_INT16,    GrB_TIMES_INT16,    GrB_DIV_INT16,
1007     GrB_PLUS_INT32,     GrB_MINUS_INT32,    GrB_TIMES_INT32,    GrB_DIV_INT32,
1008     GrB_PLUS_INT64,     GrB_MINUS_INT64,    GrB_TIMES_INT64,    GrB_DIV_INT64,
1009     GrB_PLUS_UINT8,     GrB_MINUS_UINT8,    GrB_TIMES_UINT8,    GrB_DIV_UINT8,
1010     GrB_PLUS_UINT16,    GrB_MINUS_UINT16,   GrB_TIMES_UINT16,   GrB_DIV_UINT16,
1011     GrB_PLUS_UINT32,    GrB_MINUS_UINT32,   GrB_TIMES_UINT32,   GrB_DIV_UINT32,
1012     GrB_PLUS_UINT64,    GrB_MINUS_UINT64,   GrB_TIMES_UINT64,   GrB_DIV_UINT64,
1013     GrB_PLUS_FP32,      GrB_MINUS_FP32,     GrB_TIMES_FP32,     GrB_DIV_FP32,
1014     GrB_PLUS_FP64,      GrB_MINUS_FP64,     GrB_TIMES_FP64,     GrB_DIV_FP64,
1015     // complex:
1016     GxB_PLUS_FC32,      GxB_MINUS_FC32,     GxB_TIMES_FC32,     GxB_DIV_FC32,
1017     GxB_PLUS_FC64,      GxB_MINUS_FC64,     GxB_TIMES_FC64,     GxB_DIV_FC64,
1018 
1019     // z = y-x          z = y/x             z = 1               z = any(x,y)
1020     GxB_RMINUS_BOOL,    GxB_RDIV_BOOL,      GxB_PAIR_BOOL,      GxB_ANY_BOOL,
1021     GxB_RMINUS_INT8,    GxB_RDIV_INT8,      GxB_PAIR_INT8,      GxB_ANY_INT8,
1022     GxB_RMINUS_INT16,   GxB_RDIV_INT16,     GxB_PAIR_INT16,     GxB_ANY_INT16,
1023     GxB_RMINUS_INT32,   GxB_RDIV_INT32,     GxB_PAIR_INT32,     GxB_ANY_INT32,
1024     GxB_RMINUS_INT64,   GxB_RDIV_INT64,     GxB_PAIR_INT64,     GxB_ANY_INT64,
1025     GxB_RMINUS_UINT8,   GxB_RDIV_UINT8,     GxB_PAIR_UINT8,     GxB_ANY_UINT8,
1026     GxB_RMINUS_UINT16,  GxB_RDIV_UINT16,    GxB_PAIR_UINT16,    GxB_ANY_UINT16,
1027     GxB_RMINUS_UINT32,  GxB_RDIV_UINT32,    GxB_PAIR_UINT32,    GxB_ANY_UINT32,
1028     GxB_RMINUS_UINT64,  GxB_RDIV_UINT64,    GxB_PAIR_UINT64,    GxB_ANY_UINT64,
1029     GxB_RMINUS_FP32,    GxB_RDIV_FP32,      GxB_PAIR_FP32,      GxB_ANY_FP32,
1030     GxB_RMINUS_FP64,    GxB_RDIV_FP64,      GxB_PAIR_FP64,      GxB_ANY_FP64,
1031     // complex:
1032     GxB_RMINUS_FC32,    GxB_RDIV_FC32,      GxB_PAIR_FC32,      GxB_ANY_FC32,
1033     GxB_RMINUS_FC64,    GxB_RDIV_FC64,      GxB_PAIR_FC64,      GxB_ANY_FC64,
1034 
1035     // The GxB_IS* comparison operators z=f(x,y) return the same type as their
1036     // inputs.  Each of them compute z = (x OP y), where x, y, and z all have
1037     // the same type.  The value z is either 1 for true or 0 for false, but it
1038     // is a value with the same type as x and y.
1039 
1040     // z = (x == y)     z = (x != y)
1041     GxB_ISEQ_BOOL,      GxB_ISNE_BOOL,
1042     GxB_ISEQ_INT8,      GxB_ISNE_INT8,
1043     GxB_ISEQ_INT16,     GxB_ISNE_INT16,
1044     GxB_ISEQ_INT32,     GxB_ISNE_INT32,
1045     GxB_ISEQ_INT64,     GxB_ISNE_INT64,
1046     GxB_ISEQ_UINT8,     GxB_ISNE_UINT8,
1047     GxB_ISEQ_UINT16,    GxB_ISNE_UINT16,
1048     GxB_ISEQ_UINT32,    GxB_ISNE_UINT32,
1049     GxB_ISEQ_UINT64,    GxB_ISNE_UINT64,
1050     GxB_ISEQ_FP32,      GxB_ISNE_FP32,
1051     GxB_ISEQ_FP64,      GxB_ISNE_FP64,
1052     // complex:
1053     GxB_ISEQ_FC32,      GxB_ISNE_FC32,
1054     GxB_ISEQ_FC64,      GxB_ISNE_FC64,
1055 
1056     // z = (x > y)      z = (x < y)         z = (x >= y)     z = (x <= y)
1057     GxB_ISGT_BOOL,      GxB_ISLT_BOOL,      GxB_ISGE_BOOL,      GxB_ISLE_BOOL,
1058     GxB_ISGT_INT8,      GxB_ISLT_INT8,      GxB_ISGE_INT8,      GxB_ISLE_INT8,
1059     GxB_ISGT_INT16,     GxB_ISLT_INT16,     GxB_ISGE_INT16,     GxB_ISLE_INT16,
1060     GxB_ISGT_INT32,     GxB_ISLT_INT32,     GxB_ISGE_INT32,     GxB_ISLE_INT32,
1061     GxB_ISGT_INT64,     GxB_ISLT_INT64,     GxB_ISGE_INT64,     GxB_ISLE_INT64,
1062     GxB_ISGT_UINT8,     GxB_ISLT_UINT8,     GxB_ISGE_UINT8,     GxB_ISLE_UINT8,
1063     GxB_ISGT_UINT16,    GxB_ISLT_UINT16,    GxB_ISGE_UINT16,    GxB_ISLE_UINT16,
1064     GxB_ISGT_UINT32,    GxB_ISLT_UINT32,    GxB_ISGE_UINT32,    GxB_ISLE_UINT32,
1065     GxB_ISGT_UINT64,    GxB_ISLT_UINT64,    GxB_ISGE_UINT64,    GxB_ISLE_UINT64,
1066     GxB_ISGT_FP32,      GxB_ISLT_FP32,      GxB_ISGE_FP32,      GxB_ISLE_FP32,
1067     GxB_ISGT_FP64,      GxB_ISLT_FP64,      GxB_ISGE_FP64,      GxB_ISLE_FP64,
1068 
1069     // z = min(x,y)     z = max (x,y)
1070     GrB_MIN_BOOL,       GrB_MAX_BOOL,
1071     GrB_MIN_INT8,       GrB_MAX_INT8,
1072     GrB_MIN_INT16,      GrB_MAX_INT16,
1073     GrB_MIN_INT32,      GrB_MAX_INT32,
1074     GrB_MIN_INT64,      GrB_MAX_INT64,
1075     GrB_MIN_UINT8,      GrB_MAX_UINT8,
1076     GrB_MIN_UINT16,     GrB_MAX_UINT16,
1077     GrB_MIN_UINT32,     GrB_MAX_UINT32,
1078     GrB_MIN_UINT64,     GrB_MAX_UINT64,
1079     GrB_MIN_FP32,       GrB_MAX_FP32,
1080     GrB_MIN_FP64,       GrB_MAX_FP64,
1081 
1082     // Binary operators for each of the 11 real types:
1083 
1084     // The operators convert non-boolean types internally to boolean and return
1085     // a value 1 or 0 in the same type, for true or false.  Each computes z =
1086     // ((x != 0) OP (y != 0)), where x, y, and z all the same type.  These
1087     // operators are useful as multiplicative operators when combined with
1088     // non-boolean monoids of the same type.
1089 
1090     // z = (x || y)     z = (x && y)        z = (x != y)
1091     GxB_LOR_BOOL,       GxB_LAND_BOOL,      GxB_LXOR_BOOL,
1092     GxB_LOR_INT8,       GxB_LAND_INT8,      GxB_LXOR_INT8,
1093     GxB_LOR_INT16,      GxB_LAND_INT16,     GxB_LXOR_INT16,
1094     GxB_LOR_INT32,      GxB_LAND_INT32,     GxB_LXOR_INT32,
1095     GxB_LOR_INT64,      GxB_LAND_INT64,     GxB_LXOR_INT64,
1096     GxB_LOR_UINT8,      GxB_LAND_UINT8,     GxB_LXOR_UINT8,
1097     GxB_LOR_UINT16,     GxB_LAND_UINT16,    GxB_LXOR_UINT16,
1098     GxB_LOR_UINT32,     GxB_LAND_UINT32,    GxB_LXOR_UINT32,
1099     GxB_LOR_UINT64,     GxB_LAND_UINT64,    GxB_LXOR_UINT64,
1100     GxB_LOR_FP32,       GxB_LAND_FP32,      GxB_LXOR_FP32,
1101     GxB_LOR_FP64,       GxB_LAND_FP64,      GxB_LXOR_FP64,
1102 
1103     // Binary operators that operate only on boolean types: LOR, LAND, LXOR,
1104     // and LXNOR.  The naming convention differs (_BOOL is not appended to the
1105     // name).  They are the same as GxB_LOR_BOOL, GxB_LAND_BOOL, and
1106     // GxB_LXOR_BOOL, and GrB_EQ_BOOL, respectively.
1107 
1108     // z = (x || y)     z = (x && y)        z = (x != y)        z = (x == y)
1109     GrB_LOR,            GrB_LAND,           GrB_LXOR,           GrB_LXNOR,
1110 
1111     // Operators for floating-point reals:
1112 
1113     // z = atan2(x,y)   z = hypot(x,y)      z = fmod(x,y)   z = remainder(x,y)
1114     GxB_ATAN2_FP32,     GxB_HYPOT_FP32,     GxB_FMOD_FP32,  GxB_REMAINDER_FP32,
1115     GxB_ATAN2_FP64,     GxB_HYPOT_FP64,     GxB_FMOD_FP64,  GxB_REMAINDER_FP64,
1116 
1117     // z = ldexp(x,y)   z = copysign (x,y)
1118     GxB_LDEXP_FP32,     GxB_COPYSIGN_FP32,
1119     GxB_LDEXP_FP64,     GxB_COPYSIGN_FP64,
1120 
1121     // Bitwise operations on signed and unsigned integers: note that
1122     // bitwise operations on signed integers can lead to different results,
1123     // depending on your compiler; results are implementation-defined.
1124 
1125     // z = (x | y)      z = (x & y)         z = (x ^ y)        z = ~(x ^ y)
1126     GrB_BOR_INT8,       GrB_BAND_INT8,      GrB_BXOR_INT8,     GrB_BXNOR_INT8,
1127     GrB_BOR_INT16,      GrB_BAND_INT16,     GrB_BXOR_INT16,    GrB_BXNOR_INT16,
1128     GrB_BOR_INT32,      GrB_BAND_INT32,     GrB_BXOR_INT32,    GrB_BXNOR_INT32,
1129     GrB_BOR_INT64,      GrB_BAND_INT64,     GrB_BXOR_INT64,    GrB_BXNOR_INT64,
1130     GrB_BOR_UINT8,      GrB_BAND_UINT8,     GrB_BXOR_UINT8,    GrB_BXNOR_UINT8,
1131     GrB_BOR_UINT16,     GrB_BAND_UINT16,    GrB_BXOR_UINT16,   GrB_BXNOR_UINT16,
1132     GrB_BOR_UINT32,     GrB_BAND_UINT32,    GrB_BXOR_UINT32,   GrB_BXNOR_UINT32,
1133     GrB_BOR_UINT64,     GrB_BAND_UINT64,    GrB_BXOR_UINT64,   GrB_BXNOR_UINT64,
1134 
1135     // z = bitget(x,y)  z = bitset(x,y)     z = bitclr(x,y)
1136     GxB_BGET_INT8,      GxB_BSET_INT8,      GxB_BCLR_INT8,
1137     GxB_BGET_INT16,     GxB_BSET_INT16,     GxB_BCLR_INT16,
1138     GxB_BGET_INT32,     GxB_BSET_INT32,     GxB_BCLR_INT32,
1139     GxB_BGET_INT64,     GxB_BSET_INT64,     GxB_BCLR_INT64,
1140     GxB_BGET_UINT8,     GxB_BSET_UINT8,     GxB_BCLR_UINT8,
1141     GxB_BGET_UINT16,    GxB_BSET_UINT16,    GxB_BCLR_UINT16,
1142     GxB_BGET_UINT32,    GxB_BSET_UINT32,    GxB_BCLR_UINT32,
1143     GxB_BGET_UINT64,    GxB_BSET_UINT64,    GxB_BCLR_UINT64 ;
1144 
1145 //------------------------------------------------------------------------------
1146 // z=f(x,y) where z and x have the same type, but y is GrB_INT8
1147 //------------------------------------------------------------------------------
1148 
1149     // z = bitshift (x,y) computes z = x left-shifted by y bits if y >= 0, or z
1150     // = x right-shifted by (-y) bits if y < 0.  z is equal to x if y is zero.
1151     // z and x have the same type, as given by the suffix on the operator name.
1152     // Since y must be signed, it cannot have the same type as x when x is
1153     // unsigned; it is always GrB_INT8 for all 8 versions of this operator.
1154     // The GxB_BSHIFT_* operators compute the arithmetic shift, and produce the
1155     // same results as the MATLAB BITSHIFT function, for all possible inputs.
1156 
1157 GB_PUBLIC GrB_BinaryOp
1158 
1159     // z = bitshift(x,y)
1160     GxB_BSHIFT_INT8,
1161     GxB_BSHIFT_INT16,
1162     GxB_BSHIFT_INT32,
1163     GxB_BSHIFT_INT64,
1164     GxB_BSHIFT_UINT8,
1165     GxB_BSHIFT_UINT16,
1166     GxB_BSHIFT_UINT32,
1167     GxB_BSHIFT_UINT64 ;
1168 
1169 //------------------------------------------------------------------------------
1170 // z=f(x,y) where z is BOOL and the type of x,y is given by the suffix
1171 //------------------------------------------------------------------------------
1172 
1173 GB_PUBLIC GrB_BinaryOp
1174 
1175     // Six comparison operators z=f(x,y) return their result as boolean, but
1176     // where x and y have the same type.  The suffix in their names refers to
1177     // the type of x and y since z is always boolean.  If used as multiply
1178     // operators in a semiring, they can only be combined with boolean monoids.
1179     // The _BOOL versions of these operators give the same results as their
1180     // IS*_BOOL counterparts.  GrB_EQ_BOOL and GrB_LXNOR are identical.
1181 
1182     // z = (x == y)     z = (x != y)        z = (x > y)         z = (x < y)
1183     GrB_EQ_BOOL,        GrB_NE_BOOL,        GrB_GT_BOOL,        GrB_LT_BOOL,
1184     GrB_EQ_INT8,        GrB_NE_INT8,        GrB_GT_INT8,        GrB_LT_INT8,
1185     GrB_EQ_INT16,       GrB_NE_INT16,       GrB_GT_INT16,       GrB_LT_INT16,
1186     GrB_EQ_INT32,       GrB_NE_INT32,       GrB_GT_INT32,       GrB_LT_INT32,
1187     GrB_EQ_INT64,       GrB_NE_INT64,       GrB_GT_INT64,       GrB_LT_INT64,
1188     GrB_EQ_UINT8,       GrB_NE_UINT8,       GrB_GT_UINT8,       GrB_LT_UINT8,
1189     GrB_EQ_UINT16,      GrB_NE_UINT16,      GrB_GT_UINT16,      GrB_LT_UINT16,
1190     GrB_EQ_UINT32,      GrB_NE_UINT32,      GrB_GT_UINT32,      GrB_LT_UINT32,
1191     GrB_EQ_UINT64,      GrB_NE_UINT64,      GrB_GT_UINT64,      GrB_LT_UINT64,
1192     GrB_EQ_FP32,        GrB_NE_FP32,        GrB_GT_FP32,        GrB_LT_FP32,
1193     GrB_EQ_FP64,        GrB_NE_FP64,        GrB_GT_FP64,        GrB_LT_FP64,
1194     // complex:
1195     GxB_EQ_FC32,        GxB_NE_FC32,
1196     GxB_EQ_FC64,        GxB_NE_FC64,
1197 
1198     // z = (x >= y)     z = (x <= y)
1199     GrB_GE_BOOL,        GrB_LE_BOOL,
1200     GrB_GE_INT8,        GrB_LE_INT8,
1201     GrB_GE_INT16,       GrB_LE_INT16,
1202     GrB_GE_INT32,       GrB_LE_INT32,
1203     GrB_GE_INT64,       GrB_LE_INT64,
1204     GrB_GE_UINT8,       GrB_LE_UINT8,
1205     GrB_GE_UINT16,      GrB_LE_UINT16,
1206     GrB_GE_UINT32,      GrB_LE_UINT32,
1207     GrB_GE_UINT64,      GrB_LE_UINT64,
1208     GrB_GE_FP32,        GrB_LE_FP32,
1209     GrB_GE_FP64,        GrB_LE_FP64 ;
1210 
1211 //------------------------------------------------------------------------------
1212 // z=f(x,y) where z is complex and the type of x,y is given by the suffix
1213 //------------------------------------------------------------------------------
1214 
1215 GB_PUBLIC GrB_BinaryOp
1216 
1217     // z = cmplx (x,y)
1218     GxB_CMPLX_FP32,
1219     GxB_CMPLX_FP64 ;
1220 
1221 //==============================================================================
1222 // positional GrB_UnaryOp and GrB_BinaryOp operators
1223 //==============================================================================
1224 
1225 // Positional operators do not depend on the value of an entry, but its row or
1226 // column index in the matrix instead.  For example, for an entry A(i,j),
1227 // first_i(A(i,j),y) is equal to i.  These operators are useful for returning
1228 // node id's as the result of a semiring operation.  If used as a mask, zero
1229 // has a special value, and thus z=first_i1(A(i,j),j) returns i+1 instead of i.
1230 // This can be useful when using a positional operator to construct a mask
1231 // matrix or vector for another GraphBLAS operation.  It is also essential for
1232 // the MATLAB interface, since the user view of matrix indices in MATLAB is
1233 // 1-based, not 0-based.
1234 
1235 // When applied to a vector, j is always equal to 0.  For a GxB_SCALAR,
1236 // both i and j are always zero.
1237 
1238 // GraphBLAS defines a GrB_Index as uint64_t, but these operators return a
1239 // GrB_INT32 or GrB_INT64 type, which is more flexible to use because the
1240 // result of this operator can be negated, to flag an entry for example.  The
1241 // value -1 can be used to denote "no node" or "no position".  GrB_INT32 is
1242 // useful for graphs smaller than 2^31 nodes.  If the row or column index
1243 // exceeds INT32_MAX, the result is determined by the typecast from the
1244 // 64-bit index to the smaller 32-bit index.
1245 
1246 // Positional operators cannot be used to construct monoids.  They can be used
1247 // as multiplicative operators in semirings, and as operators for GrB_eWise*,
1248 // and GrB_apply (bind first or second).  For the latter, the operator cannot
1249 // depend on the bound scalar.
1250 
1251 // When used as multiplicative operators in a semiring, FIRSTJ and SECONDI
1252 // are identical.  If C(i,j) += t is computed where t = A(i,k)*B(k,j), then
1253 // t = k in both cases.  Likewise, FIRSTJ1 and SECONDI1 are identical.
1254 
1255 GB_PUBLIC GrB_BinaryOp
1256 
1257     GxB_FIRSTI_INT32,   GxB_FIRSTI_INT64,    // z = first_i(A(i,j),y) == i
1258     GxB_FIRSTI1_INT32,  GxB_FIRSTI1_INT64,   // z = first_i1(A(i,j),y) == i+1
1259     GxB_FIRSTJ_INT32,   GxB_FIRSTJ_INT64,    // z = first_j(A(i,j),y) == j
1260     GxB_FIRSTJ1_INT32,  GxB_FIRSTJ1_INT64,   // z = first_j1(A(i,j),y) == j+1
1261     GxB_SECONDI_INT32,  GxB_SECONDI_INT64,   // z = second_i(x,B(i,j)) == i
1262     GxB_SECONDI1_INT32, GxB_SECONDI1_INT64,  // z = second_i1(x,B(i,j)) == i+1
1263     GxB_SECONDJ_INT32,  GxB_SECONDJ_INT64,   // z = second_j(x,B(i,j)) == j
1264     GxB_SECONDJ1_INT32, GxB_SECONDJ1_INT64 ; // z = second_j1(x,B(i,j)) == j+1
1265 
1266 GB_PUBLIC GrB_UnaryOp
1267 
1268     GxB_POSITIONI_INT32,  GxB_POSITIONI_INT64,  // z=position_i(A(i,j)) == i
1269     GxB_POSITIONI1_INT32, GxB_POSITIONI1_INT64, // z=position_i1(A(i,j)) == i+1
1270     GxB_POSITIONJ_INT32,  GxB_POSITIONJ_INT64,  // z=position_j(A(i,j)) == j
1271     GxB_POSITIONJ1_INT32, GxB_POSITIONJ1_INT64 ;// z=position_j1(A(i,j)) == j+1
1272 
1273 //==============================================================================
1274 // About boolean and bitwise binary operators
1275 //==============================================================================
1276 
1277 // Some of the boolean operators compute the same thing with different names.
1278 // For example, x*y and x&&y give the same results for boolean x and y.
1279 // Operations such as x < y when x and y are boolean are treated as if true=1
1280 // and false=0.  Below is the truth table for all binary operators with boolean
1281 // inputs.  This table is defined by how C typecasts boolean values for
1282 // non-boolean operations.  For example, if x, y, and z are boolean, x = true,
1283 // and y = true, then z = x + y = true + true = true.  DIV (x/y) is defined
1284 // below.  RDIV (y/x) is shown as \ in the table; it is the same as 2nd.
1285 
1286 //  x y  1st 2nd min max +  -  *  /  or and xor eq ne > < ge le \ pow pair
1287 //  0 0  0   0   0   0   0  0  0  0  0  0   0   1  0  0 0 1  1  0 1   1
1288 //  0 1  0   1   0   1   1  1  0  0  1  0   1   0  1  0 1 0  1  1 0   1
1289 //  1 0  1   0   0   1   1  1  0  1  1  0   1   0  1  1 0 1  0  0 1   1
1290 //  1 1  1   1   1   1   1  0  1  1  1  1   0   1  0  0 0 1  1  1 1   1
1291 
1292 // GraphBLAS includes a GrB_DIV_BOOL operator in its specification, but does
1293 // not define what boolean "division" means.  SuiteSparse:GraphBLAS makes the
1294 // following interpretation.
1295 
1296 // GraphBLAS does not generate exceptions for divide-by-zero, so the results
1297 // are defined just as they are in MATLAB.  Floating-point divide-by-zero
1298 // follows the IEEE 754 standard: 1/0 is +Inf, -1/0 is -Inf, and 0/0 is NaN.
1299 // For integer division by zero, if x is positive, x/0 is the largest integer,
1300 // -x/0 is the integer minimum (zero for unsigned integers), and 0/0 is zero.
1301 // For example, for int8, 1/0 is 127, and -1/0 is -128.  For uint8, 1/0 is 255
1302 // and 0/0 is zero.
1303 
1304 // Boolean division is not in MATLAB.  For SuiteSparse:GraphBLAS, boolean
1305 // division is treated as if it were an unsigned integer type with true=1 and
1306 // false=0, and with the max and min value being 1 and 0.  As a result,
1307 // GrB_IDENTITY_BOOL, GrB_AINV_BOOL, and GrB_MINV_BOOL all give the same result
1308 // (z = x).
1309 
1310 // With this convention for boolean "division", there are 11 unique binary
1311 // operators that are purely boolean.  Other named *_BOOL operators are
1312 // redundant but are included in GraphBLAS so that the name space of operators
1313 // is complete.  Below is a list of all operators and their equivalents.
1314 
1315 //                   x: 0 0 1 1
1316 //                   y: 0 1 0 1
1317 //                   z: see below
1318 //
1319 //      z = 0           0 0 0 0     (zero function, not predefined)
1320 //      z = (x && y)    0 0 0 1     AND, MIN, TIMES
1321 //      z = (x > y)     0 0 1 0     GT, ISGT, and set diff (x\y)
1322 //      z = x           0 0 1 1     FIRST, DIV
1323 //
1324 //      z = (x < y)     0 1 0 0     LT, ISLT, and set diff (y\x)
1325 //      z = y           0 1 0 1     SECOND, RDIV
1326 //      z = (x != y)    0 1 1 0     XOR, MINUS, RMINUS, NE, ISNE
1327 //      z = (x || y)    0 1 1 1     OR, MAX, PLUS
1328 //
1329 //      z = ~(x || y)   1 0 0 0     (nor(x,y) function, not predefined)
1330 //      z = (x == y)    1 0 0 1     LXNOR, EQ, ISEQ
1331 //      z = ~y          1 0 1 0     (not(y), not predefined)
1332 //      z = (x >= y)    1 0 1 1     GE, ISGE, POW, and "x implies y"
1333 //
1334 //      z = ~x          1 1 0 0     (not(x), not predefined)
1335 //      z = (x <= y)    1 1 0 1     LE, ISLE, and "y implies x"
1336 //      z = ~(x && y)   1 1 1 0     (nand(x,y) function, not predefined)
1337 //      z = 1           1 1 1 1     PAIR
1338 //
1339 //      z = any(x,y)    0 . . 1     ANY (pick x or y arbitrarily)
1340 
1341 // Four more that have no _BOOL suffix are also redundant with the operators
1342 // of the form GxB_*_BOOL (GrB_LOR, GrB_LAND, GrB_LXOR, and GrB_LXNOR).
1343 
1344 // Note that the boolean binary operator space is not complete.  Five other
1345 // boolean functions could be pre-defined as well:  z = 0, nor(x,y),
1346 // nand(x,y), not(x), and not(y).
1347 
1348 // Four of the possible 16 bitwise operators are pre-defined: BOR, BAND,
1349 // BXOR, and BXNOR.  This assumes that the computations for each bit are
1350 // entirely independent (so BSHIFT would not fit in the table above).
1351 
1352 //------------------------------------------------------------------------------
1353 // methods for binary operators
1354 //------------------------------------------------------------------------------
1355 
1356 typedef void (*GxB_binary_function) (void *, const void *, const void *) ;
1357 
1358 #undef GrB_BinaryOp_new
1359 #undef GrM_BinaryOp_new
1360 
1361 GB_PUBLIC
1362 GrB_Info GRB (BinaryOp_new)
1363 (
1364     GrB_BinaryOp *binaryop,         // handle for the new binary operator
1365     GxB_binary_function function,   // pointer to the binary function
1366     GrB_Type ztype,                 // type of output z
1367     GrB_Type xtype,                 // type of input x
1368     GrB_Type ytype                  // type of input y
1369 ) ;
1370 
1371 #define GrB_BinaryOp_new(op,f,z,x,y) GB_BinaryOp_new (op,f,z,x,y, GB_STR(f))
1372 #define GrM_BinaryOp_new(op,f,z,x,y) GM_BinaryOp_new (op,f,z,x,y, GB_STR(f))
1373 
1374 GB_PUBLIC
1375 GrB_Info GB_BinaryOp_new            // not user-callable; use GrB_BinaryOp_new
1376 (
1377     GrB_BinaryOp *binaryop,         // handle for the new binary operator
1378     GxB_binary_function function,   // pointer to the binary function
1379     GrB_Type ztype,                 // type of output z
1380     GrB_Type xtype,                 // type of input x
1381     GrB_Type ytype,                 // type of input y
1382     const char *name                // name of the underlying function
1383 ) ;
1384 
1385 GB_PUBLIC
1386 GrB_Info GxB_BinaryOp_ztype         // return the type of z
1387 (
1388     GrB_Type *ztype,                // return type of output z
1389     GrB_BinaryOp binaryop           // binary operator to query
1390 ) ;
1391 
1392 GB_PUBLIC
1393 GrB_Info GxB_BinaryOp_xtype         // return the type of x
1394 (
1395     GrB_Type *xtype,                // return type of input x
1396     GrB_BinaryOp binaryop           // binary operator to query
1397 ) ;
1398 
1399 GB_PUBLIC
1400 GrB_Info GxB_BinaryOp_ytype         // return the type of y
1401 (
1402     GrB_Type *ytype,                // return type of input y
1403     GrB_BinaryOp binaryop           // binary operator to query
1404 ) ;
1405 
1406 GB_PUBLIC
1407 GrB_Info GrB_BinaryOp_free          // free a user-created binary operator
1408 (
1409     GrB_BinaryOp *binaryop          // handle of binary operator to free
1410 ) ;
1411 
1412 //==============================================================================
1413 // GxB_SelectOp: select operators
1414 //==============================================================================
1415 
1416 // GxB_SelectOp is an operator used by GxB_select to select entries from an
1417 // input matrix A that are kept in the output C.  If an entry A(i,j) in the
1418 // matrix A, of size nrows-by-ncols, has the value aij, then it calls the
1419 // select function as result = f (i, j, aij, thunk).  If the function returns
1420 // true, the entry is kept in the output C.  If f returns false, the entry is
1421 // not kept in C.  The type of x for the GxB_SelectOp operator may be any of
1422 // the 11 built-in types, or any user-defined type.  It may also be GrB_NULL,
1423 // to indicate that the function is type-generic and does not depend at all on
1424 // the value aij.  In this case, x is passed to f as a NULL pointer.
1425 
1426 // The optional Thunk parameter to GxB_select is a GxB_Scalar.  For built-in
1427 // select operators (TRIL, TRIU, DIAG, and OFFDIAG), Thunk must have any
1428 // built-in type, and thunk = (int64_t) Thunk is used to specific the diagonal
1429 // for these operators.  Thunk may be NULL, in which case its value is treated
1430 // as zero, if it has a built-in type. The value of Thunk (if present) is not
1431 // modified by any built-in select operator.
1432 
1433 // For user-defined select operators, Thunk is not typecasted at all.  If
1434 // the user operator is defined with a non-NULL Thunk input, then it must
1435 // be non-NULL and of the same type, when calling GxB_select.
1436 
1437 // GxB_SelectOp:  a function z=f(i,j,x,thunk) for the GxB_Select operation.
1438 // The function f must have the signature:
1439 
1440 //      bool f (GrB_Index i, GrB_Index j,
1441 //              const void *x, const void *thunk) ;
1442 
1443 // NOTE: GxB_SelectOp has changed in v4.  In v3.3.3 it had this syntax:
1444 
1445 //      bool f (GrB_Index i, GrB_Index j,
1446 //              GrB_Index nrows, GrB_Index ncols,
1447 //              const void *x, const void *thunk) ;
1448 
1449 typedef struct GB_SelectOp_opaque *GxB_SelectOp ;
1450 
1451 //------------------------------------------------------------------------------
1452 // built-in select operators
1453 //------------------------------------------------------------------------------
1454 
1455 // GxB_select (C, Mask, accum, op, A, Thunk, desc) always returns a matrix C of
1456 // the same size as A (or A' if GrB_TRAN is in the descriptor).
1457 
1458 GB_PUBLIC GxB_SelectOp
1459 
1460     GxB_TRIL,       // C=tril(A,thunk):   returns true if ((j-i) <= thunk)
1461     GxB_TRIU,       // C=triu(A,thunk):   returns true if ((j-i) >= thunk)
1462     GxB_DIAG,       // C=diag(A,thunk):   returns true if ((j-i) == thunk)
1463     GxB_OFFDIAG,    // C=A-diag(A,thunk): returns true if ((j-i) != thunk)
1464 
1465     GxB_NONZERO,    // C=A(A ~= 0)
1466     GxB_EQ_ZERO,    // C=A(A == 0)
1467     GxB_GT_ZERO,    // C=A(A >  0)
1468     GxB_GE_ZERO,    // C=A(A >= 0)
1469     GxB_LT_ZERO,    // C=A(A <  0)
1470     GxB_LE_ZERO,    // C=A(A <= 0)
1471 
1472     GxB_NE_THUNK,   // C=A(A ~= thunk)
1473     GxB_EQ_THUNK,   // C=A(A == thunk)
1474     GxB_GT_THUNK,   // C=A(A >  thunk)
1475     GxB_GE_THUNK,   // C=A(A >= thunk)
1476     GxB_LT_THUNK,   // C=A(A <  thunk)
1477     GxB_LE_THUNK ;  // C=A(A <= thunk)
1478 
1479 // For GxB_TRIL, GxB_TRIU, GxB_DIAG, and GxB_OFFDIAG, the parameter Thunk is a
1480 // GxB_Scalar of any built-in type.  If GrB_NULL, or empty, Thunk is treated as
1481 // zero.  Otherwise, the single entry is typecasted as (int64_t) Thunk.
1482 // These select operators do not depend on the values of A, but just their
1483 // position, and they work on matrices of any type.
1484 
1485 // For GxB_*ZERO, the result depends only on the value of A(i,j).  The Thunk
1486 // parameter to GxB_select is ignored and may be GrB_NULL.
1487 
1488 // The operators GxB_TRIL, GxB_TRIU, GxB_DIAG, GxB_OFFDIAG, GxB_NONZERO,
1489 // GxB_EQ_ZERO, GxB_NE_THUNK, and GxB_EQ_THUNK work on all built-in types and
1490 // all user-defined types.
1491 
1492 // GxB_GT_*, GxB_GE_*, GxB_LT_*, and GxB_LE_* only work on the 11 built-in
1493 // types (not complex).  They cannot be used for user-defined types.
1494 
1495 //------------------------------------------------------------------------------
1496 // select operators
1497 //------------------------------------------------------------------------------
1498 
1499 typedef bool (*GxB_select_function)      // return true if A(i,j) is kept
1500 (
1501     GrB_Index i,                // row index of A(i,j)
1502     GrB_Index j,                // column index of A(i,j)
1503     const void *x,              // value of A(i,j)
1504     const void *thunk           // optional input for select function
1505 ) ;
1506 
1507 #undef GxB_SelectOp_new
1508 #undef GxM_SelectOp_new
1509 
1510 GB_PUBLIC
1511 GrB_Info GXB (SelectOp_new)     // create a new user-defined select operator
1512 (
1513     GxB_SelectOp *selectop,     // handle for the new select operator
1514     GxB_select_function function,// pointer to the select function
1515     GrB_Type xtype,             // type of input x, or NULL if type-generic
1516     GrB_Type ttype              // type of thunk, or NULL if not used
1517 ) ;
1518 
1519 #define GxB_SelectOp_new(op,f,x,t) GB_SelectOp_new (op,f,x,t, GB_STR(f))
1520 #define GxM_SelectOp_new(op,f,x,t) GM_SelectOp_new (op,f,x,t, GB_STR(f))
1521 
1522 GB_PUBLIC
1523 GrB_Info GB_SelectOp_new        // not user-callable; use GxB_SelectOp_new
1524 (
1525     GxB_SelectOp *selectop,     // handle for the new select operator
1526     GxB_select_function function,// pointer to the select function
1527     GrB_Type xtype,             // type of input x
1528     GrB_Type ttype,             // type of thunk, or NULL if not used
1529     const char *name            // name of the underlying function
1530 ) ;
1531 
1532 GB_PUBLIC
1533 GrB_Info GxB_SelectOp_xtype     // return the type of x
1534 (
1535     GrB_Type *xtype,            // return type of input x
1536     GxB_SelectOp selectop       // select operator
1537 ) ;
1538 
1539 GB_PUBLIC
1540 GrB_Info GxB_SelectOp_ttype     // return the type of thunk
1541 (
1542     GrB_Type *ttype,            // return type of input thunk
1543     GxB_SelectOp selectop       // select operator
1544 ) ;
1545 
1546 GB_PUBLIC
1547 GrB_Info GxB_SelectOp_free      // free a user-created select operator
1548 (
1549     GxB_SelectOp *selectop      // handle of select operator to free
1550 ) ;
1551 
1552 //==============================================================================
1553 // GrB_Monoid
1554 //==============================================================================
1555 
1556 // A monoid is an associative operator z=op(x,y) where all three types of z, x,
1557 // and y are identical.  The monoid also has an identity element, such that
1558 // op(x,identity) = op(identity,x) = x.
1559 
1560 typedef struct GB_Monoid_opaque *GrB_Monoid ;
1561 
1562 GB_PUBLIC
1563 GrB_Info GrB_Monoid_new_BOOL        // create a new boolean monoid
1564 (
1565     GrB_Monoid *monoid,             // handle of monoid to create
1566     GrB_BinaryOp op,                // binary operator of the monoid
1567     bool identity                   // identity value of the monoid
1568 ) ;
1569 
1570 GB_PUBLIC
1571 GrB_Info GrB_Monoid_new_INT8        // create a new int8 monoid
1572 (
1573     GrB_Monoid *monoid,             // handle of monoid to create
1574     GrB_BinaryOp op,                // binary operator of the monoid
1575     int8_t identity                 // identity value of the monoid
1576 ) ;
1577 
1578 GB_PUBLIC
1579 GrB_Info GrB_Monoid_new_UINT8       // create a new uint8 monoid
1580 (
1581     GrB_Monoid *monoid,             // handle of monoid to create
1582     GrB_BinaryOp op,                // binary operator of the monoid
1583     uint8_t identity                // identity value of the monoid
1584 ) ;
1585 
1586 GB_PUBLIC
1587 GrB_Info GrB_Monoid_new_INT16       // create a new int16 monoid
1588 (
1589     GrB_Monoid *monoid,             // handle of monoid to create
1590     GrB_BinaryOp op,                // binary operator of the monoid
1591     int16_t identity                // identity value of the monoid
1592 ) ;
1593 
1594 GB_PUBLIC
1595 GrB_Info GrB_Monoid_new_UINT16      // create a new uint16 monoid
1596 (
1597     GrB_Monoid *monoid,             // handle of monoid to create
1598     GrB_BinaryOp op,                // binary operator of the monoid
1599     uint16_t identity               // identity value of the monoid
1600 ) ;
1601 
1602 GB_PUBLIC
1603 GrB_Info GrB_Monoid_new_INT32       // create a new int32 monoid
1604 (
1605     GrB_Monoid *monoid,             // handle of monoid to create
1606     GrB_BinaryOp op,                // binary operator of the monoid
1607     int32_t identity                // identity value of the monoid
1608 ) ;
1609 
1610 GB_PUBLIC
1611 GrB_Info GrB_Monoid_new_UINT32      // create a new uint32 monoid
1612 (
1613     GrB_Monoid *monoid,             // handle of monoid to create
1614     GrB_BinaryOp op,                // binary operator of the monoid
1615     uint32_t identity               // identity value of the monoid
1616 ) ;
1617 
1618 GB_PUBLIC
1619 GrB_Info GrB_Monoid_new_INT64       // create a new int64 monoid
1620 (
1621     GrB_Monoid *monoid,             // handle of monoid to create
1622     GrB_BinaryOp op,                // binary operator of the monoid
1623     int64_t identity                // identity value of the monoid
1624 ) ;
1625 
1626 GB_PUBLIC
1627 GrB_Info GrB_Monoid_new_UINT64      // create a new uint64 monoid
1628 (
1629     GrB_Monoid *monoid,             // handle of monoid to create
1630     GrB_BinaryOp op,                // binary operator of the monoid
1631     uint64_t identity               // identity value of the monoid
1632 ) ;
1633 
1634 GB_PUBLIC
1635 GrB_Info GrB_Monoid_new_FP32        // create a new float monoid
1636 (
1637     GrB_Monoid *monoid,             // handle of monoid to create
1638     GrB_BinaryOp op,                // binary operator of the monoid
1639     float identity                  // identity value of the monoid
1640 ) ;
1641 
1642 GB_PUBLIC
1643 GrB_Info GrB_Monoid_new_FP64        // create a new double monoid
1644 (
1645     GrB_Monoid *monoid,             // handle of monoid to create
1646     GrB_BinaryOp op,                // binary operator of the monoid
1647     double identity                 // identity value of the monoid
1648 ) ;
1649 
1650 GB_PUBLIC
1651 GrB_Info GxB_Monoid_new_FC32        // create a new float complex monoid
1652 (
1653     GrB_Monoid *monoid,             // handle of monoid to create
1654     GrB_BinaryOp op,                // binary operator of the monoid
1655     GxB_FC32_t identity             // identity value of the monoid
1656 ) ;
1657 
1658 GB_PUBLIC
1659 GrB_Info GxB_Monoid_new_FC64        // create a new double complex monoid
1660 (
1661     GrB_Monoid *monoid,             // handle of monoid to create
1662     GrB_BinaryOp op,                // binary operator of the monoid
1663     GxB_FC64_t identity             // identity value of the monoid
1664 ) ;
1665 
1666 GB_PUBLIC
1667 GrB_Info GrB_Monoid_new_UDT         // create a monoid with a user-defined type
1668 (
1669     GrB_Monoid *monoid,             // handle of monoid to create
1670     GrB_BinaryOp op,                // binary operator of the monoid
1671     void *identity                  // identity value of the monoid
1672 ) ;
1673 
1674 // Type-generic method for creating a new monoid:
1675 
1676 /*
1677 
1678 GB_PUBLIC
1679 GrB_Info GrB_Monoid_new             // create a monoid
1680 (
1681     GrB_Monoid *monoid,             // handle of monoid to create
1682     GrB_BinaryOp op,          // binary operator of the monoid
1683     <type> identity           // identity value of the monoid
1684 ) ;
1685 
1686 */
1687 
1688 #if GxB_STDC_VERSION >= 201112L
1689 #define GrB_Monoid_new(monoid,op,identity) \
1690     _Generic ((identity), GB_CASES (, GrB, Monoid_new)) (monoid, op, identity) ;
1691 #endif
1692 
1693 // GxB_Monoid_terminal_new is identical to GrB_Monoid_new, except that a
1694 // terminal value can be specified.  The terminal may be NULL, which indicates
1695 // no terminal value (and in this case, it is identical to GrB_Monoid_new).
1696 // The terminal value, if not NULL, must have the same type as the identity.
1697 
1698 GB_PUBLIC
1699 GrB_Info GxB_Monoid_terminal_new_BOOL        // create a new boolean monoid
1700 (
1701     GrB_Monoid *monoid,             // handle of monoid to create
1702     GrB_BinaryOp op,                // binary operator of the monoid
1703     bool identity,                  // identity value of the monoid
1704     bool terminal                   // terminal value of the monoid
1705 ) ;
1706 
1707 GB_PUBLIC
1708 GrB_Info GxB_Monoid_terminal_new_INT8        // create a new int8 monoid
1709 (
1710     GrB_Monoid *monoid,             // handle of monoid to create
1711     GrB_BinaryOp op,                // binary operator of the monoid
1712     int8_t identity,                // identity value of the monoid
1713     int8_t terminal                 // terminal value of the monoid
1714 ) ;
1715 
1716 GB_PUBLIC
1717 GrB_Info GxB_Monoid_terminal_new_UINT8       // create a new uint8 monoid
1718 (
1719     GrB_Monoid *monoid,             // handle of monoid to create
1720     GrB_BinaryOp op,                // binary operator of the monoid
1721     uint8_t identity,               // identity value of the monoid
1722     uint8_t terminal                // terminal value of the monoid
1723 ) ;
1724 
1725 GB_PUBLIC
1726 GrB_Info GxB_Monoid_terminal_new_INT16       // create a new int16 monoid
1727 (
1728     GrB_Monoid *monoid,             // handle of monoid to create
1729     GrB_BinaryOp op,                // binary operator of the monoid
1730     int16_t identity,               // identity value of the monoid
1731     int16_t terminal                // terminal value of the monoid
1732 ) ;
1733 
1734 GB_PUBLIC
1735 GrB_Info GxB_Monoid_terminal_new_UINT16      // create a new uint16 monoid
1736 (
1737     GrB_Monoid *monoid,             // handle of monoid to create
1738     GrB_BinaryOp op,                // binary operator of the monoid
1739     uint16_t identity,              // identity value of the monoid
1740     uint16_t terminal               // terminal value of the monoid
1741 ) ;
1742 
1743 GB_PUBLIC
1744 GrB_Info GxB_Monoid_terminal_new_INT32       // create a new int32 monoid
1745 (
1746     GrB_Monoid *monoid,             // handle of monoid to create
1747     GrB_BinaryOp op,                // binary operator of the monoid
1748     int32_t identity,               // identity value of the monoid
1749     int32_t terminal                // terminal value of the monoid
1750 ) ;
1751 
1752 GB_PUBLIC
1753 GrB_Info GxB_Monoid_terminal_new_UINT32      // create a new uint32 monoid
1754 (
1755     GrB_Monoid *monoid,             // handle of monoid to create
1756     GrB_BinaryOp op,                // binary operator of the monoid
1757     uint32_t identity,              // identity value of the monoid
1758     uint32_t terminal               // terminal value of the monoid
1759 ) ;
1760 
1761 GB_PUBLIC
1762 GrB_Info GxB_Monoid_terminal_new_INT64       // create a new int64 monoid
1763 (
1764     GrB_Monoid *monoid,             // handle of monoid to create
1765     GrB_BinaryOp op,                // binary operator of the monoid
1766     int64_t identity,               // identity value of the monoid
1767     int64_t terminal                // terminal value of the monoid
1768 ) ;
1769 
1770 GB_PUBLIC
1771 GrB_Info GxB_Monoid_terminal_new_UINT64      // create a new uint64 monoid
1772 (
1773     GrB_Monoid *monoid,             // handle of monoid to create
1774     GrB_BinaryOp op,                // binary operator of the monoid
1775     uint64_t identity,              // identity value of the monoid
1776     uint64_t terminal               // terminal value of the monoid
1777 ) ;
1778 
1779 GB_PUBLIC
1780 GrB_Info GxB_Monoid_terminal_new_FP32        // create a new float monoid
1781 (
1782     GrB_Monoid *monoid,             // handle of monoid to create
1783     GrB_BinaryOp op,                // binary operator of the monoid
1784     float identity,                 // identity value of the monoid
1785     float terminal                  // terminal value of the monoid
1786 ) ;
1787 
1788 GB_PUBLIC
1789 GrB_Info GxB_Monoid_terminal_new_FP64        // create a new double monoid
1790 (
1791     GrB_Monoid *monoid,             // handle of monoid to create
1792     GrB_BinaryOp op,                // binary operator of the monoid
1793     double identity,                // identity value of the monoid
1794     double terminal                 // terminal value of the monoid
1795 ) ;
1796 
1797 GB_PUBLIC
1798 GrB_Info GxB_Monoid_terminal_new_FC32   // create a new float complex monoid
1799 (
1800     GrB_Monoid *monoid,             // handle of monoid to create
1801     GrB_BinaryOp op,                // binary operator of the monoid
1802     GxB_FC32_t identity,            // identity value of the monoid
1803     GxB_FC32_t terminal             // terminal value of the monoid
1804 ) ;
1805 
1806 GB_PUBLIC
1807 GrB_Info GxB_Monoid_terminal_new_FC64   // create a new double complex monoid
1808 (
1809     GrB_Monoid *monoid,             // handle of monoid to create
1810     GrB_BinaryOp op,                // binary operator of the monoid
1811     GxB_FC64_t identity,            // identity value of the monoid
1812     GxB_FC64_t terminal             // terminal value of the monoid
1813 ) ;
1814 
1815 GB_PUBLIC
1816 GrB_Info GxB_Monoid_terminal_new_UDT    // create a monoid with a user type
1817 (
1818     GrB_Monoid *monoid,             // handle of monoid to create
1819     GrB_BinaryOp op,                // binary operator of the monoid
1820     void *identity,                 // identity value of the monoid
1821     void *terminal                  // terminal value of the monoid
1822 ) ;
1823 
1824 // Type-generic method for creating a new monoid with a terminal value:
1825 
1826 /*
1827 
1828 GB_PUBLIC
1829 GrB_Info GxB_Monoid_terminal_new             // create a monoid
1830 (
1831     GrB_Monoid *monoid,             // handle of monoid to create
1832     GrB_BinaryOp op,                // binary operator of the monoid
1833     <type> identity,                // identity value of the monoid
1834     <type> terminal                 // terminal value of the monoid
1835 ) ;
1836 
1837 */
1838 
1839 #if GxB_STDC_VERSION >= 201112L
1840 #define GxB_Monoid_terminal_new(monoid,op,identity,terminal)        \
1841     _Generic ((identity), GB_CASES (, GxB, Monoid_terminal_new))     \
1842     (monoid, op, identity, terminal) ;
1843 #endif
1844 
1845 GB_PUBLIC
1846 GrB_Info GxB_Monoid_operator        // return the monoid operator
1847 (
1848     GrB_BinaryOp *op,               // returns the binary op of the monoid
1849     GrB_Monoid monoid               // monoid to query
1850 ) ;
1851 
1852 GB_PUBLIC
1853 GrB_Info GxB_Monoid_identity        // return the monoid identity
1854 (
1855     void *identity,                 // returns the identity of the monoid
1856     GrB_Monoid monoid               // monoid to query
1857 ) ;
1858 
1859 GB_PUBLIC
1860 GrB_Info GxB_Monoid_terminal        // return the monoid terminal
1861 (
1862     bool *has_terminal,             // true if the monoid has a terminal value
1863     void *terminal,                 // returns the terminal of the monoid,
1864                                     // unmodified if has_terminal is false
1865     GrB_Monoid monoid               // monoid to query
1866 ) ;
1867 
1868 GB_PUBLIC
1869 GrB_Info GrB_Monoid_free            // free a user-created monoid
1870 (
1871     GrB_Monoid *monoid              // handle of monoid to free
1872 ) ;
1873 
1874 //==============================================================================
1875 // GrB_Semiring
1876 //==============================================================================
1877 
1878 typedef struct GB_Semiring_opaque *GrB_Semiring ;
1879 
1880 GB_PUBLIC
1881 GrB_Info GrB_Semiring_new           // create a semiring
1882 (
1883     GrB_Semiring *semiring,         // handle of semiring to create
1884     GrB_Monoid add,                 // add monoid of the semiring
1885     GrB_BinaryOp multiply           // multiply operator of the semiring
1886 ) ;
1887 
1888 GB_PUBLIC
1889 GrB_Info GxB_Semiring_add           // return the add monoid of a semiring
1890 (
1891     GrB_Monoid *add,                // returns add monoid of the semiring
1892     GrB_Semiring semiring           // semiring to query
1893 ) ;
1894 
1895 GB_PUBLIC
1896 GrB_Info GxB_Semiring_multiply      // return multiply operator of a semiring
1897 (
1898     GrB_BinaryOp *multiply,         // returns multiply operator of the semiring
1899     GrB_Semiring semiring           // semiring to query
1900 ) ;
1901 
1902 GB_PUBLIC
1903 GrB_Info GrB_Semiring_free          // free a user-created semiring
1904 (
1905     GrB_Semiring *semiring          // handle of semiring to free
1906 ) ;
1907 
1908 //==============================================================================
1909 // GxB_Scalar: a GraphBLAS scalar
1910 //==============================================================================
1911 
1912 typedef struct GB_Scalar_opaque *GxB_Scalar ;
1913 
1914 // These methods create, free, copy, and clear a GxB_Scalar.  The nvals,
1915 // and type methods return basic information about a GxB_Scalar.
1916 
1917 GB_PUBLIC
1918 GrB_Info GxB_Scalar_new     // create a new GxB_Scalar with no entry
1919 (
1920     GxB_Scalar *s,          // handle of GxB_Scalar to create
1921     GrB_Type type           // type of GxB_Scalar to create
1922 ) ;
1923 
1924 GB_PUBLIC
1925 GrB_Info GxB_Scalar_dup     // make an exact copy of a GxB_Scalar
1926 (
1927     GxB_Scalar *s,          // handle of output GxB_Scalar to create
1928     const GxB_Scalar t      // input GxB_Scalar to copy
1929 ) ;
1930 
1931 GB_PUBLIC
1932 GrB_Info GxB_Scalar_clear   // clear a GxB_Scalar of its entry
1933 (                           // type remains unchanged.
1934     GxB_Scalar s            // GxB_Scalar to clear
1935 ) ;
1936 
1937 GB_PUBLIC
1938 GrB_Info GxB_Scalar_nvals   // get the number of entries in a GxB_Scalar
1939 (
1940     GrB_Index *nvals,       // GxB_Scalar has nvals entries (0 or 1)
1941     const GxB_Scalar s      // GxB_Scalar to query
1942 ) ;
1943 
1944 GB_PUBLIC
1945 GrB_Info GxB_Scalar_type    // get the type of a GxB_Scalar
1946 (
1947     GrB_Type *type,         // returns the type of the GxB_Scalar
1948     const GxB_Scalar s      // GxB_Scalar to query
1949 ) ;
1950 
1951 GB_PUBLIC
1952 GrB_Info GxB_Scalar_free    // free a GxB_Scalar
1953 (
1954     GxB_Scalar *s           // handle of GxB_Scalar to free
1955 ) ;
1956 
1957 //------------------------------------------------------------------------------
1958 // GxB_Scalar_setElement
1959 //------------------------------------------------------------------------------
1960 
1961 // Set a single GxB_Scalar s, from a user scalar x: s = x, typecasting from the
1962 // type of x to the type of w as needed.
1963 
1964 GB_PUBLIC
1965 GrB_Info GxB_Scalar_setElement_BOOL     // s = x
1966 (
1967     GxB_Scalar s,                       // GxB_Scalar to modify
1968     bool x                              // user scalar to assign to s
1969 ) ;
1970 
1971 GB_PUBLIC
1972 GrB_Info GxB_Scalar_setElement_INT8     // s = x
1973 (
1974     GxB_Scalar s,                       // GxB_Scalar to modify
1975     int8_t x                            // user scalar to assign to s
1976 ) ;
1977 
1978 GB_PUBLIC
1979 GrB_Info GxB_Scalar_setElement_UINT8    // s = x
1980 (
1981     GxB_Scalar s,                       // GxB_Scalar to modify
1982     uint8_t x                           // user scalar to assign to s
1983 ) ;
1984 
1985 GB_PUBLIC
1986 GrB_Info GxB_Scalar_setElement_INT16    // s = x
1987 (
1988     GxB_Scalar s,                       // GxB_Scalar to modify
1989     int16_t x                           // user scalar to assign to s
1990 ) ;
1991 
1992 GB_PUBLIC
1993 GrB_Info GxB_Scalar_setElement_UINT16   // s = x
1994 (
1995     GxB_Scalar s,                       // GxB_Scalar to modify
1996     uint16_t x                          // user scalar to assign to s
1997 ) ;
1998 
1999 GB_PUBLIC
2000 GrB_Info GxB_Scalar_setElement_INT32    // s = x
2001 (
2002     GxB_Scalar s,                       // GxB_Scalar to modify
2003     int32_t x                           // user scalar to assign to s
2004 ) ;
2005 
2006 GB_PUBLIC
2007 GrB_Info GxB_Scalar_setElement_UINT32   // s = x
2008 (
2009     GxB_Scalar s,                       // GxB_Scalar to modify
2010     uint32_t x                          // user scalar to assign to s
2011 ) ;
2012 
2013 GB_PUBLIC
2014 GrB_Info GxB_Scalar_setElement_INT64    // s = x
2015 (
2016     GxB_Scalar s,                       // GxB_Scalar to modify
2017     int64_t x                           // user scalar to assign to s
2018 ) ;
2019 
2020 GB_PUBLIC
2021 GrB_Info GxB_Scalar_setElement_UINT64   // s = x
2022 (
2023     GxB_Scalar s,                       // GxB_Scalar to modify
2024     uint64_t x                          // user scalar to assign to s
2025 ) ;
2026 
2027 GB_PUBLIC
2028 GrB_Info GxB_Scalar_setElement_FP32     // s = x
2029 (
2030     GxB_Scalar s,                       // GxB_Scalar to modify
2031     float x                             // user scalar to assign to s
2032 ) ;
2033 
2034 GB_PUBLIC
2035 GrB_Info GxB_Scalar_setElement_FP64     // s = x
2036 (
2037     GxB_Scalar s,                       // GxB_Scalar to modify
2038     double x                            // user scalar to assign to s
2039 ) ;
2040 
2041 GB_PUBLIC
2042 GrB_Info GxB_Scalar_setElement_FC32     // s = x
2043 (
2044     GxB_Scalar s,                       // GxB_Scalar to modify
2045     GxB_FC32_t x                        // user scalar to assign to s
2046 ) ;
2047 
2048 GB_PUBLIC
2049 GrB_Info GxB_Scalar_setElement_FC64     // s = x
2050 (
2051     GxB_Scalar s,                       // GxB_Scalar to modify
2052     GxB_FC64_t x                        // user scalar to assign to s
2053 ) ;
2054 
2055 GB_PUBLIC
2056 GrB_Info GxB_Scalar_setElement_UDT      // s = x
2057 (
2058     GxB_Scalar s,                       // GxB_Scalar to modify
2059     void *x                             // user scalar to assign to s
2060 ) ;
2061 
2062 // Type-generic version:  x can be any supported C type or void * for a
2063 // user-defined type.
2064 
2065 /*
2066 
2067 GB_PUBLIC
2068 GrB_Info GxB_Scalar_setElement          // s = x
2069 (
2070     GxB_Scalar s,                       // GxB_Scalar to modify
2071     <type> x                            // user scalar to assign to s
2072 ) ;
2073 
2074 */
2075 
2076 #if GxB_STDC_VERSION >= 201112L
2077 #define GxB_Scalar_setElement(s,x)  \
2078     _Generic ((x), GB_CASES (, GxB, Scalar_setElement)) (s, x)
2079 #endif
2080 
2081 //------------------------------------------------------------------------------
2082 // GxB_Scalar_extractElement
2083 //------------------------------------------------------------------------------
2084 
2085 // Extract a single entry from a GxB_Scalar, x = s, typecasting from the type
2086 // of s to the type of x as needed.
2087 
2088 GB_PUBLIC
2089 GrB_Info GxB_Scalar_extractElement_BOOL     // x = s
2090 (
2091     bool *x,                        // user scalar extracted
2092     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2093 ) ;
2094 
2095 GB_PUBLIC
2096 GrB_Info GxB_Scalar_extractElement_INT8     // x = s
2097 (
2098     int8_t *x,                      // user scalar extracted
2099     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2100 ) ;
2101 
2102 GB_PUBLIC
2103 GrB_Info GxB_Scalar_extractElement_UINT8    // x = s
2104 (
2105     uint8_t *x,                     // user scalar extracted
2106     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2107 ) ;
2108 
2109 GB_PUBLIC
2110 GrB_Info GxB_Scalar_extractElement_INT16    // x = s
2111 (
2112     int16_t *x,                     // user scalar extracted
2113     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2114 ) ;
2115 
2116 GB_PUBLIC
2117 GrB_Info GxB_Scalar_extractElement_UINT16   // x = s
2118 (
2119     uint16_t *x,                    // user scalar extracted
2120     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2121 ) ;
2122 
2123 GB_PUBLIC
2124 GrB_Info GxB_Scalar_extractElement_INT32    // x = s
2125 (
2126     int32_t *x,                     // user scalar extracted
2127     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2128 ) ;
2129 
2130 GB_PUBLIC
2131 GrB_Info GxB_Scalar_extractElement_UINT32   // x = s
2132 (
2133     uint32_t *x,                    // user scalar extracted
2134     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2135 ) ;
2136 
2137 GB_PUBLIC
2138 GrB_Info GxB_Scalar_extractElement_INT64    // x = s
2139 (
2140     int64_t *x,                     // user scalar extracted
2141     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2142 ) ;
2143 
2144 GB_PUBLIC
2145 GrB_Info GxB_Scalar_extractElement_UINT64   // x = s
2146 (
2147     uint64_t *x,                    // user scalar extracted
2148     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2149 ) ;
2150 
2151 GB_PUBLIC
2152 GrB_Info GxB_Scalar_extractElement_FP32     // x = s
2153 (
2154     float *x,                       // user scalar extracted
2155     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2156 ) ;
2157 
2158 GB_PUBLIC
2159 GrB_Info GxB_Scalar_extractElement_FP64     // x = s
2160 (
2161     double *x,                      // user scalar extracted
2162     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2163 ) ;
2164 
2165 GB_PUBLIC
2166 GrB_Info GxB_Scalar_extractElement_FC32     // x = s
2167 (
2168     GxB_FC32_t *x,                  // user scalar extracted
2169     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2170 ) ;
2171 
2172 GB_PUBLIC
2173 GrB_Info GxB_Scalar_extractElement_FC64     // x = s
2174 (
2175     GxB_FC64_t *x,                  // user scalar extracted
2176     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2177 ) ;
2178 
2179 GB_PUBLIC
2180 GrB_Info GxB_Scalar_extractElement_UDT      // x = s
2181 (
2182     void *x,                        // user scalar extracted
2183     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2184 ) ;
2185 
2186 // Type-generic version:  x can be a pointer to any supported C type or void *
2187 // for a user-defined type.
2188 
2189 /*
2190 
2191 GB_PUBLIC
2192 GrB_Info GxB_Scalar_extractElement  // x = s
2193 (
2194     <type> *x,                      // user scalar extracted
2195     const GxB_Scalar s              // GxB_Scalar to extract an entry from
2196 ) ;
2197 
2198 */
2199 
2200 #if GxB_STDC_VERSION >= 201112L
2201 #define GxB_Scalar_extractElement(x,s)  \
2202     _Generic ((x), GB_CASES (*, GxB, Scalar_extractElement)) (x, s)
2203 #endif
2204 
2205 //==============================================================================
2206 // GrB_Vector: a GraphBLAS vector
2207 //==============================================================================
2208 
2209 typedef struct GB_Vector_opaque *GrB_Vector ;
2210 
2211 // These methods create, free, copy, and clear a vector.  The size, nvals,
2212 // and type methods return basic information about a vector.
2213 
2214 GB_PUBLIC
2215 GrB_Info GrB_Vector_new     // create a new vector with no entries
2216 (
2217     GrB_Vector *v,          // handle of vector to create
2218     GrB_Type type,          // type of vector to create
2219     GrB_Index n             // vector dimension is n-by-1
2220 ) ;
2221 
2222 GB_PUBLIC
2223 GrB_Info GrB_Vector_dup     // make an exact copy of a vector
2224 (
2225     GrB_Vector *w,          // handle of output vector to create
2226     const GrB_Vector u      // input vector to copy
2227 ) ;
2228 
2229 GB_PUBLIC
2230 GrB_Info GrB_Vector_clear   // clear a vector of all entries;
2231 (                           // type and dimension remain unchanged.
2232     GrB_Vector v            // vector to clear
2233 ) ;
2234 
2235 GB_PUBLIC
2236 GrB_Info GrB_Vector_size    // get the dimension of a vector
2237 (
2238     GrB_Index *n,           // vector dimension is n-by-1
2239     const GrB_Vector v      // vector to query
2240 ) ;
2241 
2242 GB_PUBLIC
2243 GrB_Info GrB_Vector_nvals   // get the number of entries in a vector
2244 (
2245     GrB_Index *nvals,       // vector has nvals entries
2246     const GrB_Vector v      // vector to query
2247 ) ;
2248 
2249 GB_PUBLIC
2250 GrB_Info GxB_Vector_type    // get the type of a vector
2251 (
2252     GrB_Type *type,         // returns the type of the vector
2253     const GrB_Vector v      // vector to query
2254 ) ;
2255 
2256 GB_PUBLIC
2257 GrB_Info GrB_Vector_free    // free a vector
2258 (
2259     GrB_Vector *v           // handle of vector to free
2260 ) ;
2261 
2262 //------------------------------------------------------------------------------
2263 // GrB_Vector_build
2264 //------------------------------------------------------------------------------
2265 
2266 // GrB_Vector_build:  w = sparse (I,1,X) in MATLAB notation, but using any
2267 // associative operator to assemble duplicate entries.
2268 
2269 GB_PUBLIC
2270 GrB_Info GrB_Vector_build_BOOL      // build a vector from (I,X) tuples
2271 (
2272     GrB_Vector w,                   // vector to build
2273     const GrB_Index *I,             // array of row indices of tuples
2274     const bool *X,                  // array of values of tuples
2275     GrB_Index nvals,                // number of tuples
2276     const GrB_BinaryOp dup          // binary function to assemble duplicates
2277 ) ;
2278 
2279 GB_PUBLIC
2280 GrB_Info GrB_Vector_build_INT8      // build a vector from (I,X) tuples
2281 (
2282     GrB_Vector w,                   // vector to build
2283     const GrB_Index *I,             // array of row indices of tuples
2284     const int8_t *X,                // array of values of tuples
2285     GrB_Index nvals,                // number of tuples
2286     const GrB_BinaryOp dup          // binary function to assemble duplicates
2287 ) ;
2288 
2289 GB_PUBLIC
2290 GrB_Info GrB_Vector_build_UINT8     // build a vector from (I,X) tuples
2291 (
2292     GrB_Vector w,                   // vector to build
2293     const GrB_Index *I,             // array of row indices of tuples
2294     const uint8_t *X,               // array of values of tuples
2295     GrB_Index nvals,                // number of tuples
2296     const GrB_BinaryOp dup          // binary function to assemble duplicates
2297 ) ;
2298 
2299 GB_PUBLIC
2300 GrB_Info GrB_Vector_build_INT16     // build a vector from (I,X) tuples
2301 (
2302     GrB_Vector w,                   // vector to build
2303     const GrB_Index *I,             // array of row indices of tuples
2304     const int16_t *X,               // array of values of tuples
2305     GrB_Index nvals,                // number of tuples
2306     const GrB_BinaryOp dup          // binary function to assemble duplicates
2307 ) ;
2308 
2309 GB_PUBLIC
2310 GrB_Info GrB_Vector_build_UINT16    // build a vector from (I,X) tuples
2311 (
2312     GrB_Vector w,                   // vector to build
2313     const GrB_Index *I,             // array of row indices of tuples
2314     const uint16_t *X,              // array of values of tuples
2315     GrB_Index nvals,                // number of tuples
2316     const GrB_BinaryOp dup          // binary function to assemble duplicates
2317 ) ;
2318 
2319 GB_PUBLIC
2320 GrB_Info GrB_Vector_build_INT32     // build a vector from (I,X) tuples
2321 (
2322     GrB_Vector w,                   // vector to build
2323     const GrB_Index *I,             // array of row indices of tuples
2324     const int32_t *X,               // array of values of tuples
2325     GrB_Index nvals,                // number of tuples
2326     const GrB_BinaryOp dup          // binary function to assemble duplicates
2327 ) ;
2328 
2329 GB_PUBLIC
2330 GrB_Info GrB_Vector_build_UINT32    // build a vector from (I,X) tuples
2331 (
2332     GrB_Vector w,                   // vector to build
2333     const GrB_Index *I,             // array of row indices of tuples
2334     const uint32_t *X,              // array of values of tuples
2335     GrB_Index nvals,                // number of tuples
2336     const GrB_BinaryOp dup          // binary function to assemble duplicates
2337 ) ;
2338 
2339 GB_PUBLIC
2340 GrB_Info GrB_Vector_build_INT64     // build a vector from (I,X) tuples
2341 (
2342     GrB_Vector w,                   // vector to build
2343     const GrB_Index *I,             // array of row indices of tuples
2344     const int64_t *X,               // array of values of tuples
2345     GrB_Index nvals,                // number of tuples
2346     const GrB_BinaryOp dup          // binary function to assemble duplicates
2347 ) ;
2348 
2349 GB_PUBLIC
2350 GrB_Info GrB_Vector_build_UINT64    // build a vector from (I,X) tuples
2351 (
2352     GrB_Vector w,                   // vector to build
2353     const GrB_Index *I,             // array of row indices of tuples
2354     const uint64_t *X,              // array of values of tuples
2355     GrB_Index nvals,                // number of tuples
2356     const GrB_BinaryOp dup          // binary function to assemble duplicates
2357 ) ;
2358 
2359 GB_PUBLIC
2360 GrB_Info GrB_Vector_build_FP32      // build a vector from (I,X) tuples
2361 (
2362     GrB_Vector w,                   // vector to build
2363     const GrB_Index *I,             // array of row indices of tuples
2364     const float *X,                 // array of values of tuples
2365     GrB_Index nvals,                // number of tuples
2366     const GrB_BinaryOp dup          // binary function to assemble duplicates
2367 ) ;
2368 
2369 GB_PUBLIC
2370 GrB_Info GrB_Vector_build_FP64      // build a vector from (I,X) tuples
2371 (
2372     GrB_Vector w,                   // vector to build
2373     const GrB_Index *I,             // array of row indices of tuples
2374     const double *X,                // array of values of tuples
2375     GrB_Index nvals,                // number of tuples
2376     const GrB_BinaryOp dup          // binary function to assemble duplicates
2377 ) ;
2378 
2379 GB_PUBLIC
2380 GrB_Info GxB_Vector_build_FC32      // build a vector from (I,X) tuples
2381 (
2382     GrB_Vector w,                   // vector to build
2383     const GrB_Index *I,             // array of row indices of tuples
2384     const GxB_FC32_t *X,            // array of values of tuples
2385     GrB_Index nvals,                // number of tuples
2386     const GrB_BinaryOp dup          // binary function to assemble duplicates
2387 ) ;
2388 
2389 GB_PUBLIC
2390 GrB_Info GxB_Vector_build_FC64      // build a vector from (I,X) tuples
2391 (
2392     GrB_Vector w,                   // vector to build
2393     const GrB_Index *I,             // array of row indices of tuples
2394     const GxB_FC64_t *X,            // array of values of tuples
2395     GrB_Index nvals,                // number of tuples
2396     const GrB_BinaryOp dup          // binary function to assemble duplicates
2397 ) ;
2398 
2399 GB_PUBLIC
2400 GrB_Info GrB_Vector_build_UDT       // build a vector from (I,X) tuples
2401 (
2402     GrB_Vector w,                   // vector to build
2403     const GrB_Index *I,             // array of row indices of tuples
2404     const void *X,                  // array of values of tuples
2405     GrB_Index nvals,                // number of tuples
2406     const GrB_BinaryOp dup          // binary function to assemble duplicates
2407 ) ;
2408 
2409 // Type-generic version:  X can be a pointer to any supported C type or void *
2410 // for a user-defined type.
2411 
2412 /*
2413 
2414 GB_PUBLIC
2415 GrB_Info GrB_Vector_build           // build a vector from (I,X) tuples
2416 (
2417     GrB_Vector w,                   // vector to build
2418     const GrB_Index *I,             // array of row indices of tuples
2419     const <type> *X,                // array of values of tuples
2420     GrB_Index nvals,                // number of tuples
2421     const GrB_BinaryOp dup          // binary function to assemble duplicates
2422 ) ;
2423 
2424 */
2425 
2426 #if GxB_STDC_VERSION >= 201112L
2427 #define GrB_Vector_build(w,I,X,nvals,dup)               \
2428     _Generic ((X), GB_CASES (*, GrB, Vector_build))     \
2429     (w, I, ((const void *) (X)), nvals, dup)
2430 #endif
2431 
2432 //------------------------------------------------------------------------------
2433 // GrB_Vector_setElement
2434 //------------------------------------------------------------------------------
2435 
2436 // Set a single scalar in a vector, w(i) = x, typecasting from the type of x to
2437 // the type of w as needed.
2438 
2439 GB_PUBLIC
2440 GrB_Info GrB_Vector_setElement_BOOL     // w(i) = x
2441 (
2442     GrB_Vector w,                       // vector to modify
2443     bool x,                             // scalar to assign to w(i)
2444     GrB_Index i                         // row index
2445 ) ;
2446 
2447 GB_PUBLIC
2448 GrB_Info GrB_Vector_setElement_INT8     // w(i) = x
2449 (
2450     GrB_Vector w,                       // vector to modify
2451     int8_t x,                           // scalar to assign to w(i)
2452     GrB_Index i                         // row index
2453 ) ;
2454 
2455 GB_PUBLIC
2456 GrB_Info GrB_Vector_setElement_UINT8    // w(i) = x
2457 (
2458     GrB_Vector w,                       // vector to modify
2459     uint8_t x,                          // scalar to assign to w(i)
2460     GrB_Index i                         // row index
2461 ) ;
2462 
2463 GB_PUBLIC
2464 GrB_Info GrB_Vector_setElement_INT16    // w(i) = x
2465 (
2466     GrB_Vector w,                       // vector to modify
2467     int16_t x,                          // scalar to assign to w(i)
2468     GrB_Index i                         // row index
2469 ) ;
2470 
2471 GB_PUBLIC
2472 GrB_Info GrB_Vector_setElement_UINT16   // w(i) = x
2473 (
2474     GrB_Vector w,                       // vector to modify
2475     uint16_t x,                         // scalar to assign to w(i)
2476     GrB_Index i                         // row index
2477 ) ;
2478 
2479 GB_PUBLIC
2480 GrB_Info GrB_Vector_setElement_INT32    // w(i) = x
2481 (
2482     GrB_Vector w,                       // vector to modify
2483     int32_t x,                          // scalar to assign to w(i)
2484     GrB_Index i                         // row index
2485 ) ;
2486 
2487 GB_PUBLIC
2488 GrB_Info GrB_Vector_setElement_UINT32   // w(i) = x
2489 (
2490     GrB_Vector w,                       // vector to modify
2491     uint32_t x,                         // scalar to assign to w(i)
2492     GrB_Index i                         // row index
2493 ) ;
2494 
2495 GB_PUBLIC
2496 GrB_Info GrB_Vector_setElement_INT64    // w(i) = x
2497 (
2498     GrB_Vector w,                       // vector to modify
2499     int64_t x,                          // scalar to assign to w(i)
2500     GrB_Index i                         // row index
2501 ) ;
2502 
2503 GB_PUBLIC
2504 GrB_Info GrB_Vector_setElement_UINT64   // w(i) = x
2505 (
2506     GrB_Vector w,                       // vector to modify
2507     uint64_t x,                         // scalar to assign to w(i)
2508     GrB_Index i                         // row index
2509 ) ;
2510 
2511 GB_PUBLIC
2512 GrB_Info GrB_Vector_setElement_FP32     // w(i) = x
2513 (
2514     GrB_Vector w,                       // vector to modify
2515     float x,                            // scalar to assign to w(i)
2516     GrB_Index i                         // row index
2517 ) ;
2518 
2519 GB_PUBLIC
2520 GrB_Info GrB_Vector_setElement_FP64     // w(i) = x
2521 (
2522     GrB_Vector w,                       // vector to modify
2523     double x,                           // scalar to assign to w(i)
2524     GrB_Index i                         // row index
2525 ) ;
2526 
2527 GB_PUBLIC
2528 GrB_Info GxB_Vector_setElement_FC32     // w(i) = x
2529 (
2530     GrB_Vector w,                       // vector to modify
2531     GxB_FC32_t x,                       // scalar to assign to w(i)
2532     GrB_Index i                         // row index
2533 ) ;
2534 
2535 GB_PUBLIC
2536 GrB_Info GxB_Vector_setElement_FC64     // w(i) = x
2537 (
2538     GrB_Vector w,                       // vector to modify
2539     GxB_FC64_t x,                       // scalar to assign to w(i)
2540     GrB_Index i                         // row index
2541 ) ;
2542 
2543 GB_PUBLIC
2544 GrB_Info GrB_Vector_setElement_UDT      // w(i) = x
2545 (
2546     GrB_Vector w,                       // vector to modify
2547     void *x,                            // scalar to assign to w(i)
2548     GrB_Index i                         // row index
2549 ) ;
2550 
2551 // Type-generic version:  x can be any supported C type or void * for a
2552 // user-defined type.
2553 
2554 /*
2555 
2556 GB_PUBLIC
2557 GrB_Info GrB_Vector_setElement          // w(i) = x
2558 (
2559     GrB_Vector w,                       // vector to modify
2560     <type> x,                           // scalar to assign to w(i)
2561     GrB_Index i                         // row index
2562 ) ;
2563 
2564 */
2565 
2566 #if GxB_STDC_VERSION >= 201112L
2567 #define GrB_Vector_setElement(w,x,i)    \
2568     _Generic ((x), GB_CASES (, GrB, Vector_setElement)) (w, x, i)
2569 #endif
2570 
2571 //------------------------------------------------------------------------------
2572 // GrB_Vector_extractElement
2573 //------------------------------------------------------------------------------
2574 
2575 // Extract a single entry from a vector, x = v(i), typecasting from the type of
2576 // v to the type of x as needed.
2577 
2578 GB_PUBLIC
2579 GrB_Info GrB_Vector_extractElement_BOOL     // x = v(i)
2580 (
2581     bool *x,                        // scalar extracted
2582     const GrB_Vector v,             // vector to extract an entry from
2583     GrB_Index i                     // row index
2584 ) ;
2585 
2586 GB_PUBLIC
2587 GrB_Info GrB_Vector_extractElement_INT8     // x = v(i)
2588 (
2589     int8_t *x,                      // scalar extracted
2590     const GrB_Vector v,             // vector to extract an entry from
2591     GrB_Index i                     // row index
2592 ) ;
2593 
2594 GB_PUBLIC
2595 GrB_Info GrB_Vector_extractElement_UINT8    // x = v(i)
2596 (
2597     uint8_t *x,                     // scalar extracted
2598     const GrB_Vector v,             // vector to extract an entry from
2599     GrB_Index i                     // row index
2600 ) ;
2601 
2602 GB_PUBLIC
2603 GrB_Info GrB_Vector_extractElement_INT16    // x = v(i)
2604 (
2605     int16_t *x,                     // scalar extracted
2606     const GrB_Vector v,             // vector to extract an entry from
2607     GrB_Index i                     // row index
2608 ) ;
2609 
2610 GB_PUBLIC
2611 GrB_Info GrB_Vector_extractElement_UINT16   // x = v(i)
2612 (
2613     uint16_t *x,                    // scalar extracted
2614     const GrB_Vector v,             // vector to extract an entry from
2615     GrB_Index i                     // row index
2616 ) ;
2617 
2618 GB_PUBLIC
2619 GrB_Info GrB_Vector_extractElement_INT32    // x = v(i)
2620 (
2621     int32_t *x,                     // scalar extracted
2622     const GrB_Vector v,             // vector to extract an entry from
2623     GrB_Index i                     // row index
2624 ) ;
2625 
2626 GB_PUBLIC
2627 GrB_Info GrB_Vector_extractElement_UINT32   // x = v(i)
2628 (
2629     uint32_t *x,                    // scalar extracted
2630     const GrB_Vector v,             // vector to extract an entry from
2631     GrB_Index i                     // row index
2632 ) ;
2633 
2634 GB_PUBLIC
2635 GrB_Info GrB_Vector_extractElement_INT64    // x = v(i)
2636 (
2637     int64_t *x,                     // scalar extracted
2638     const GrB_Vector v,             // vector to extract an entry from
2639     GrB_Index i                     // row index
2640 ) ;
2641 
2642 GB_PUBLIC
2643 GrB_Info GrB_Vector_extractElement_UINT64   // x = v(i)
2644 (
2645     uint64_t *x,                    // scalar extracted
2646     const GrB_Vector v,             // vector to extract an entry from
2647     GrB_Index i                     // row index
2648 ) ;
2649 
2650 GB_PUBLIC
2651 GrB_Info GrB_Vector_extractElement_FP32     // x = v(i)
2652 (
2653     float *x,                       // scalar extracted
2654     const GrB_Vector v,             // vector to extract an entry from
2655     GrB_Index i                     // row index
2656 ) ;
2657 
2658 GB_PUBLIC
2659 GrB_Info GrB_Vector_extractElement_FP64     // x = v(i)
2660 (
2661     double *x,                      // scalar extracted
2662     const GrB_Vector v,             // vector to extract an entry from
2663     GrB_Index i                     // row index
2664 ) ;
2665 
2666 GB_PUBLIC
2667 GrB_Info GxB_Vector_extractElement_FC32     // x = v(i)
2668 (
2669     GxB_FC32_t *x,                  // scalar extracted
2670     const GrB_Vector v,             // vector to extract an entry from
2671     GrB_Index i                     // row index
2672 ) ;
2673 
2674 GB_PUBLIC
2675 GrB_Info GxB_Vector_extractElement_FC64     // x = v(i)
2676 (
2677     GxB_FC64_t *x,                  // scalar extracted
2678     const GrB_Vector v,             // vector to extract an entry from
2679     GrB_Index i                     // row index
2680 ) ;
2681 
2682 GB_PUBLIC
2683 GrB_Info GrB_Vector_extractElement_UDT      // x = v(i)
2684 (
2685     void *x,                        // scalar extracted
2686     const GrB_Vector v,             // vector to extract an entry from
2687     GrB_Index i                     // row index
2688 ) ;
2689 
2690 // Type-generic version:  x can be a pointer to any supported C type or void *
2691 // for a user-defined type.
2692 
2693 /*
2694 
2695 GB_PUBLIC
2696 GrB_Info GrB_Vector_extractElement  // x = v(i)
2697 (
2698     <type> *x,                      // scalar extracted
2699     const GrB_Vector v,             // vector to extract an entry from
2700     GrB_Index i                     // row index
2701 ) ;
2702 
2703 */
2704 
2705 #if GxB_STDC_VERSION >= 201112L
2706 #define GrB_Vector_extractElement(x,v,i)    \
2707     _Generic ((x), GB_CASES (*, GrB, Vector_extractElement)) (x, v, i)
2708 #endif
2709 
2710 //------------------------------------------------------------------------------
2711 // GrB_Vector_removeElement
2712 //------------------------------------------------------------------------------
2713 
2714 // GrB_Vector_removeElement (v,i) removes the element v(i) from the vector v.
2715 
2716 GB_PUBLIC
2717 GrB_Info GrB_Vector_removeElement
2718 (
2719     GrB_Vector v,                   // vector to remove an element from
2720     GrB_Index i                     // index
2721 ) ;
2722 
2723 //------------------------------------------------------------------------------
2724 // GrB_Vector_extractTuples
2725 //------------------------------------------------------------------------------
2726 
2727 // Extracts all tuples from a vector, like [I,~,X] = find (v) in MATLAB.  If
2728 // any parameter I and/or X is NULL, then that component is not extracted.  For
2729 // example, to extract just the row indices, pass I as non-NULL, and X as NULL.
2730 // This is like [I,~,~] = find (v) in MATLAB.
2731 
2732 GB_PUBLIC
2733 GrB_Info GrB_Vector_extractTuples_BOOL      // [I,~,X] = find (v)
2734 (
2735     GrB_Index *I,               // array for returning row indices of tuples
2736     bool *X,                    // array for returning values of tuples
2737     GrB_Index *nvals,           // I, X size on input; # tuples on output
2738     const GrB_Vector v          // vector to extract tuples from
2739 ) ;
2740 
2741 GB_PUBLIC
2742 GrB_Info GrB_Vector_extractTuples_INT8      // [I,~,X] = find (v)
2743 (
2744     GrB_Index *I,               // array for returning row indices of tuples
2745     int8_t *X,                  // array for returning values of tuples
2746     GrB_Index *nvals,           // I, X size on input; # tuples on output
2747     const GrB_Vector v          // vector to extract tuples from
2748 ) ;
2749 
2750 GB_PUBLIC
2751 GrB_Info GrB_Vector_extractTuples_UINT8     // [I,~,X] = find (v)
2752 (
2753     GrB_Index *I,               // array for returning row indices of tuples
2754     uint8_t *X,                 // array for returning values of tuples
2755     GrB_Index *nvals,           // I, X size on input; # tuples on output
2756     const GrB_Vector v          // vector to extract tuples from
2757 ) ;
2758 
2759 GB_PUBLIC
2760 GrB_Info GrB_Vector_extractTuples_INT16     // [I,~,X] = find (v)
2761 (
2762     GrB_Index *I,               // array for returning row indices of tuples
2763     int16_t *X,                 // array for returning values of tuples
2764     GrB_Index *nvals,           // I, X size on input; # tuples on output
2765     const GrB_Vector v          // vector to extract tuples from
2766 ) ;
2767 
2768 GB_PUBLIC
2769 GrB_Info GrB_Vector_extractTuples_UINT16    // [I,~,X] = find (v)
2770 (
2771     GrB_Index *I,               // array for returning row indices of tuples
2772     uint16_t *X,                // array for returning values of tuples
2773     GrB_Index *nvals,           // I, X size on input; # tuples on output
2774     const GrB_Vector v          // vector to extract tuples from
2775 ) ;
2776 
2777 GB_PUBLIC
2778 GrB_Info GrB_Vector_extractTuples_INT32     // [I,~,X] = find (v)
2779 (
2780     GrB_Index *I,               // array for returning row indices of tuples
2781     int32_t *X,                 // array for returning values of tuples
2782     GrB_Index *nvals,           // I, X size on input; # tuples on output
2783     const GrB_Vector v          // vector to extract tuples from
2784 ) ;
2785 
2786 GB_PUBLIC
2787 GrB_Info GrB_Vector_extractTuples_UINT32    // [I,~,X] = find (v)
2788 (
2789     GrB_Index *I,               // array for returning row indices of tuples
2790     uint32_t *X,                // array for returning values of tuples
2791     GrB_Index *nvals,           // I, X size on input; # tuples on output
2792     const GrB_Vector v          // vector to extract tuples from
2793 ) ;
2794 
2795 GB_PUBLIC
2796 GrB_Info GrB_Vector_extractTuples_INT64     // [I,~,X] = find (v)
2797 (
2798     GrB_Index *I,               // array for returning row indices of tuples
2799     int64_t *X,                 // array for returning values of tuples
2800     GrB_Index *nvals,           // I, X size on input; # tuples on output
2801     const GrB_Vector v          // vector to extract tuples from
2802 ) ;
2803 
2804 GB_PUBLIC
2805 GrB_Info GrB_Vector_extractTuples_UINT64    // [I,~,X] = find (v)
2806 (
2807     GrB_Index *I,               // array for returning row indices of tuples
2808     uint64_t *X,                // array for returning values of tuples
2809     GrB_Index *nvals,           // I, X size on input; # tuples on output
2810     const GrB_Vector v          // vector to extract tuples from
2811 ) ;
2812 
2813 GB_PUBLIC
2814 GrB_Info GrB_Vector_extractTuples_FP32      // [I,~,X] = find (v)
2815 (
2816     GrB_Index *I,               // array for returning row indices of tuples
2817     float *X,                   // array for returning values of tuples
2818     GrB_Index *nvals,           // I, X size on input; # tuples on output
2819     const GrB_Vector v          // vector to extract tuples from
2820 ) ;
2821 
2822 GB_PUBLIC
2823 GrB_Info GrB_Vector_extractTuples_FP64      // [I,~,X] = find (v)
2824 (
2825     GrB_Index *I,               // array for returning row indices of tuples
2826     double *X,                  // array for returning values of tuples
2827     GrB_Index *nvals,           // I, X size on input; # tuples on output
2828     const GrB_Vector v          // vector to extract tuples from
2829 ) ;
2830 
2831 GB_PUBLIC
2832 GrB_Info GxB_Vector_extractTuples_FC32      // [I,~,X] = find (v)
2833 (
2834     GrB_Index *I,               // array for returning row indices of tuples
2835     GxB_FC32_t *X,              // array for returning values of tuples
2836     GrB_Index *nvals,           // I, X size on input; # tuples on output
2837     const GrB_Vector v          // vector to extract tuples from
2838 ) ;
2839 
2840 GB_PUBLIC
2841 GrB_Info GxB_Vector_extractTuples_FC64      // [I,~,X] = find (v)
2842 (
2843     GrB_Index *I,               // array for returning row indices of tuples
2844     GxB_FC64_t *X,              // array for returning values of tuples
2845     GrB_Index *nvals,           // I, X size on input; # tuples on output
2846     const GrB_Vector v          // vector to extract tuples from
2847 ) ;
2848 
2849 GB_PUBLIC
2850 GrB_Info GrB_Vector_extractTuples_UDT       // [I,~,X] = find (v)
2851 (
2852     GrB_Index *I,               // array for returning row indices of tuples
2853     void *X,                    // array for returning values of tuples
2854     GrB_Index *nvals,           // I, X size on input; # tuples on output
2855     const GrB_Vector v          // vector to extract tuples from
2856 ) ;
2857 
2858 // Type-generic version:  X can be a pointer to any supported C type or void *
2859 // for a user-defined type.
2860 
2861 /*
2862 
2863 GB_PUBLIC
2864 GrB_Info GrB_Vector_extractTuples           // [I,~,X] = find (v)
2865 (
2866     GrB_Index *I,               // array for returning row indices of tuples
2867     <type> *X,                  // array for returning values of tuples
2868     GrB_Index *nvals,           // I, X size on input; # tuples on output
2869     const GrB_Vector v          // vector to extract tuples from
2870 ) ;
2871 
2872 */
2873 
2874 #if GxB_STDC_VERSION >= 201112L
2875 #define GrB_Vector_extractTuples(I,X,nvals,v)   \
2876     _Generic ((X), GB_CASES (*, GrB, Vector_extractTuples)) (I, X, nvals, v)
2877 #endif
2878 
2879 //==============================================================================
2880 // GrB_Matrix: a GraphBLAS matrix
2881 //==============================================================================
2882 
2883 typedef struct GB_Matrix_opaque *GrB_Matrix ;
2884 
2885 // These methods create, free, copy, and clear a matrix.  The nrows, ncols,
2886 // nvals, and type methods return basic information about a matrix.
2887 
2888 GB_PUBLIC
2889 GrB_Info GrB_Matrix_new     // create a new matrix with no entries
2890 (
2891     GrB_Matrix *A,          // handle of matrix to create
2892     GrB_Type type,          // type of matrix to create
2893     GrB_Index nrows,        // matrix dimension is nrows-by-ncols
2894     GrB_Index ncols
2895 ) ;
2896 
2897 GB_PUBLIC
2898 GrB_Info GrB_Matrix_dup     // make an exact copy of a matrix
2899 (
2900     GrB_Matrix *C,          // handle of output matrix to create
2901     const GrB_Matrix A      // input matrix to copy
2902 ) ;
2903 
2904 GB_PUBLIC
2905 GrB_Info GrB_Matrix_clear   // clear a matrix of all entries;
2906 (                           // type and dimensions remain unchanged
2907     GrB_Matrix A            // matrix to clear
2908 ) ;
2909 
2910 GB_PUBLIC
2911 GrB_Info GrB_Matrix_nrows   // get the number of rows of a matrix
2912 (
2913     GrB_Index *nrows,       // matrix has nrows rows
2914     const GrB_Matrix A      // matrix to query
2915 ) ;
2916 
2917 GB_PUBLIC
2918 GrB_Info GrB_Matrix_ncols   // get the number of columns of a matrix
2919 (
2920     GrB_Index *ncols,       // matrix has ncols columns
2921     const GrB_Matrix A      // matrix to query
2922 ) ;
2923 
2924 GB_PUBLIC
2925 GrB_Info GrB_Matrix_nvals   // get the number of entries in a matrix
2926 (
2927     GrB_Index *nvals,       // matrix has nvals entries
2928     const GrB_Matrix A      // matrix to query
2929 ) ;
2930 
2931 GB_PUBLIC
2932 GrB_Info GxB_Matrix_type    // get the type of a matrix
2933 (
2934     GrB_Type *type,         // returns the type of the matrix
2935     const GrB_Matrix A      // matrix to query
2936 ) ;
2937 
2938 GB_PUBLIC
2939 GrB_Info GrB_Matrix_free    // free a matrix
2940 (
2941     GrB_Matrix *A           // handle of matrix to free
2942 ) ;
2943 
2944 //------------------------------------------------------------------------------
2945 // GrB_Matrix_build
2946 //------------------------------------------------------------------------------
2947 
2948 // GrB_Matrix_build:  C = sparse (I,J,X) in MATLAB notation, but using any
2949 // associative operator to assemble duplicate entries.
2950 
2951 GB_PUBLIC
2952 GrB_Info GrB_Matrix_build_BOOL      // build a matrix from (I,J,X) tuples
2953 (
2954     GrB_Matrix C,                   // matrix to build
2955     const GrB_Index *I,             // array of row indices of tuples
2956     const GrB_Index *J,             // array of column indices of tuples
2957     const bool *X,                  // array of values of tuples
2958     GrB_Index nvals,                // number of tuples
2959     const GrB_BinaryOp dup          // binary function to assemble duplicates
2960 ) ;
2961 
2962 GB_PUBLIC
2963 GrB_Info GrB_Matrix_build_INT8      // build a matrix from (I,J,X) tuples
2964 (
2965     GrB_Matrix C,                   // matrix to build
2966     const GrB_Index *I,             // array of row indices of tuples
2967     const GrB_Index *J,             // array of column indices of tuples
2968     const int8_t *X,                // array of values of tuples
2969     GrB_Index nvals,                // number of tuples
2970     const GrB_BinaryOp dup          // binary function to assemble duplicates
2971 ) ;
2972 
2973 GB_PUBLIC
2974 GrB_Info GrB_Matrix_build_UINT8     // build a matrix from (I,J,X) tuples
2975 (
2976     GrB_Matrix C,                   // matrix to build
2977     const GrB_Index *I,             // array of row indices of tuples
2978     const GrB_Index *J,             // array of column indices of tuples
2979     const uint8_t *X,               // array of values of tuples
2980     GrB_Index nvals,                // number of tuples
2981     const GrB_BinaryOp dup          // binary function to assemble duplicates
2982 ) ;
2983 
2984 GB_PUBLIC
2985 GrB_Info GrB_Matrix_build_INT16     // build a matrix from (I,J,X) tuples
2986 (
2987     GrB_Matrix C,                   // matrix to build
2988     const GrB_Index *I,             // array of row indices of tuples
2989     const GrB_Index *J,             // array of column indices of tuples
2990     const int16_t *X,               // array of values of tuples
2991     GrB_Index nvals,                // number of tuples
2992     const GrB_BinaryOp dup          // binary function to assemble duplicates
2993 ) ;
2994 
2995 GB_PUBLIC
2996 GrB_Info GrB_Matrix_build_UINT16    // build a matrix from (I,J,X) tuples
2997 (
2998     GrB_Matrix C,                   // matrix to build
2999     const GrB_Index *I,             // array of row indices of tuples
3000     const GrB_Index *J,             // array of column indices of tuples
3001     const uint16_t *X,              // array of values of tuples
3002     GrB_Index nvals,                // number of tuples
3003     const GrB_BinaryOp dup          // binary function to assemble duplicates
3004 ) ;
3005 
3006 GB_PUBLIC
3007 GrB_Info GrB_Matrix_build_INT32     // build a matrix from (I,J,X) tuples
3008 (
3009     GrB_Matrix C,                   // matrix to build
3010     const GrB_Index *I,             // array of row indices of tuples
3011     const GrB_Index *J,             // array of column indices of tuples
3012     const int32_t *X,               // array of values of tuples
3013     GrB_Index nvals,                // number of tuples
3014     const GrB_BinaryOp dup          // binary function to assemble duplicates
3015 ) ;
3016 
3017 GB_PUBLIC
3018 GrB_Info GrB_Matrix_build_UINT32    // build a matrix from (I,J,X) tuples
3019 (
3020     GrB_Matrix C,                   // matrix to build
3021     const GrB_Index *I,             // array of row indices of tuples
3022     const GrB_Index *J,             // array of column indices of tuples
3023     const uint32_t *X,              // array of values of tuples
3024     GrB_Index nvals,                // number of tuples
3025     const GrB_BinaryOp dup          // binary function to assemble duplicates
3026 ) ;
3027 
3028 GB_PUBLIC
3029 GrB_Info GrB_Matrix_build_INT64     // build a matrix from (I,J,X) tuples
3030 (
3031     GrB_Matrix C,                   // matrix to build
3032     const GrB_Index *I,             // array of row indices of tuples
3033     const GrB_Index *J,             // array of column indices of tuples
3034     const int64_t *X,               // array of values of tuples
3035     GrB_Index nvals,                // number of tuples
3036     const GrB_BinaryOp dup          // binary function to assemble duplicates
3037 ) ;
3038 
3039 GB_PUBLIC
3040 GrB_Info GrB_Matrix_build_UINT64    // build a matrix from (I,J,X) tuples
3041 (
3042     GrB_Matrix C,                   // matrix to build
3043     const GrB_Index *I,             // array of row indices of tuples
3044     const GrB_Index *J,             // array of column indices of tuples
3045     const uint64_t *X,              // array of values of tuples
3046     GrB_Index nvals,                // number of tuples
3047     const GrB_BinaryOp dup          // binary function to assemble duplicates
3048 ) ;
3049 
3050 GB_PUBLIC
3051 GrB_Info GrB_Matrix_build_FP32      // build a matrix from (I,J,X) tuples
3052 (
3053     GrB_Matrix C,                   // matrix to build
3054     const GrB_Index *I,             // array of row indices of tuples
3055     const GrB_Index *J,             // array of column indices of tuples
3056     const float *X,                 // array of values of tuples
3057     GrB_Index nvals,                // number of tuples
3058     const GrB_BinaryOp dup          // binary function to assemble duplicates
3059 ) ;
3060 
3061 GB_PUBLIC
3062 GrB_Info GrB_Matrix_build_FP64      // build a matrix from (I,J,X) tuples
3063 (
3064     GrB_Matrix C,                   // matrix to build
3065     const GrB_Index *I,             // array of row indices of tuples
3066     const GrB_Index *J,             // array of column indices of tuples
3067     const double *X,                // array of values of tuples
3068     GrB_Index nvals,                // number of tuples
3069     const GrB_BinaryOp dup          // binary function to assemble duplicates
3070 ) ;
3071 
3072 GB_PUBLIC
3073 GrB_Info GxB_Matrix_build_FC32      // build a matrix from (I,J,X) tuples
3074 (
3075     GrB_Matrix C,                   // matrix to build
3076     const GrB_Index *I,             // array of row indices of tuples
3077     const GrB_Index *J,             // array of column indices of tuples
3078     const GxB_FC32_t *X,            // array of values of tuples
3079     GrB_Index nvals,                // number of tuples
3080     const GrB_BinaryOp dup          // binary function to assemble duplicates
3081 ) ;
3082 
3083 GB_PUBLIC
3084 GrB_Info GxB_Matrix_build_FC64      // build a matrix from (I,J,X) tuples
3085 (
3086     GrB_Matrix C,                   // matrix to build
3087     const GrB_Index *I,             // array of row indices of tuples
3088     const GrB_Index *J,             // array of column indices of tuples
3089     const GxB_FC64_t *X,            // array of values of tuples
3090     GrB_Index nvals,                // number of tuples
3091     const GrB_BinaryOp dup          // binary function to assemble duplicates
3092 ) ;
3093 
3094 GB_PUBLIC
3095 GrB_Info GrB_Matrix_build_UDT       // build a matrix from (I,J,X) tuples
3096 (
3097     GrB_Matrix C,                   // matrix to build
3098     const GrB_Index *I,             // array of row indices of tuples
3099     const GrB_Index *J,             // array of column indices of tuples
3100     const void *X,                  // array of values of tuples
3101     GrB_Index nvals,                // number of tuples
3102     const GrB_BinaryOp dup          // binary function to assemble duplicates
3103 ) ;
3104 
3105 // Type-generic version:  X can be a pointer to any supported C type or void *
3106 // for a user-defined type.
3107 
3108 /*
3109 
3110 GB_PUBLIC
3111 GrB_Info GrB_Matrix_build           // build a matrix from (I,J,X) tuples
3112 (
3113     GrB_Matrix C,                   // matrix to build
3114     const GrB_Index *I,             // array of row indices of tuples
3115     const GrB_Index *J,             // array of column indices of tuples
3116     const <type> *X,                // array of values of tuples
3117     GrB_Index nvals,                // number of tuples
3118     const GrB_BinaryOp dup          // binary function to assemble duplicates
3119 ) ;
3120 
3121 */
3122 
3123 #if GxB_STDC_VERSION >= 201112L
3124 #define GrB_Matrix_build(C,I,J,X,nvals,dup)             \
3125     _Generic ((X), GB_CASES (*, GrB, Matrix_build))     \
3126     (C, I, J, ((const void *) (X)), nvals, dup)
3127 #endif
3128 
3129 //------------------------------------------------------------------------------
3130 // GrB_Matrix_setElement
3131 //------------------------------------------------------------------------------
3132 
3133 // Set a single entry in a matrix, C(i,j) = x in MATLAB notation, typecasting
3134 // from the type of x to the type of C, as needed.
3135 
3136 GB_PUBLIC
3137 GrB_Info GrB_Matrix_setElement_BOOL     // C (i,j) = x
3138 (
3139     GrB_Matrix C,                       // matrix to modify
3140     bool x,                             // scalar to assign to C(i,j)
3141     GrB_Index i,                        // row index
3142     GrB_Index j                         // column index
3143 ) ;
3144 
3145 GB_PUBLIC
3146 GrB_Info GrB_Matrix_setElement_INT8     // C (i,j) = x
3147 (
3148     GrB_Matrix C,                       // matrix to modify
3149     int8_t x,                           // scalar to assign to C(i,j)
3150     GrB_Index i,                        // row index
3151     GrB_Index j                         // column index
3152 ) ;
3153 
3154 GB_PUBLIC
3155 GrB_Info GrB_Matrix_setElement_UINT8    // C (i,j) = x
3156 (
3157     GrB_Matrix C,                       // matrix to modify
3158     uint8_t x,                          // scalar to assign to C(i,j)
3159     GrB_Index i,                        // row index
3160     GrB_Index j                         // column index
3161 ) ;
3162 
3163 GB_PUBLIC
3164 GrB_Info GrB_Matrix_setElement_INT16    // C (i,j) = x
3165 (
3166     GrB_Matrix C,                       // matrix to modify
3167     int16_t x,                          // scalar to assign to C(i,j)
3168     GrB_Index i,                        // row index
3169     GrB_Index j                         // column index
3170 ) ;
3171 
3172 GB_PUBLIC
3173 GrB_Info GrB_Matrix_setElement_UINT16   // C (i,j) = x
3174 (
3175     GrB_Matrix C,                       // matrix to modify
3176     uint16_t x,                         // scalar to assign to C(i,j)
3177     GrB_Index i,                        // row index
3178     GrB_Index j                         // column index
3179 ) ;
3180 
3181 GB_PUBLIC
3182 GrB_Info GrB_Matrix_setElement_INT32    // C (i,j) = x
3183 (
3184     GrB_Matrix C,                       // matrix to modify
3185     int32_t x,                          // scalar to assign to C(i,j)
3186     GrB_Index i,                        // row index
3187     GrB_Index j                         // column index
3188 ) ;
3189 
3190 GB_PUBLIC
3191 GrB_Info GrB_Matrix_setElement_UINT32   // C (i,j) = x
3192 (
3193     GrB_Matrix C,                       // matrix to modify
3194     uint32_t x,                         // scalar to assign to C(i,j)
3195     GrB_Index i,                        // row index
3196     GrB_Index j                         // column index
3197 ) ;
3198 
3199 GB_PUBLIC
3200 GrB_Info GrB_Matrix_setElement_INT64    // C (i,j) = x
3201 (
3202     GrB_Matrix C,                       // matrix to modify
3203     int64_t x,                          // scalar to assign to C(i,j)
3204     GrB_Index i,                        // row index
3205     GrB_Index j                         // column index
3206 ) ;
3207 
3208 GB_PUBLIC
3209 GrB_Info GrB_Matrix_setElement_UINT64   // C (i,j) = x
3210 (
3211     GrB_Matrix C,                       // matrix to modify
3212     uint64_t x,                         // scalar to assign to C(i,j)
3213     GrB_Index i,                        // row index
3214     GrB_Index j                         // column index
3215 ) ;
3216 
3217 GB_PUBLIC
3218 GrB_Info GrB_Matrix_setElement_FP32     // C (i,j) = x
3219 (
3220     GrB_Matrix C,                       // matrix to modify
3221     float x,                            // scalar to assign to C(i,j)
3222     GrB_Index i,                        // row index
3223     GrB_Index j                         // column index
3224 ) ;
3225 
3226 GB_PUBLIC
3227 GrB_Info GrB_Matrix_setElement_FP64     // C (i,j) = x
3228 (
3229     GrB_Matrix C,                       // matrix to modify
3230     double x,                           // scalar to assign to C(i,j)
3231     GrB_Index i,                        // row index
3232     GrB_Index j                         // column index
3233 ) ;
3234 
3235 GB_PUBLIC
3236 GrB_Info GxB_Matrix_setElement_FC32     // C (i,j) = x
3237 (
3238     GrB_Matrix C,                       // matrix to modify
3239     GxB_FC32_t x,                       // scalar to assign to C(i,j)
3240     GrB_Index i,                        // row index
3241     GrB_Index j                         // column index
3242 ) ;
3243 
3244 GB_PUBLIC
3245 GrB_Info GxB_Matrix_setElement_FC64     // C (i,j) = x
3246 (
3247     GrB_Matrix C,                       // matrix to modify
3248     GxB_FC64_t x,                       // scalar to assign to C(i,j)
3249     GrB_Index i,                        // row index
3250     GrB_Index j                         // column index
3251 ) ;
3252 
3253 GB_PUBLIC
3254 GrB_Info GrB_Matrix_setElement_UDT      // C (i,j) = x
3255 (
3256     GrB_Matrix C,                       // matrix to modify
3257     void *x,                            // scalar to assign to C(i,j)
3258     GrB_Index i,                        // row index
3259     GrB_Index j                         // column index
3260 ) ;
3261 
3262 // Type-generic version:  x can be any supported C type or void * for a
3263 // user-defined type.
3264 
3265 /*
3266 
3267 GB_PUBLIC
3268 GrB_Info GrB_Matrix_setElement          // C (i,j) = x
3269 (
3270     GrB_Matrix C,                       // matrix to modify
3271     <type> x,                           // scalar to assign to C(i,j)
3272     GrB_Index i,                        // row index
3273     GrB_Index j                         // column index
3274 ) ;
3275 
3276 */
3277 
3278 #if GxB_STDC_VERSION >= 201112L
3279 #define GrB_Matrix_setElement(C,x,i,j)                      \
3280     _Generic ((x), GB_CASES (, GrB, Matrix_setElement)) (C, x, i, j)
3281 #endif
3282 
3283 //------------------------------------------------------------------------------
3284 // GrB_Matrix_extractElement
3285 //------------------------------------------------------------------------------
3286 
3287 // Extract a single entry from a matrix, x = A(i,j), typecasting from the type
3288 // of A to the type of x, as needed.
3289 
3290 GB_PUBLIC
3291 GrB_Info GrB_Matrix_extractElement_BOOL     // x = A(i,j)
3292 (
3293     bool *x,                            // extracted scalar
3294     const GrB_Matrix A,                 // matrix to extract a scalar from
3295     GrB_Index i,                        // row index
3296     GrB_Index j                         // column index
3297 ) ;
3298 
3299 GB_PUBLIC
3300 GrB_Info GrB_Matrix_extractElement_INT8     // x = A(i,j)
3301 (
3302     int8_t *x,                          // extracted scalar
3303     const GrB_Matrix A,                 // matrix to extract a scalar from
3304     GrB_Index i,                        // row index
3305     GrB_Index j                         // column index
3306 ) ;
3307 
3308 GB_PUBLIC
3309 GrB_Info GrB_Matrix_extractElement_UINT8    // x = A(i,j)
3310 (
3311     uint8_t *x,                         // extracted scalar
3312     const GrB_Matrix A,                 // matrix to extract a scalar from
3313     GrB_Index i,                        // row index
3314     GrB_Index j                         // column index
3315 ) ;
3316 
3317 GB_PUBLIC
3318 GrB_Info GrB_Matrix_extractElement_INT16    // x = A(i,j)
3319 (
3320     int16_t *x,                         // extracted scalar
3321     const GrB_Matrix A,                 // matrix to extract a scalar from
3322     GrB_Index i,                        // row index
3323     GrB_Index j                         // column index
3324 ) ;
3325 
3326 GB_PUBLIC
3327 GrB_Info GrB_Matrix_extractElement_UINT16   // x = A(i,j)
3328 (
3329     uint16_t *x,                        // extracted scalar
3330     const GrB_Matrix A,                 // matrix to extract a scalar from
3331     GrB_Index i,                        // row index
3332     GrB_Index j                         // column index
3333 ) ;
3334 
3335 GB_PUBLIC
3336 GrB_Info GrB_Matrix_extractElement_INT32    // x = A(i,j)
3337 (
3338     int32_t *x,                         // extracted scalar
3339     const GrB_Matrix A,                 // matrix to extract a scalar from
3340     GrB_Index i,                        // row index
3341     GrB_Index j                         // column index
3342 ) ;
3343 
3344 GB_PUBLIC
3345 GrB_Info GrB_Matrix_extractElement_UINT32   // x = A(i,j)
3346 (
3347     uint32_t *x,                        // extracted scalar
3348     const GrB_Matrix A,                 // matrix to extract a scalar from
3349     GrB_Index i,                        // row index
3350     GrB_Index j                         // column index
3351 ) ;
3352 
3353 GB_PUBLIC
3354 GrB_Info GrB_Matrix_extractElement_INT64    // x = A(i,j)
3355 (
3356     int64_t *x,                         // extracted scalar
3357     const GrB_Matrix A,                 // matrix to extract a scalar from
3358     GrB_Index i,                        // row index
3359     GrB_Index j                         // column index
3360 ) ;
3361 
3362 GB_PUBLIC
3363 GrB_Info GrB_Matrix_extractElement_UINT64   // x = A(i,j)
3364 (
3365     uint64_t *x,                        // extracted scalar
3366     const GrB_Matrix A,                 // matrix to extract a scalar from
3367     GrB_Index i,                        // row index
3368     GrB_Index j                         // column index
3369 ) ;
3370 
3371 GB_PUBLIC
3372 GrB_Info GrB_Matrix_extractElement_FP32     // x = A(i,j)
3373 (
3374     float *x,                           // extracted scalar
3375     const GrB_Matrix A,                 // matrix to extract a scalar from
3376     GrB_Index i,                        // row index
3377     GrB_Index j                         // column index
3378 ) ;
3379 
3380 GB_PUBLIC
3381 GrB_Info GrB_Matrix_extractElement_FP64     // x = A(i,j)
3382 (
3383     double *x,                          // extracted scalar
3384     const GrB_Matrix A,                 // matrix to extract a scalar from
3385     GrB_Index i,                        // row index
3386     GrB_Index j                         // column index
3387 ) ;
3388 
3389 GB_PUBLIC
3390 GrB_Info GxB_Matrix_extractElement_FC32     // x = A(i,j)
3391 (
3392     GxB_FC32_t *x,                      // extracted scalar
3393     const GrB_Matrix A,                 // matrix to extract a scalar from
3394     GrB_Index i,                        // row index
3395     GrB_Index j                         // column index
3396 ) ;
3397 
3398 GB_PUBLIC
3399 GrB_Info GxB_Matrix_extractElement_FC64     // x = A(i,j)
3400 (
3401     GxB_FC64_t *x,                      // extracted scalar
3402     const GrB_Matrix A,                 // matrix to extract a scalar from
3403     GrB_Index i,                        // row index
3404     GrB_Index j                         // column index
3405 ) ;
3406 
3407 GB_PUBLIC
3408 GrB_Info GrB_Matrix_extractElement_UDT      // x = A(i,j)
3409 (
3410     void *x,                            // extracted scalar
3411     const GrB_Matrix A,                 // matrix to extract a scalar from
3412     GrB_Index i,                        // row index
3413     GrB_Index j                         // column index
3414 ) ;
3415 
3416 // Type-generic version:  x can be a pointer to any supported C type or void *
3417 // for a user-defined type.
3418 
3419 /*
3420 
3421 GB_PUBLIC
3422 GrB_Info GrB_Matrix_extractElement      // x = A(i,j)
3423 (
3424     <type> *x,                          // extracted scalar
3425     const GrB_Matrix A,                 // matrix to extract a scalar from
3426     GrB_Index i,                        // row index
3427     GrB_Index j                         // column index
3428 ) ;
3429 
3430 */
3431 
3432 #if GxB_STDC_VERSION >= 201112L
3433 #define GrB_Matrix_extractElement(x,A,i,j)  \
3434     _Generic ((x), GB_CASES (*, GrB, Matrix_extractElement)) (x, A, i, j)
3435 #endif
3436 
3437 //------------------------------------------------------------------------------
3438 // GrB_Matrix_removeElement
3439 //------------------------------------------------------------------------------
3440 
3441 // GrB_Matrix_removeElement (A,i,j) removes the entry A(i,j) from the matrix A.
3442 
3443 GB_PUBLIC
3444 GrB_Info GrB_Matrix_removeElement
3445 (
3446     GrB_Matrix C,                   // matrix to remove entry from
3447     GrB_Index i,                    // row index
3448     GrB_Index j                     // column index
3449 ) ;
3450 
3451 //------------------------------------------------------------------------------
3452 // GrB_Matrix_extractTuples
3453 //------------------------------------------------------------------------------
3454 
3455 // Extracts all tuples from a matrix, like [I,J,X] = find (A) in MATLAB.  If
3456 // any parameter I, J and/or X is NULL, then that component is not extracted.
3457 // For example, to extract just the row and col indices, pass I and J as
3458 // non-NULL, and X as NULL.  This is like [I,J,~] = find (A).
3459 
3460 GB_PUBLIC
3461 GrB_Info GrB_Matrix_extractTuples_BOOL      // [I,J,X] = find (A)
3462 (
3463     GrB_Index *I,               // array for returning row indices of tuples
3464     GrB_Index *J,               // array for returning col indices of tuples
3465     bool *X,                    // array for returning values of tuples
3466     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3467     const GrB_Matrix A          // matrix to extract tuples from
3468 ) ;
3469 
3470 GB_PUBLIC
3471 GrB_Info GrB_Matrix_extractTuples_INT8      // [I,J,X] = find (A)
3472 (
3473     GrB_Index *I,               // array for returning row indices of tuples
3474     GrB_Index *J,               // array for returning col indices of tuples
3475     int8_t *X,                  // array for returning values of tuples
3476     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3477     const GrB_Matrix A          // matrix to extract tuples from
3478 ) ;
3479 
3480 GB_PUBLIC
3481 GrB_Info GrB_Matrix_extractTuples_UINT8     // [I,J,X] = find (A)
3482 (
3483     GrB_Index *I,               // array for returning row indices of tuples
3484     GrB_Index *J,               // array for returning col indices of tuples
3485     uint8_t *X,                 // array for returning values of tuples
3486     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3487     const GrB_Matrix A          // matrix to extract tuples from
3488 ) ;
3489 
3490 GB_PUBLIC
3491 GrB_Info GrB_Matrix_extractTuples_INT16     // [I,J,X] = find (A)
3492 (
3493     GrB_Index *I,               // array for returning row indices of tuples
3494     GrB_Index *J,               // array for returning col indices of tuples
3495     int16_t *X,                 // array for returning values of tuples
3496     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3497     const GrB_Matrix A          // matrix to extract tuples from
3498 ) ;
3499 
3500 GB_PUBLIC
3501 GrB_Info GrB_Matrix_extractTuples_UINT16    // [I,J,X] = find (A)
3502 (
3503     GrB_Index *I,               // array for returning row indices of tuples
3504     GrB_Index *J,               // array for returning col indices of tuples
3505     uint16_t *X,                // array for returning values of tuples
3506     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3507     const GrB_Matrix A          // matrix to extract tuples from
3508 ) ;
3509 
3510 GB_PUBLIC
3511 GrB_Info GrB_Matrix_extractTuples_INT32     // [I,J,X] = find (A)
3512 (
3513     GrB_Index *I,               // array for returning row indices of tuples
3514     GrB_Index *J,               // array for returning col indices of tuples
3515     int32_t *X,                 // array for returning values of tuples
3516     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3517     const GrB_Matrix A          // matrix to extract tuples from
3518 ) ;
3519 
3520 GB_PUBLIC
3521 GrB_Info GrB_Matrix_extractTuples_UINT32    // [I,J,X] = find (A)
3522 (
3523     GrB_Index *I,               // array for returning row indices of tuples
3524     GrB_Index *J,               // array for returning col indices of tuples
3525     uint32_t *X,                // array for returning values of tuples
3526     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3527     const GrB_Matrix A          // matrix to extract tuples from
3528 ) ;
3529 
3530 GB_PUBLIC
3531 GrB_Info GrB_Matrix_extractTuples_INT64     // [I,J,X] = find (A)
3532 (
3533     GrB_Index *I,               // array for returning row indices of tuples
3534     GrB_Index *J,               // array for returning col indices of tuples
3535     int64_t *X,                 // array for returning values of tuples
3536     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3537     const GrB_Matrix A          // matrix to extract tuples from
3538 ) ;
3539 
3540 GB_PUBLIC
3541 GrB_Info GrB_Matrix_extractTuples_UINT64    // [I,J,X] = find (A)
3542 (
3543     GrB_Index *I,               // array for returning row indices of tuples
3544     GrB_Index *J,               // array for returning col indices of tuples
3545     uint64_t *X,                // array for returning values of tuples
3546     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3547     const GrB_Matrix A          // matrix to extract tuples from
3548 ) ;
3549 
3550 GB_PUBLIC
3551 GrB_Info GrB_Matrix_extractTuples_FP32      // [I,J,X] = find (A)
3552 (
3553     GrB_Index *I,               // array for returning row indices of tuples
3554     GrB_Index *J,               // array for returning col indices of tuples
3555     float *X,                   // array for returning values of tuples
3556     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3557     const GrB_Matrix A          // matrix to extract tuples from
3558 ) ;
3559 
3560 GB_PUBLIC
3561 GrB_Info GrB_Matrix_extractTuples_FP64      // [I,J,X] = find (A)
3562 (
3563     GrB_Index *I,               // array for returning row indices of tuples
3564     GrB_Index *J,               // array for returning col indices of tuples
3565     double *X,                  // array for returning values of tuples
3566     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3567     const GrB_Matrix A          // matrix to extract tuples from
3568 ) ;
3569 
3570 GB_PUBLIC
3571 GrB_Info GxB_Matrix_extractTuples_FC32      // [I,J,X] = find (A)
3572 (
3573     GrB_Index *I,               // array for returning row indices of tuples
3574     GrB_Index *J,               // array for returning col indices of tuples
3575     GxB_FC32_t *X,              // array for returning values of tuples
3576     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3577     const GrB_Matrix A          // matrix to extract tuples from
3578 ) ;
3579 
3580 GB_PUBLIC
3581 GrB_Info GxB_Matrix_extractTuples_FC64      // [I,J,X] = find (A)
3582 (
3583     GrB_Index *I,               // array for returning row indices of tuples
3584     GrB_Index *J,               // array for returning col indices of tuples
3585     GxB_FC64_t *X,              // array for returning values of tuples
3586     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3587     const GrB_Matrix A          // matrix to extract tuples from
3588 ) ;
3589 
3590 GB_PUBLIC
3591 GrB_Info GrB_Matrix_extractTuples_UDT       // [I,J,X] = find (A)
3592 (
3593     GrB_Index *I,               // array for returning row indices of tuples
3594     GrB_Index *J,               // array for returning col indices of tuples
3595     void *X,                    // array for returning values of tuples
3596     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3597     const GrB_Matrix A          // matrix to extract tuples from
3598 ) ;
3599 
3600 // Type-generic version:  X can be a pointer to any supported C type or void *
3601 // for a user-defined type.
3602 
3603 /*
3604 
3605 GB_PUBLIC
3606 GrB_Info GrB_Matrix_extractTuples           // [I,J,X] = find (A)
3607 (
3608     GrB_Index *I,               // array for returning row indices of tuples
3609     GrB_Index *J,               // array for returning col indices of tuples
3610     <type> *X,                  // array for returning values of tuples
3611     GrB_Index *nvals,           // I,J,X size on input; # tuples on output
3612     const GrB_Matrix A          // matrix to extract tuples from
3613 ) ;
3614 
3615 */
3616 
3617 #if GxB_STDC_VERSION >= 201112L
3618 #define GrB_Matrix_extractTuples(I,J,X,nvals,A) \
3619     _Generic ((X), GB_CASES (*, GrB, Matrix_extractTuples)) (I, J, X, nvals, A)
3620 #endif
3621 
3622 //------------------------------------------------------------------------------
3623 // GxB_Matrix_concat and GxB_Matrix_split
3624 //------------------------------------------------------------------------------
3625 
3626 // GxB_Matrix_concat concatenates an array of matrices (Tiles) into a single
3627 // GrB_Matrix C.
3628 
3629 // Tiles is an m-by-n dense array of matrices held in row-major format, where
3630 // Tiles [i*n+j] is the (i,j)th tile, and where m > 0 and n > 0 must hold.  Let
3631 // A{i,j} denote the (i,j)th tile.  The matrix C is constructed by
3632 // concatenating these tiles together, as:
3633 
3634 //  C = [ A{0,0}   A{0,1}   A{0,2}   ... A{0,n-1}
3635 //        A{1,0}   A{1,1}   A{1,2}   ... A{1,n-1}
3636 //        ...
3637 //        A{m-1,0} A{m-1,1} A{m-1,2} ... A{m-1,n-1} ]
3638 
3639 // On input, the matrix C must already exist.  Any existing entries in C are
3640 // discarded.  C must have dimensions nrows by ncols where nrows is the sum of
3641 // # of rows in the matrices A{i,0} for all i, and ncols is the sum of the # of
3642 // columns in the matrices A{0,j} for all j.  All matrices in any given tile
3643 // row i must have the same number of rows (that is, nrows(A{i,0}) must equal
3644 // nrows(A{i,j}) for all j), and all matrices in any given tile column j must
3645 // have the same number of columns (that is, ncols(A{0,j}) must equal
3646 // ncols(A{i,j}) for all i).
3647 
3648 // The type of C is unchanged, and all matrices A{i,j} are typecasted into the
3649 // type of C.  Any settings made to C by GxB_Matrix_Option_set (format by row
3650 // or by column, bitmap switch, hyper switch, and sparsity control) are
3651 // unchanged.
3652 
3653 GB_PUBLIC
3654 GrB_Info GxB_Matrix_concat          // concatenate a 2D array of matrices
3655 (
3656     GrB_Matrix C,                   // input/output matrix for results
3657     const GrB_Matrix *Tiles,        // 2D row-major array of size m-by-n
3658     const GrB_Index m,
3659     const GrB_Index n,
3660     const GrB_Descriptor desc       // unused, except threading control
3661 ) ;
3662 
3663 // GxB_Matrix_split does the opposite of GxB_Matrix_concat.  It splits a single
3664 // input matrix A into a 2D array of tiles.  On input, the Tiles array must be
3665 // a non-NULL pointer to a previously allocated array of size at least m*n
3666 // where both m and n must be > 0.  The Tiles_nrows array has size m, and
3667 // Tiles_ncols has size n.  The (i,j)th tile has dimension
3668 // Tiles_nrows[i]-by-Tiles_ncols[j].  The sum of Tiles_nrows [0:m-1] must equal
3669 // the number of rows of A, and the sum of Tiles_ncols [0:n-1] must equal the
3670 // number of columns of A.  The type of each tile is the same as the type of A;
3671 // no typecasting is done.
3672 
3673 GB_PUBLIC
3674 GrB_Info GxB_Matrix_split           // split a matrix into 2D array of matrices
3675 (
3676     GrB_Matrix *Tiles,              // 2D row-major array of size m-by-n
3677     const GrB_Index m,
3678     const GrB_Index n,
3679     const GrB_Index *Tile_nrows,    // array of size m
3680     const GrB_Index *Tile_ncols,    // array of size n
3681     const GrB_Matrix A,             // input matrix to split
3682     const GrB_Descriptor desc       // unused, except threading control
3683 ) ;
3684 
3685 //------------------------------------------------------------------------------
3686 // GxB_Matrix_diag and GxB_Vector_diag
3687 //------------------------------------------------------------------------------
3688 
3689 // GxB_Matrix_diag constructs a matrix from a vector.  Let n be the length of
3690 // the v vector, from GrB_Vector_size (&n, v).  If k = 0, then C is an n-by-n
3691 // diagonal matrix with the entries from v along the main diagonal of C, with
3692 // C(i,i) = v(i).  If k is nonzero, C is square with dimension n+abs(k).  If k
3693 // is positive, it denotes diagonals above the main diagonal, with C(i,i+k) =
3694 // v(i).  If k is negative, it denotes diagonals below the main diagonal of C,
3695 // with C(i-k,i) = v(i).  This behavior is identical to the MATLAB statement
3696 // C = diag(v,k), where v is a vector, except that GxB_Matrix_diag can also
3697 // do typecasting.
3698 
3699 // C must already exist on input, of the correct size.  Any existing entries in
3700 // C are discarded.  The type of C is preserved, so that if the type of C and v
3701 // differ, the entries are typecasted into the type of C.  Any settings made to
3702 // C by GxB_Matrix_Option_set (format by row or by column, bitmap switch, hyper
3703 // switch, and sparsity control) are unchanged.
3704 
3705 GB_PUBLIC
3706 GrB_Info GxB_Matrix_diag    // construct a diagonal matrix from a vector
3707 (
3708     GrB_Matrix C,                   // output matrix
3709     const GrB_Vector v,             // input vector
3710     int64_t k,
3711     const GrB_Descriptor desc       // unused, except threading control
3712 ) ;
3713 
3714 // GxB_Vector_diag extracts a vector v from an input matrix A, which may be
3715 // rectangular.  If k = 0, the main diagonal of A is extracted; k > 0 denotes
3716 // diagonals above the main diagonal of A, and k < 0 denotes diagonals below
3717 // the main diagonal of A.  Let A have dimension m-by-n.  If k is in the range
3718 // 0 to n-1, then v has length min(m,n-k).  If k is negative and in the range
3719 // -1 to -m+1, then v has length min(m+k,n).  If k is outside these ranges,
3720 // v has length 0 (this is not an error).  This function computes the same
3721 // thing as the MATLAB statement v = diag(A,k) when A is a matrix, except that
3722 // GxB_Vector_diag can also do typecasting.
3723 
3724 // v must already exist on input, of the correct length; that is
3725 // GrB_Vector_size (&len,v) must return len = 0 if k >= n or k <= -m, len =
3726 // min(m,n-k) if k is in the range 0 to n-1, and len = min(m+k,n) if k is in
3727 // the range -1 to -m+1.  Any existing entries in v are discarded.  The type of
3728 // v is preserved, so that if the type of A and v differ, the entries are
3729 // typecasted into the type of v.  Any settings made to v by
3730 // GxB_Vector_Option_set (bitmap switch and sparsity control) are unchanged.
3731 
3732 GB_PUBLIC
3733 GrB_Info GxB_Vector_diag    // extract a diagonal from a matrix, as a vector
3734 (
3735     GrB_Vector v,                   // output vector
3736     const GrB_Matrix A,             // input matrix
3737     int64_t k,
3738     const GrB_Descriptor desc       // unused, except threading control
3739 ) ;
3740 
3741 //==============================================================================
3742 // SuiteSparse:GraphBLAS options
3743 //==============================================================================
3744 
3745 // The following options modify how SuiteSparse:GraphBLAS stores and operates
3746 // on its matrices.  The GxB_*Option* methods allow the user to suggest how the
3747 // internal representation of a matrix, or all matrices, should be held.  These
3748 // options have no effect on the result (except for minor roundoff differences
3749 // for floating-point types). They only affect the time and memory usage of the
3750 // computations.
3751 
3752 //      GxB_Matrix_Option_set:  sets an option for a specific matrix
3753 //      GxB_Matrix_Option_get:  queries the current option of a specific matrix
3754 //      GxB_Vector_Option_set:  sets an option for a specific vector
3755 //      GxB_Vector_Option_get:  queries the current option of a specific vector
3756 //      GxB_Global_Option_set:  sets an option for all future matrices
3757 //      GxB_Global_Option_get:  queries current option for all future matrices
3758 
3759 #define GxB_HYPER 0     // (historical, use GxB_HYPER_SWITCH)
3760 
3761 typedef enum            // for global options or matrix options
3762 {
3763 
3764     //------------------------------------------------------------
3765     // for GxB_Matrix_Option_get/set and GxB_Global_Option_get/set:
3766     //------------------------------------------------------------
3767 
3768     GxB_HYPER_SWITCH = 0,   // defines switch to hypersparse (a double value)
3769     GxB_BITMAP_SWITCH = 34, // defines switch to bitmap (a double value)
3770     GxB_FORMAT = 1,         // defines CSR/CSC format: GxB_BY_ROW or GxB_BY_COL
3771 
3772     //------------------------------------------------------------
3773     // for GxB_Global_Option_get only:
3774     //------------------------------------------------------------
3775 
3776     GxB_MODE = 2,       // mode passed to GrB_init (blocking or non-blocking)
3777     GxB_LIBRARY_NAME = 8,           // name of the library (char *)
3778     GxB_LIBRARY_VERSION = 9,        // library version (3 int's)
3779     GxB_LIBRARY_DATE = 10,          // date of the library (char *)
3780     GxB_LIBRARY_ABOUT = 11,         // about the library (char *)
3781     GxB_LIBRARY_URL = 12,           // URL for the library (char *)
3782     GxB_LIBRARY_LICENSE = 13,       // license of the library (char *)
3783     GxB_LIBRARY_COMPILE_DATE = 14,  // date library was compiled (char *)
3784     GxB_LIBRARY_COMPILE_TIME = 15,  // time library was compiled (char *)
3785     GxB_API_VERSION = 16,           // API version (3 int's)
3786     GxB_API_DATE = 17,              // date of the API (char *)
3787     GxB_API_ABOUT = 18,             // about the API (char *)
3788     GxB_API_URL = 19,               // URL for the API (char *)
3789 
3790     //------------------------------------------------------------
3791     // for GxB_Global_Option_get/set only:
3792     //------------------------------------------------------------
3793 
3794     GxB_GLOBAL_NTHREADS = GxB_NTHREADS,  // max number of threads to use
3795                         // If <= GxB_DEFAULT, then GraphBLAS selects the number
3796                         // of threads automatically.
3797 
3798     GxB_GLOBAL_CHUNK = GxB_CHUNK,       // chunk size for small problems.
3799                         // If <= GxB_DEFAULT, then the default is used.
3800 
3801     GxB_BURBLE = 99,    // diagnostic output (bool *)
3802     GxB_PRINTF = 101,   // printf function diagnostic output
3803     GxB_FLUSH = 102,    // flush function diagnostic output
3804     GxB_MEMORY_POOL = 103,  // memory pool control
3805 
3806     //------------------------------------------------------------
3807     // for GxB_Matrix_Option_get only:
3808     //------------------------------------------------------------
3809 
3810     GxB_SPARSITY_STATUS = 33,       // hyper, sparse, bitmap or full (1,2,4,8)
3811     GxB_IS_HYPER = 6,               // historical; use GxB_SPARSITY_STATUS
3812 
3813     //------------------------------------------------------------
3814     // for GxB_Matrix_Option_get/set only:
3815     //------------------------------------------------------------
3816 
3817     GxB_SPARSITY_CONTROL = 32,      // sparsity control: 0 to 15; see below
3818 
3819     //------------------------------------------------------------
3820     // GPU and options (DRAFT: do not use)
3821     //------------------------------------------------------------
3822 
3823     GxB_GLOBAL_GPU_CONTROL = GxB_GPU_CONTROL,
3824     GxB_GLOBAL_GPU_CHUNK   = GxB_GPU_CHUNK,
3825 
3826 } GxB_Option_Field ;
3827 
3828 // GxB_FORMAT can be by row or by column:
3829 typedef enum
3830 {
3831     GxB_BY_ROW = 0,     // CSR: compressed sparse row format
3832     GxB_BY_COL = 1,     // CSC: compressed sparse column format
3833     GxB_NO_FORMAT = -1  // format not defined
3834 }
3835 GxB_Format_Value ;
3836 
3837 // The default format is by column, just like MATLAB.  These constants are
3838 // defined as GB_PUBLIC const, so that if SuiteSparse:GraphBLAS is recompiled
3839 // with a different default format, and the application is relinked but not
3840 // recompiled, it will acquire the new default values.
3841 GB_PUBLIC const GxB_Format_Value GxB_FORMAT_DEFAULT ;
3842 
3843 // the default hyper_switch parameter
3844 GB_PUBLIC const double GxB_HYPER_DEFAULT ;
3845 
3846 // GxB_SPARSITY_CONTROL can be any sum or bitwise OR of these 4 values:
3847 #define GxB_HYPERSPARSE 1   // store matrix in hypersparse form
3848 #define GxB_SPARSE      2   // store matrix as sparse form (compressed vector)
3849 #define GxB_BITMAP      4   // store matrix as a bitmap
3850 #define GxB_FULL        8   // store matrix as full; all entries must be present
3851 
3852 // size of b array for GxB_set/get (GxB_BITMAP_SWITCH, b)
3853 #define GxB_NBITMAP_SWITCH 8    // size of bitmap_switch parameter array
3854 
3855 // any sparsity value:
3856 #define GxB_ANY_SPARSITY (GxB_HYPERSPARSE + GxB_SPARSE + GxB_BITMAP + GxB_FULL)
3857 
3858 // the default sparsity control is any format:
3859 #define GxB_AUTO_SPARSITY GxB_ANY_SPARSITY
3860 
3861 // GxB_Matrix_Option_set (A, GxB_SPARSITY_CONTROL, scontrol) provides hints
3862 // about which data structure GraphBLAS should use for the matrix A:
3863 //
3864 //      GxB_AUTO_SPARSITY: GraphBLAS selects automatically.
3865 //      GxB_HYPERSPARSE: always hypersparse, taking O(nvals(A)) space.
3866 //      GxB_SPARSE: always in a sparse struture: compressed-sparse row/column,
3867 //          taking O(nrows+nvals(A)) space if stored by row, or
3868 //          O(ncols+nvals(A)) if stored by column.
3869 //      GxB_BITMAP: always in a bitmap struture, taking O(nrows*ncols) space.
3870 //      GxB_FULL: always in a full structure, taking O(nrows*ncols) space,
3871 //          unless not all entries are present, in which case the bitmap
3872 //          storage is used.
3873 //
3874 // These options can be summed.  For example, to allow a matrix to be sparse
3875 // or hypersparse, but not bitmap or full, use GxB_SPARSE + GxB_HYPERSPARSE.
3876 // Since GxB_FULL can only be used when all entries are present, matrices with
3877 // the just GxB_FULL control setting are stored in bitmap form if any entries
3878 // are not present.
3879 //
3880 // Only the least 4 bits of the sparsity control are considered, so the
3881 // formats can be bitwise negated.  For example, to allow for any format
3882 // except full, use ~GxB_FULL.
3883 //
3884 // GxB_Matrix_Option_get (A, GxB_SPARSITY_STATUS, &sparsity) returns the
3885 // current data structure currently used for the matrix A (either hypersparse,
3886 // sparse, bitmap, or full).
3887 //
3888 // GxB_Matrix_Option_get (A, GxB_SPARSITY_CONTROL, &scontrol) returns the hint
3889 // for how A should be stored (hypersparse, sparse, bitmap, or full, or any
3890 // combination).
3891 
3892 // GxB_HYPER_SWITCH:
3893 //      If the matrix or vector structure can be sparse or hypersparse, the
3894 //      GxB_HYPER_SWITCH parameter controls when each of these structures are
3895 //      used.  The parameter is not used if the matrix or vector is full or
3896 //      bitmap.
3897 //
3898 //      Let k be the actual number of non-empty vectors (with at least one
3899 //      entry).  This value k is not dependent on whether or not the matrix is
3900 //      stored in hypersparse structure.  Let n be the number of vectors (the #
3901 //      of columns if CSC, or rows if CSR).  Let h be the value of the
3902 //      GxB_HYPER_SWITCH setting of the matrix.
3903 //
3904 //      If a matrix is currently hypersparse, it can be converted to
3905 //      non-hypersparse if (n <= 1  || k > 2*n*h).  Otherwise it stays
3906 //      hypersparse.  If (n <= 1) the matrix is always stored as
3907 //      non-hypersparse.
3908 //
3909 //      If currently non-hypersparse, it can be converted to hypersparse if (n
3910 //      > 1 && k <= n*h).  Otherwise, it stays non-hypersparse.  If (n <= 1)
3911 //      the matrix always remains non-hypersparse.
3912 //
3913 //      Setting GxB_HYPER_SWITCH to GxB_ALWAYS_HYPER or GxB_NEVER_HYPER ensures
3914 //      a matrix always stays hypersparse, or always stays non-hypersparse,
3915 //      respectively.
3916 
3917 GB_PUBLIC const double GxB_ALWAYS_HYPER, GxB_NEVER_HYPER ;
3918 
3919 GB_PUBLIC
3920 GrB_Info GxB_Matrix_Option_set      // set an option in a matrix
3921 (
3922     GrB_Matrix A,                   // matrix to modify
3923     GxB_Option_Field field,         // option to change
3924     ...                             // value to change it to
3925 ) ;
3926 
3927 GB_PUBLIC
3928 GrB_Info GxB_Matrix_Option_get      // gets the current option of a matrix
3929 (
3930     GrB_Matrix A,                   // matrix to query
3931     GxB_Option_Field field,         // option to query
3932     ...                             // return value of the matrix option
3933 ) ;
3934 
3935 GB_PUBLIC
3936 GrB_Info GxB_Vector_Option_set      // set an option in a vector
3937 (
3938     GrB_Vector A,                   // vector to modify
3939     GxB_Option_Field field,         // option to change
3940     ...                             // value to change it to
3941 ) ;
3942 
3943 GB_PUBLIC
3944 GrB_Info GxB_Vector_Option_get      // gets the current option of a vector
3945 (
3946     GrB_Vector A,                   // vector to query
3947     GxB_Option_Field field,         // option to query
3948     ...                             // return value of the vector option
3949 ) ;
3950 
3951 // GxB_Global_Option_set controls the global defaults used when a new matrix is
3952 // created.  GrB_init defines the following initial settings:
3953 //
3954 //      GxB_Global_Option_set (GxB_HYPER_SWITCH, GxB_HYPER_DEFAULT) ;
3955 //      GxB_Global_Option_set (GxB_BITMAP_SWITCH, NULL) ;
3956 //      GxB_Global_Option_set (GxB_FORMAT, GxB_FORMAT_DEFAULT) ;
3957 //
3958 // The compile-time constants GxB_HYPER_DEFAULT and GxB_FORMAT_DEFAULT are
3959 // equal to 0.0625 and GxB_BY_ROW, by default.  That is, by default, all new
3960 // matrices are held by row in CSR format.  If a matrix has fewer than n/16
3961 // columns, it can be converted to hypersparse structure.  If it has more than
3962 // n/8 columns, it can be converted to a sparse structure.  Modifying these
3963 // global settings via GxB_Global_Option_set has no effect on matrices already
3964 // created.
3965 
3966 GB_PUBLIC
3967 GrB_Info GxB_Global_Option_set      // set a global default option
3968 (
3969     GxB_Option_Field field,         // option to change
3970     ...                             // value to change it to
3971 ) ;
3972 
3973 GB_PUBLIC
3974 GrB_Info GxB_Global_Option_get      // gets the current global default option
3975 (
3976     GxB_Option_Field field,         // option to query
3977     ...                             // return value of the global option
3978 ) ;
3979 
3980 //------------------------------------------------------------------------------
3981 // GxB_set and GxB_get
3982 //------------------------------------------------------------------------------
3983 
3984 // The simplest way to set/get a value of a GrB_Descriptor is with
3985 // the generic GxB_set and GxB_get functions:
3986 
3987 //      GxB_set (desc, field, value) ;
3988 //      GxB_get (desc, field, &value) ;
3989 
3990 // GxB_set and GxB_get are generic methods that and set or query the options in
3991 // a GrB_Matrix, a GrB_Descriptor, or in the global options.  They can be used
3992 // with the following syntax.  Note that GxB_NTHREADS can be used for both the
3993 // global nthreads_max, and for the # of threads in the descriptor.
3994 
3995 // To set/get the global options:
3996 //
3997 //      GxB_set (GxB_HYPER_SWITCH, double h) ;
3998 //      GxB_set (GxB_HYPER_SWITCH, GxB_ALWAYS_HYPER) ;
3999 //      GxB_set (GxB_HYPER_SWITCH, GxB_NEVER_HYPER) ;
4000 //      GxB_get (GxB_HYPER_SWITCH, double *h) ;
4001 //
4002 //      double b [GxB_NBITMAP_SWITCH] ;
4003 //      GxB_set (GxB_BITMAP_SWITCH, b) ;
4004 //      GxB_set (GxB_BITMAP_SWITCH, NULL) ;     // set defaults
4005 //      GxB_get (GxB_BITMAP_SWITCH, b) ;
4006 //
4007 //      GxB_set (GxB_FORMAT, GxB_BY_ROW) ;
4008 //      GxB_set (GxB_FORMAT, GxB_BY_COL) ;
4009 //      GxB_get (GxB_FORMAT, GxB_Format_Value *s) ;
4010 //
4011 //      GxB_set (GxB_NTHREADS, nthreads_max) ;
4012 //      GxB_get (GxB_NTHREADS, int *nthreads_max) ;
4013 //
4014 //      GxB_set (GxB_CHUNK, double chunk) ;
4015 //      GxB_get (GxB_CHUNK, double *chunk) ;
4016 //
4017 //      GxB_set (GxB_BURBLE, bool burble) ;
4018 //      GxB_get (GxB_BURBLE, bool *burble) ;
4019 //
4020 //      GxB_set (GxB_PRINTF, void *printf_function) ;
4021 //      GxB_get (GxB_PRINTF, void **printf_function) ;
4022 //
4023 //      GxB_set (GxB_FLUSH, void *flush_function) ;
4024 //      GxB_get (GxB_FLUSH, void **flush_function) ;
4025 //
4026 //      int64_t free_pool_limit [64] ;
4027 //      GxB_set (GxB_MEMORY_POOL, free_pool_limit) ;
4028 //      GxB_set (GxB_MEMORY_POOL, NULL) ;     // set defaults
4029 //      GxB_get (GxB_MEMORY_POOL, free_pool_limit) ;
4030 
4031 // To get global options that can be queried but not modified:
4032 //
4033 //      GxB_get (GxB_MODE, GrB_Mode *mode) ;
4034 
4035 // To set/get a matrix option:
4036 //
4037 //      GxB_set (GrB_Matrix A, GxB_HYPER_SWITCH, double h) ;
4038 //      GxB_set (GrB_Matrix A, GxB_HYPER_SWITCH, GxB_ALWAYS_HYPER) ;
4039 //      GxB_set (GrB_Matrix A, GxB_HYPER_SWITCH, GxB_NEVER_HYPER) ;
4040 //      GxB_get (GrB_Matrix A, GxB_HYPER_SWITCH, double *h) ;
4041 //
4042 //      GxB_set (GrB_Matrix A, GxB_BITMAP_SWITCH, double b) ;
4043 //      GxB_get (GrB_Matrix A, GxB_BITMAP_SWITCH, double *b) ;
4044 //
4045 //      GxB_set (GrB_Matrix A, GxB_FORMAT, GxB_BY_ROW) ;
4046 //      GxB_set (GrB_Matrix A, GxB_FORMAT, GxB_BY_COL) ;
4047 //      GxB_get (GrB_Matrix A, GxB_FORMAT, GxB_Format_Value *s) ;
4048 //
4049 //      GxB_set (GrB_Matrix A, GxB_SPARSITY_CONTROL, GxB_AUTO_SPARSITY) ;
4050 //      GxB_set (GrB_Matrix A, GxB_SPARSITY_CONTROL, scontrol) ;
4051 //      GxB_get (GrB_Matrix A, GxB_SPARSITY_CONTROL, int *scontrol) ;
4052 //
4053 //      GxB_get (GrB_Matrix A, GxB_SPARSITY_STATUS, int *sparsity) ;
4054 
4055 // To set/get a vector option or status:
4056 //
4057 //      GxB_set (GrB_Vector v, GxB_BITMAP_SWITCH, double b) ;
4058 //      GxB_get (GrB_Vector v, GxB_BITMAP_SWITCH, double *b) ;
4059 //
4060 //      GxB_set (GrB_Vector v, GxB_FORMAT, GxB_BY_ROW) ;
4061 //      GxB_set (GrB_Vector v, GxB_FORMAT, GxB_BY_COL) ;
4062 //      GxB_get (GrB_Vector v, GxB_FORMAT, GxB_Format_Value *s) ;
4063 //
4064 //      GxB_set (GrB_Vector v, GxB_SPARSITY_CONTROL, GxB_AUTO_SPARSITY) ;
4065 //      GxB_set (GrB_Vector v, GxB_SPARSITY_CONTROL, scontrol) ;
4066 //      GxB_get (GrB_Vector v, GxB_SPARSITY_CONTROL, int *scontrol) ;
4067 //
4068 //      GxB_get (GrB_Vector v, GxB_SPARSITY_STATUS, int *sparsity) ;
4069 
4070 // To set/get a descriptor field:
4071 //
4072 //      GxB_set (GrB_Descriptor d, GrB_OUTP, GxB_DEFAULT) ;
4073 //      GxB_set (GrB_Descriptor d, GrB_OUTP, GrB_REPLACE) ;
4074 //      GxB_get (GrB_Descriptor d, GrB_OUTP, GrB_Desc_Value *v) ;
4075 //
4076 //      GxB_set (GrB_Descriptor d, GrB_MASK, GxB_DEFAULT) ;
4077 //      GxB_set (GrB_Descriptor d, GrB_MASK, GrB_COMP) ;
4078 //      GxB_set (GrB_Descriptor d, GrB_MASK, GrB_STRUCTURE) ;
4079 //      GxB_set (GrB_Descriptor d, GrB_MASK, GrB_COMP + GrB_STRUCTURE) ;
4080 //      GxB_get (GrB_Descriptor d, GrB_MASK, GrB_Desc_Value *v) ;
4081 //
4082 //      GxB_set (GrB_Descriptor d, GrB_INP0, GxB_DEFAULT) ;
4083 //      GxB_set (GrB_Descriptor d, GrB_INP0, GrB_TRAN) ;
4084 //      GxB_get (GrB_Descriptor d, GrB_INP0, GrB_Desc_Value *v) ;
4085 //
4086 //      GxB_set (GrB_Descriptor d, GrB_INP1, GxB_DEFAULT) ;
4087 //      GxB_set (GrB_Descriptor d, GrB_INP1, GrB_TRAN) ;
4088 //      GxB_get (GrB_Descriptor d, GrB_INP1, GrB_Desc_Value *v) ;
4089 //
4090 //      GxB_set (GrB_Descriptor d, GxB_AxB_METHOD, GxB_DEFAULT) ;
4091 //      GxB_set (GrB_Descriptor d, GxB_AxB_METHOD, GxB_AxB_GUSTAVSON) ;
4092 //      GxB_set (GrB_Descriptor d, GxB_AxB_METHOD, GxB_AxB_HASH) ;
4093 //      GxB_set (GrB_Descriptor d, GxB_AxB_METHOD, GxB_AxB_SAXPY) ;
4094 //      GxB_set (GrB_Descriptor d, GxB_AxB_METHOD, GxB_AxB_DOT) ;
4095 //      GxB_get (GrB_Descriptor d, GrB_AxB_METHOD, GrB_Desc_Value *v) ;
4096 //
4097 //      GxB_set (GrB_Descriptor d, GxB_NTHREADS, nthreads) ;
4098 //      GxB_get (GrB_Descriptor d, GxB_NTHREADS, int *nthreads) ;
4099 //
4100 //      GxB_set (GrB_Descriptor d, GxB_CHUNK, double chunk) ;
4101 //      GxB_get (GrB_Descriptor d, GxB_CHUNK, double *chunk) ;
4102 //
4103 //      GxB_set (GrB_Descriptor d, GxB_SORT, sort) ;
4104 //      GxB_get (GrB_Descriptor d, GxB_SORT, int *sort) ;
4105 
4106 #if GxB_STDC_VERSION >= 201112L
4107 #define GxB_set(arg1,...)                                   \
4108     _Generic                                                \
4109     (                                                       \
4110         (arg1),                                             \
4111               int              : GxB_Global_Option_set ,    \
4112               GxB_Option_Field : GxB_Global_Option_set ,    \
4113               GrB_Vector       : GxB_Vector_Option_set ,    \
4114               GrB_Matrix       : GxB_Matrix_Option_set ,    \
4115               GrB_Descriptor   : GxB_Desc_set               \
4116     )                                                       \
4117     (arg1, __VA_ARGS__)
4118 
4119 #define GxB_get(arg1,...)                                   \
4120     _Generic                                                \
4121     (                                                       \
4122         (arg1),                                             \
4123         const int              : GxB_Global_Option_get ,    \
4124               int              : GxB_Global_Option_get ,    \
4125         const GxB_Option_Field : GxB_Global_Option_get ,    \
4126               GxB_Option_Field : GxB_Global_Option_get ,    \
4127         const GrB_Vector       : GxB_Vector_Option_get ,    \
4128               GrB_Vector       : GxB_Vector_Option_get ,    \
4129         const GrB_Matrix       : GxB_Matrix_Option_get ,    \
4130               GrB_Matrix       : GxB_Matrix_Option_get ,    \
4131         const GrB_Descriptor   : GxB_Desc_get          ,    \
4132               GrB_Descriptor   : GxB_Desc_get               \
4133     )                                                       \
4134     (arg1, __VA_ARGS__)
4135 #endif
4136 
4137 //==============================================================================
4138 // GrB_free: free any GraphBLAS object
4139 //==============================================================================
4140 
4141 // for null and invalid objects
4142 #define GrB_NULL NULL
4143 #define GrB_INVALID_HANDLE NULL
4144 
4145 #if GxB_STDC_VERSION >= 201112L
4146 #define GrB_free(object)                         \
4147     _Generic                                     \
4148     (                                            \
4149         (object),                                \
4150         GrB_Type       *: GrB_Type_free       ,  \
4151         GrB_UnaryOp    *: GrB_UnaryOp_free    ,  \
4152         GrB_BinaryOp   *: GrB_BinaryOp_free   ,  \
4153         GxB_SelectOp   *: GxB_SelectOp_free   ,  \
4154         GrB_Monoid     *: GrB_Monoid_free     ,  \
4155         GrB_Semiring   *: GrB_Semiring_free   ,  \
4156         GxB_Scalar     *: GxB_Scalar_free     ,  \
4157         GrB_Vector     *: GrB_Vector_free     ,  \
4158         GrB_Matrix     *: GrB_Matrix_free     ,  \
4159         GrB_Descriptor *: GrB_Descriptor_free    \
4160     )                                            \
4161     (object)
4162 #endif
4163 
4164 //==============================================================================
4165 // GrB_wait: finish computations
4166 //==============================================================================
4167 
4168 // Finish all pending work in a specific object.
4169 
4170 GB_PUBLIC GrB_Info GrB_Type_wait       (GrB_Type       *type    ) ;
4171 GB_PUBLIC GrB_Info GrB_UnaryOp_wait    (GrB_UnaryOp    *op      ) ;
4172 GB_PUBLIC GrB_Info GrB_BinaryOp_wait   (GrB_BinaryOp   *op      ) ;
4173 GB_PUBLIC GrB_Info GxB_SelectOp_wait   (GxB_SelectOp   *op      ) ;
4174 GB_PUBLIC GrB_Info GrB_Monoid_wait     (GrB_Monoid     *monoid  ) ;
4175 GB_PUBLIC GrB_Info GrB_Semiring_wait   (GrB_Semiring   *semiring) ;
4176 GB_PUBLIC GrB_Info GrB_Descriptor_wait (GrB_Descriptor *desc    ) ;
4177 GB_PUBLIC GrB_Info GxB_Scalar_wait     (GxB_Scalar     *s       ) ;
4178 GB_PUBLIC GrB_Info GrB_Vector_wait     (GrB_Vector     *v       ) ;
4179 GB_PUBLIC GrB_Info GrB_Matrix_wait     (GrB_Matrix     *A       ) ;
4180 
4181 // Note that v1.0 of the GraphBLAS C API had a no-input GrB_wait ( ) method,
4182 // which is now deprecated and no longer supported, since it conflicts with the
4183 // single-input GrB_wait (&object) method below.  The no-input GrB_wait ( )
4184 // method has been removed, as of v4.0 of SuiteSparse:GraphBLAS.
4185 
4186 // GrB_wait (&object) polymorphic function:
4187 #if GxB_STDC_VERSION >= 201112L
4188 #define GrB_wait(object)                         \
4189     _Generic                                     \
4190     (                                            \
4191         (object),                                \
4192         GrB_Type       *: GrB_Type_wait       ,  \
4193         GrB_UnaryOp    *: GrB_UnaryOp_wait    ,  \
4194         GrB_BinaryOp   *: GrB_BinaryOp_wait   ,  \
4195         GxB_SelectOp   *: GxB_SelectOp_wait   ,  \
4196         GrB_Monoid     *: GrB_Monoid_wait     ,  \
4197         GrB_Semiring   *: GrB_Semiring_wait   ,  \
4198         GxB_Scalar     *: GxB_Scalar_wait     ,  \
4199         GrB_Vector     *: GrB_Vector_wait     ,  \
4200         GrB_Matrix     *: GrB_Matrix_wait     ,  \
4201         GrB_Descriptor *: GrB_Descriptor_wait    \
4202     )                                            \
4203     (object)
4204 #endif
4205 
4206 //==============================================================================
4207 // GrB_error: error handling
4208 //==============================================================================
4209 
4210 // Each GraphBLAS method and operation returns a GrB_Info error code.
4211 // GrB_error returns additional information on the error in a thread-safe
4212 // null-terminated string.  The string returned by GrB_error is owned by
4213 // the GraphBLAS library and must not be free'd.
4214 
4215 GB_PUBLIC GrB_Info GrB_Type_error       (const char **error, const GrB_Type       type) ;
4216 GB_PUBLIC GrB_Info GrB_UnaryOp_error    (const char **error, const GrB_UnaryOp    op) ;
4217 GB_PUBLIC GrB_Info GrB_BinaryOp_error   (const char **error, const GrB_BinaryOp   op) ;
4218 GB_PUBLIC GrB_Info GxB_SelectOp_error   (const char **error, const GxB_SelectOp   op) ;
4219 GB_PUBLIC GrB_Info GrB_Monoid_error     (const char **error, const GrB_Monoid     monoid) ;
4220 GB_PUBLIC GrB_Info GrB_Semiring_error   (const char **error, const GrB_Semiring   semiring) ;
4221 GB_PUBLIC GrB_Info GxB_Scalar_error     (const char **error, const GxB_Scalar     s) ;
4222 GB_PUBLIC GrB_Info GrB_Vector_error     (const char **error, const GrB_Vector     v) ;
4223 GB_PUBLIC GrB_Info GrB_Matrix_error     (const char **error, const GrB_Matrix     A) ;
4224 GB_PUBLIC GrB_Info GrB_Descriptor_error (const char **error, const GrB_Descriptor d) ;
4225 
4226 // Note that v1.0 of the GraphBLAS C API had a no-input GrB_error ( ) method,
4227 // which is now deprecated and no longer supported, since it conflicts with the
4228 // 2-input GrB_error method defined below.  The no-input GrB_error ( ) method
4229 // has been removed, as of v4.0 of SuiteSparse:GraphBLAS.
4230 
4231 // GrB_error (error,object) polymorphic function:
4232 #if GxB_STDC_VERSION >= 201112L
4233 #define GrB_error(error,object)                         \
4234     _Generic                                            \
4235     (                                                   \
4236         (object),                                       \
4237         const GrB_Type       : GrB_Type_error       ,   \
4238               GrB_Type       : GrB_Type_error       ,   \
4239         const GrB_UnaryOp    : GrB_UnaryOp_error    ,   \
4240               GrB_UnaryOp    : GrB_UnaryOp_error    ,   \
4241         const GrB_BinaryOp   : GrB_BinaryOp_error   ,   \
4242               GrB_BinaryOp   : GrB_BinaryOp_error   ,   \
4243         const GxB_SelectOp   : GxB_SelectOp_error   ,   \
4244               GxB_SelectOp   : GxB_SelectOp_error   ,   \
4245         const GrB_Monoid     : GrB_Monoid_error     ,   \
4246               GrB_Monoid     : GrB_Monoid_error     ,   \
4247         const GrB_Semiring   : GrB_Semiring_error   ,   \
4248               GrB_Semiring   : GrB_Semiring_error   ,   \
4249         const GxB_Scalar     : GxB_Scalar_error     ,   \
4250               GxB_Scalar     : GxB_Scalar_error     ,   \
4251         const GrB_Vector     : GrB_Vector_error     ,   \
4252               GrB_Vector     : GrB_Vector_error     ,   \
4253         const GrB_Matrix     : GrB_Matrix_error     ,   \
4254               GrB_Matrix     : GrB_Matrix_error     ,   \
4255         const GrB_Descriptor : GrB_Descriptor_error ,   \
4256               GrB_Descriptor : GrB_Descriptor_error     \
4257     )                                                   \
4258     (error, object)
4259 #endif
4260 
4261 //==============================================================================
4262 // GrB_mxm, vxm, mxv: matrix multiplication over a semiring
4263 //==============================================================================
4264 
4265 GB_PUBLIC
4266 GrB_Info GrB_mxm                    // C<Mask> = accum (C, A*B)
4267 (
4268     GrB_Matrix C,                   // input/output matrix for results
4269     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4270     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4271     const GrB_Semiring semiring,    // defines '+' and '*' for A*B
4272     const GrB_Matrix A,             // first input:  matrix A
4273     const GrB_Matrix B,             // second input: matrix B
4274     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4275 ) ;
4276 
4277 GB_PUBLIC
4278 GrB_Info GrB_vxm                    // w'<Mask> = accum (w, u'*A)
4279 (
4280     GrB_Vector w,                   // input/output vector for results
4281     const GrB_Vector mask,          // optional mask for w, unused if NULL
4282     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4283     const GrB_Semiring semiring,    // defines '+' and '*' for u'*A
4284     const GrB_Vector u,             // first input:  vector u
4285     const GrB_Matrix A,             // second input: matrix A
4286     const GrB_Descriptor desc       // descriptor for w, mask, and A
4287 ) ;
4288 
4289 GB_PUBLIC
4290 GrB_Info GrB_mxv                    // w<Mask> = accum (w, A*u)
4291 (
4292     GrB_Vector w,                   // input/output vector for results
4293     const GrB_Vector mask,          // optional mask for w, unused if NULL
4294     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4295     const GrB_Semiring semiring,    // defines '+' and '*' for A*B
4296     const GrB_Matrix A,             // first input:  matrix A
4297     const GrB_Vector u,             // second input: vector u
4298     const GrB_Descriptor desc       // descriptor for w, mask, and A
4299 ) ;
4300 
4301 //==============================================================================
4302 // GrB_eWiseMult: element-wise matrix and vector operations, set intersection
4303 //==============================================================================
4304 
4305 // GrB_eWiseMult computes C<Mask> = accum (C, A.*B), where ".*" is MATLAB
4306 // notation, and where pairs of elements in two matrices (or vectors) are
4307 // pairwise "multiplied" with C(i,j) = mult (A(i,j),B(i,j)).
4308 
4309 GB_PUBLIC
4310 GrB_Info GrB_Vector_eWiseMult_Semiring       // w<Mask> = accum (w, u.*v)
4311 (
4312     GrB_Vector w,                   // input/output vector for results
4313     const GrB_Vector mask,          // optional mask for w, unused if NULL
4314     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4315     const GrB_Semiring semiring,    // defines '.*' for t=u.*v
4316     const GrB_Vector u,             // first input:  vector u
4317     const GrB_Vector v,             // second input: vector v
4318     const GrB_Descriptor desc       // descriptor for w and mask
4319 ) ;
4320 
4321 GB_PUBLIC
4322 GrB_Info GrB_Vector_eWiseMult_Monoid         // w<Mask> = accum (w, u.*v)
4323 (
4324     GrB_Vector w,                   // input/output vector for results
4325     const GrB_Vector mask,          // optional mask for w, unused if NULL
4326     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4327     const GrB_Monoid monoid,        // defines '.*' for t=u.*v
4328     const GrB_Vector u,             // first input:  vector u
4329     const GrB_Vector v,             // second input: vector v
4330     const GrB_Descriptor desc       // descriptor for w and mask
4331 ) ;
4332 
4333 GB_PUBLIC
4334 GrB_Info GrB_Vector_eWiseMult_BinaryOp       // w<Mask> = accum (w, u.*v)
4335 (
4336     GrB_Vector w,                   // input/output vector for results
4337     const GrB_Vector mask,          // optional mask for w, unused if NULL
4338     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4339     const GrB_BinaryOp mult,        // defines '.*' for t=u.*v
4340     const GrB_Vector u,             // first input:  vector u
4341     const GrB_Vector v,             // second input: vector v
4342     const GrB_Descriptor desc       // descriptor for w and mask
4343 ) ;
4344 
4345 GB_PUBLIC
4346 GrB_Info GrB_Matrix_eWiseMult_Semiring       // C<Mask> = accum (C, A.*B)
4347 (
4348     GrB_Matrix C,                   // input/output matrix for results
4349     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4350     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4351     const GrB_Semiring semiring,    // defines '.*' for T=A.*B
4352     const GrB_Matrix A,             // first input:  matrix A
4353     const GrB_Matrix B,             // second input: matrix B
4354     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4355 ) ;
4356 
4357 GB_PUBLIC
4358 GrB_Info GrB_Matrix_eWiseMult_Monoid         // C<Mask> = accum (C, A.*B)
4359 (
4360     GrB_Matrix C,                   // input/output matrix for results
4361     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4362     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4363     const GrB_Monoid monoid,        // defines '.*' for T=A.*B
4364     const GrB_Matrix A,             // first input:  matrix A
4365     const GrB_Matrix B,             // second input: matrix B
4366     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4367 ) ;
4368 
4369 GB_PUBLIC
4370 GrB_Info GrB_Matrix_eWiseMult_BinaryOp       // C<Mask> = accum (C, A.*B)
4371 (
4372     GrB_Matrix C,                   // input/output matrix for results
4373     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4374     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4375     const GrB_BinaryOp mult,        // defines '.*' for T=A.*B
4376     const GrB_Matrix A,             // first input:  matrix A
4377     const GrB_Matrix B,             // second input: matrix B
4378     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4379 ) ;
4380 
4381 // All 6 of the above type-specific functions are captured in a single
4382 // type-generic function, GrB_eWiseMult:
4383 
4384 #if GxB_STDC_VERSION >= 201112L
4385 #define GrB_eWiseMult(C,Mask,accum,op,A,B,desc)                         \
4386     _Generic                                                            \
4387     (                                                                   \
4388         (C),                                                            \
4389         GrB_Matrix :                                                    \
4390             _Generic                                                    \
4391             (                                                           \
4392                 (op),                                                   \
4393                 const GrB_Semiring : GrB_Matrix_eWiseMult_Semiring ,    \
4394                       GrB_Semiring : GrB_Matrix_eWiseMult_Semiring ,    \
4395                 const GrB_Monoid   : GrB_Matrix_eWiseMult_Monoid   ,    \
4396                       GrB_Monoid   : GrB_Matrix_eWiseMult_Monoid   ,    \
4397                 const GrB_BinaryOp : GrB_Matrix_eWiseMult_BinaryOp ,    \
4398                       GrB_BinaryOp : GrB_Matrix_eWiseMult_BinaryOp      \
4399             ),                                                          \
4400         GrB_Vector :                                                    \
4401             _Generic                                                    \
4402             (                                                           \
4403                 (op),                                                   \
4404                 const GrB_Semiring : GrB_Vector_eWiseMult_Semiring ,    \
4405                       GrB_Semiring : GrB_Vector_eWiseMult_Semiring ,    \
4406                 const GrB_Monoid   : GrB_Vector_eWiseMult_Monoid   ,    \
4407                       GrB_Monoid   : GrB_Vector_eWiseMult_Monoid   ,    \
4408                 const GrB_BinaryOp : GrB_Vector_eWiseMult_BinaryOp ,    \
4409                       GrB_BinaryOp : GrB_Vector_eWiseMult_BinaryOp      \
4410             )                                                           \
4411     )                                                                   \
4412     (C, Mask, accum, op, A, B, desc)
4413 #endif
4414 
4415 //==============================================================================
4416 // GrB_eWiseAdd: element-wise matrix and vector operations, set union
4417 //==============================================================================
4418 
4419 // GrB_eWiseAdd computes C<Mask> = accum (C, A+B), where pairs of elements in
4420 // two matrices (or two vectors) are pairwise "added".
4421 
4422 GB_PUBLIC
4423 GrB_Info GrB_Vector_eWiseAdd_Semiring       // w<Mask> = accum (w, u+v)
4424 (
4425     GrB_Vector w,                   // input/output vector for results
4426     const GrB_Vector mask,          // optional mask for w, unused if NULL
4427     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4428     const GrB_Semiring semiring,    // defines '+' for t=u+v
4429     const GrB_Vector u,             // first input:  vector u
4430     const GrB_Vector v,             // second input: vector v
4431     const GrB_Descriptor desc       // descriptor for w and mask
4432 ) ;
4433 
4434 GB_PUBLIC
4435 GrB_Info GrB_Vector_eWiseAdd_Monoid         // w<Mask> = accum (w, u+v)
4436 (
4437     GrB_Vector w,                   // input/output vector for results
4438     const GrB_Vector mask,          // optional mask for w, unused if NULL
4439     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4440     const GrB_Monoid monoid,        // defines '+' for t=u+v
4441     const GrB_Vector u,             // first input:  vector u
4442     const GrB_Vector v,             // second input: vector v
4443     const GrB_Descriptor desc       // descriptor for w and mask
4444 ) ;
4445 
4446 GB_PUBLIC
4447 GrB_Info GrB_Vector_eWiseAdd_BinaryOp       // w<Mask> = accum (w, u+v)
4448 (
4449     GrB_Vector w,                   // input/output vector for results
4450     const GrB_Vector mask,          // optional mask for w, unused if NULL
4451     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4452     const GrB_BinaryOp add,         // defines '+' for t=u+v
4453     const GrB_Vector u,             // first input:  vector u
4454     const GrB_Vector v,             // second input: vector v
4455     const GrB_Descriptor desc       // descriptor for w and mask
4456 ) ;
4457 
4458 GB_PUBLIC
4459 GrB_Info GrB_Matrix_eWiseAdd_Semiring       // C<Mask> = accum (C, A+B)
4460 (
4461     GrB_Matrix C,                   // input/output matrix for results
4462     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4463     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4464     const GrB_Semiring semiring,    // defines '+' for T=A+B
4465     const GrB_Matrix A,             // first input:  matrix A
4466     const GrB_Matrix B,             // second input: matrix B
4467     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4468 ) ;
4469 
4470 GB_PUBLIC
4471 GrB_Info GrB_Matrix_eWiseAdd_Monoid         // C<Mask> = accum (C, A+B)
4472 (
4473     GrB_Matrix C,                   // input/output matrix for results
4474     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4475     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4476     const GrB_Monoid monoid,        // defines '+' for T=A+B
4477     const GrB_Matrix A,             // first input:  matrix A
4478     const GrB_Matrix B,             // second input: matrix B
4479     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4480 ) ;
4481 
4482 GB_PUBLIC
4483 GrB_Info GrB_Matrix_eWiseAdd_BinaryOp       // C<Mask> = accum (C, A+B)
4484 (
4485     GrB_Matrix C,                   // input/output matrix for results
4486     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4487     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4488     const GrB_BinaryOp add,         // defines '+' for T=A+B
4489     const GrB_Matrix A,             // first input:  matrix A
4490     const GrB_Matrix B,             // second input: matrix B
4491     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
4492 ) ;
4493 
4494 #if GxB_STDC_VERSION >= 201112L
4495 #define GrB_eWiseAdd(C,Mask,accum,op,A,B,desc)                          \
4496     _Generic                                                            \
4497     (                                                                   \
4498         (C),                                                            \
4499         GrB_Matrix :                                                    \
4500             _Generic                                                    \
4501             (                                                           \
4502                 (op),                                                   \
4503                 const GrB_Semiring : GrB_Matrix_eWiseAdd_Semiring ,     \
4504                       GrB_Semiring : GrB_Matrix_eWiseAdd_Semiring ,     \
4505                 const GrB_Monoid   : GrB_Matrix_eWiseAdd_Monoid   ,     \
4506                       GrB_Monoid   : GrB_Matrix_eWiseAdd_Monoid   ,     \
4507                 const GrB_BinaryOp : GrB_Matrix_eWiseAdd_BinaryOp ,     \
4508                       GrB_BinaryOp : GrB_Matrix_eWiseAdd_BinaryOp       \
4509             ),                                                          \
4510         GrB_Vector :                                                    \
4511             _Generic                                                    \
4512             (                                                           \
4513                 (op),                                                   \
4514                 const GrB_Semiring : GrB_Vector_eWiseAdd_Semiring ,     \
4515                       GrB_Semiring : GrB_Vector_eWiseAdd_Semiring ,     \
4516                 const GrB_Monoid   : GrB_Vector_eWiseAdd_Monoid   ,     \
4517                       GrB_Monoid   : GrB_Vector_eWiseAdd_Monoid   ,     \
4518                 const GrB_BinaryOp : GrB_Vector_eWiseAdd_BinaryOp ,     \
4519                       GrB_BinaryOp : GrB_Vector_eWiseAdd_BinaryOp       \
4520             )                                                           \
4521     )                                                                   \
4522     (C, Mask, accum, op, A, B, desc)
4523 #endif
4524 
4525 //==============================================================================
4526 // GrB_extract: extract a submatrix or subvector
4527 //==============================================================================
4528 
4529 // Extract entries from a matrix or vector; T = A(I,J) in MATLAB notation.
4530 // This (like most GraphBLAS methods) is then followed by C<Mask>=accum(C,T).
4531 
4532 // To extract all rows of a matrix or vector, as in A (:,J) in MATLAB, use
4533 // I=GrB_ALL as the input argument.  For all columns of a matrix, use
4534 // J=GrB_ALL.
4535 
4536 GB_PUBLIC const uint64_t *GrB_ALL ;
4537 
4538 // To extract a range of rows and columns, I and J can be a list of 2 or 3
4539 // indices that defines a range (begin:end) or a strided range (begin:inc:end),
4540 // in MATLAB notation.  To specify the MATLAB syntax I = begin:end, the array I
4541 // has size at least 2, where I [GxB_BEGIN] = begin and I [GxB_END] = end.  The
4542 // parameter ni is then passed as the special value GxB_RANGE.  To specify the
4543 // MATLAB syntax I = begin:inc:end, the array I has size at least three, with
4544 // the values begin, end, and inc (in that order), and then pass in the value
4545 // ni = GxB_STRIDE.  The same can be done for the list J and its size, nj.
4546 
4547 // These special values of ni and nj can be used for GrB_assign,
4548 // GrB_extract, and GxB_subassign.
4549 #define GxB_RANGE       (INT64_MAX)
4550 #define GxB_STRIDE      (INT64_MAX-1)
4551 #define GxB_BACKWARDS   (INT64_MAX-2)
4552 
4553 // for the strided range begin:inc:end, I [GxB_BEGIN] is the value of begin, I
4554 // [GxB_END] is the value end, I [GxB_INC] is the magnitude of the stride.  If
4555 // the stride is negative, use ni = GxB_BACKWARDS.
4556 #define GxB_BEGIN (0)
4557 #define GxB_END   (1)
4558 #define GxB_INC   (2)
4559 
4560 // For example, the MATLAB notation 10:-2:1 defines a sequence [10 8 6 4 2].
4561 // The end point of the sequence (1) need not appear in the sequence, if
4562 // the last increment goes past it.  To specify the same in GraphBLAS,
4563 // use:
4564 
4565 //      GrB_Index I [3], ni = GxB_BACKWARDS ;
4566 //      I [GxB_BEGIN ] = 10 ;               // the start of the sequence
4567 //      I [GxB_INC   ] = 2 ;                // the magnitude of the increment
4568 //      I [GxB_END   ] = 1 ;                // the end of the sequence
4569 
4570 GB_PUBLIC
4571 GrB_Info GrB_Vector_extract         // w<mask> = accum (w, u(I))
4572 (
4573     GrB_Vector w,                   // input/output vector for results
4574     const GrB_Vector mask,          // optional mask for w, unused if NULL
4575     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4576     const GrB_Vector u,             // first input:  vector u
4577     const GrB_Index *I,             // row indices
4578     GrB_Index ni,                   // number of row indices
4579     const GrB_Descriptor desc       // descriptor for w and mask
4580 ) ;
4581 
4582 GB_PUBLIC
4583 GrB_Info GrB_Matrix_extract         // C<Mask> = accum (C, A(I,J))
4584 (
4585     GrB_Matrix C,                   // input/output matrix for results
4586     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
4587     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
4588     const GrB_Matrix A,             // first input:  matrix A
4589     const GrB_Index *I,             // row indices
4590     GrB_Index ni,                   // number of row indices
4591     const GrB_Index *J,             // column indices
4592     GrB_Index nj,                   // number of column indices
4593     const GrB_Descriptor desc       // descriptor for C, Mask, and A
4594 ) ;
4595 
4596 GB_PUBLIC
4597 GrB_Info GrB_Col_extract            // w<mask> = accum (w, A(I,j))
4598 (
4599     GrB_Vector w,                   // input/output matrix for results
4600     const GrB_Vector mask,          // optional mask for w, unused if NULL
4601     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
4602     const GrB_Matrix A,             // first input:  matrix A
4603     const GrB_Index *I,             // row indices
4604     GrB_Index ni,                   // number of row indices
4605     GrB_Index j,                    // column index
4606     const GrB_Descriptor desc       // descriptor for w, mask, and A
4607 ) ;
4608 
4609 //------------------------------------------------------------------------------
4610 // GrB_extract: generic matrix/vector extraction
4611 //------------------------------------------------------------------------------
4612 
4613 // GrB_extract is a generic interface to the following functions:
4614 
4615 // GrB_Vector_extract (w,mask,acc,u,I,ni,d)      // w<m>    = acc (w, u(I))
4616 // GrB_Col_extract    (w,mask,acc,A,I,ni,j,d)    // w<m>    = acc (w, A(I,j))
4617 // GrB_Matrix_extract (C,Mask,acc,A,I,ni,J,nj,d) // C<Mask> = acc (C, A(I,J))
4618 
4619 #if GxB_STDC_VERSION >= 201112L
4620 #define GrB_extract(arg1,Mask,accum,arg4,...) \
4621     _Generic                                                \
4622     (                                                       \
4623         (arg1),                                             \
4624         GrB_Vector :                                        \
4625             _Generic                                        \
4626             (                                               \
4627                 (arg4),                                     \
4628                 const GrB_Vector : GrB_Vector_extract ,     \
4629                       GrB_Vector : GrB_Vector_extract ,     \
4630                 const GrB_Matrix : GrB_Col_extract    ,     \
4631                       GrB_Matrix : GrB_Col_extract          \
4632             ),                                              \
4633         GrB_Matrix : GrB_Matrix_extract                     \
4634     )                                                       \
4635     (arg1, Mask, accum, arg4, __VA_ARGS__)
4636 #endif
4637 
4638 //==============================================================================
4639 // GxB_subassign: matrix and vector subassign: C(I,J)<Mask> = accum (C(I,J), A)
4640 //==============================================================================
4641 
4642 // Assign entries in a matrix or vector; C(I,J) = A in MATLAB notation.
4643 
4644 // Each GxB_subassign function is very similar to its corresponding GrB_assign
4645 // function in the spec, but they differ in two ways: (1) the mask in
4646 // GxB_subassign has the same size as w(I) for vectors and C(I,J) for matrices,
4647 // and (2) they differ in the GrB_REPLACE option.  See the user guide for
4648 // details.
4649 
4650 // In GraphBLAS notation, the two methods can be described as follows:
4651 
4652 // matrix and vector subassign: C(I,J)<Mask> = accum (C(I,J), A)
4653 // matrix and vector    assign: C<Mask>(I,J) = accum (C(I,J), A)
4654 
4655 // --- assign ------------------------------------------------------------------
4656 //
4657 // GrB_Matrix_assign      C<M>(I,J) += A        M same size as matrix C.
4658 //                                              A is |I|-by-|J|
4659 //
4660 // GrB_Vector_assign      w<m>(I)   += u        m same size as column vector w.
4661 //                                              u is |I|-by-1
4662 //
4663 // GrB_Row_assign         C<m'>(i,J) += u'      m is a column vector the same
4664 //                                              size as a row of C.
4665 //                                              u is |J|-by-1, i is a scalar.
4666 //
4667 // GrB_Col_assign         C<m>(I,j) += u        m is a column vector the same
4668 //                                              size as a column of C.
4669 //                                              u is |I|-by-1, j is a scalar.
4670 //
4671 // --- subassign ---------------------------------------------------------------
4672 //
4673 // GxB_Matrix_subassign   C(I,J)<M> += A        M same size as matrix A.
4674 //                                              A is |I|-by-|J|
4675 //
4676 // GxB_Vector_subassign   w(I)<m>   += u        m same size as column vector u.
4677 //                                              u is |I|-by-1
4678 //
4679 // GxB_Row_subassign      C(i,J)<m'> += u'      m same size as column vector u.
4680 //                                              u is |J|-by-1, i is a scalar.
4681 //
4682 // GxB_Col_subassign      C(I,j)<m> += u        m same size as column vector u.
4683 //                                              u is |I|-by-1, j is a scalar.
4684 
4685 GB_PUBLIC
4686 GrB_Info GxB_Vector_subassign       // w(I)<mask> = accum (w(I),u)
4687 (
4688     GrB_Vector w,                   // input/output matrix for results
4689     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4690     const GrB_BinaryOp accum,       // optional accum for z=accum(w(I),t)
4691     const GrB_Vector u,             // first input:  vector u
4692     const GrB_Index *I,             // row indices
4693     GrB_Index ni,                   // number of row indices
4694     const GrB_Descriptor desc       // descriptor for w(I) and mask
4695 ) ;
4696 
4697 GB_PUBLIC
4698 GrB_Info GxB_Matrix_subassign       // C(I,J)<Mask> = accum (C(I,J),A)
4699 (
4700     GrB_Matrix C,                   // input/output matrix for results
4701     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4702     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),T)
4703     const GrB_Matrix A,             // first input:  matrix A
4704     const GrB_Index *I,             // row indices
4705     GrB_Index ni,                   // number of row indices
4706     const GrB_Index *J,             // column indices
4707     GrB_Index nj,                   // number of column indices
4708     const GrB_Descriptor desc       // descriptor for C(I,J), Mask, and A
4709 ) ;
4710 
4711 GB_PUBLIC
4712 GrB_Info GxB_Col_subassign          // C(I,j)<mask> = accum (C(I,j),u)
4713 (
4714     GrB_Matrix C,                   // input/output matrix for results
4715     const GrB_Vector mask,          // optional mask for C(I,j), unused if NULL
4716     const GrB_BinaryOp accum,       // optional accum for z=accum(C(I,j),t)
4717     const GrB_Vector u,             // input vector
4718     const GrB_Index *I,             // row indices
4719     GrB_Index ni,                   // number of row indices
4720     GrB_Index j,                    // column index
4721     const GrB_Descriptor desc       // descriptor for C(I,j) and mask
4722 ) ;
4723 
4724 GB_PUBLIC
4725 GrB_Info GxB_Row_subassign          // C(i,J)<mask'> = accum (C(i,J),u')
4726 (
4727     GrB_Matrix C,                   // input/output matrix for results
4728     const GrB_Vector mask,          // optional mask for C(i,J), unused if NULL
4729     const GrB_BinaryOp accum,       // optional accum for z=accum(C(i,J),t)
4730     const GrB_Vector u,             // input vector
4731     GrB_Index i,                    // row index
4732     const GrB_Index *J,             // column indices
4733     GrB_Index nj,                   // number of column indices
4734     const GrB_Descriptor desc       // descriptor for C(i,J) and mask
4735 ) ;
4736 
4737 //------------------------------------------------------------------------------
4738 // GxB_Vector_subassign_[SCALAR]:  scalar expansion assignment to subvector
4739 //------------------------------------------------------------------------------
4740 
4741 // Assigns a single scalar to a subvector, w(I)<mask> = accum(w(I),x).  The
4742 // scalar x is implicitly expanded into a vector u of size ni-by-1, with each
4743 // entry in u equal to x, and then w(I)<mask> = accum(w(I),u) is done.
4744 
4745 GB_PUBLIC
4746 GrB_Info GxB_Vector_subassign_BOOL  // w(I)<mask> = accum (w(I),x)
4747 (
4748     GrB_Vector w,                   // input/output vector for results
4749     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4750     const GrB_BinaryOp accum,       // optional accum for z=accum(w(I),x)
4751     bool x,                         // scalar to assign to w(I)
4752     const GrB_Index *I,             // row indices
4753     GrB_Index ni,                   // number of row indices
4754     const GrB_Descriptor desc       // descriptor for w(I) and mask
4755 ) ;
4756 
4757 GB_PUBLIC
4758 GrB_Info GxB_Vector_subassign_INT8  // w(I)<mask> = accum (w(I),x)
4759 (
4760     GrB_Vector w,                   // input/output vector for results
4761     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4762     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4763     int8_t x,                       // scalar to assign to w(I)
4764     const GrB_Index *I,             // row indices
4765     GrB_Index ni,                   // number of row indices
4766     const GrB_Descriptor desc       // descriptor for w(I) and mask
4767 ) ;
4768 
4769 GB_PUBLIC
4770 GrB_Info GxB_Vector_subassign_UINT8 // w(I)<mask> = accum (w(I),x)
4771 (
4772     GrB_Vector w,                   // input/output vector for results
4773     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4774     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4775     uint8_t x,                      // scalar to assign to w(I)
4776     const GrB_Index *I,             // row indices
4777     GrB_Index ni,                   // number of row indices
4778     const GrB_Descriptor desc       // descriptor for w(I) and mask
4779 ) ;
4780 
4781 GB_PUBLIC
4782 GrB_Info GxB_Vector_subassign_INT16 // w(I)<mask> = accum (w(I),x)
4783 (
4784     GrB_Vector w,                   // input/output vector for results
4785     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4786     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4787     int16_t x,                      // scalar to assign to w(I)
4788     const GrB_Index *I,             // row indices
4789     GrB_Index ni,                   // number of row indices
4790     const GrB_Descriptor desc       // descriptor for w(I) and mask
4791 ) ;
4792 
4793 GB_PUBLIC
4794 GrB_Info GxB_Vector_subassign_UINT16   // w(I)<mask> = accum (w(I),x)
4795 (
4796     GrB_Vector w,                   // input/output vector for results
4797     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4798     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4799     uint16_t x,                     // scalar to assign to w(I)
4800     const GrB_Index *I,             // row indices
4801     GrB_Index ni,                   // number of row indices
4802     const GrB_Descriptor desc       // descriptor for w(I) and mask
4803 ) ;
4804 
4805 GB_PUBLIC
4806 GrB_Info GxB_Vector_subassign_INT32    // w(I)<mask> = accum (w(I),x)
4807 (
4808     GrB_Vector w,                   // input/output vector for results
4809     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4810     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4811     int32_t x,                      // scalar to assign to w(I)
4812     const GrB_Index *I,             // row indices
4813     GrB_Index ni,                   // number of row indices
4814     const GrB_Descriptor desc       // descriptor for w(I) and mask
4815 ) ;
4816 
4817 GB_PUBLIC
4818 GrB_Info GxB_Vector_subassign_UINT32   // w(I)<mask> = accum (w(I),x)
4819 (
4820     GrB_Vector w,                   // input/output vector for results
4821     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4822     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4823     uint32_t x,                     // scalar to assign to w(I)
4824     const GrB_Index *I,             // row indices
4825     GrB_Index ni,                   // number of row indices
4826     const GrB_Descriptor desc       // descriptor for w(I) and mask
4827 ) ;
4828 
4829 GB_PUBLIC
4830 GrB_Info GxB_Vector_subassign_INT64    // w(I)<mask> = accum (w(I),x)
4831 (
4832     GrB_Vector w,                   // input/output vector for results
4833     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4834     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4835     int64_t x,                      // scalar to assign to w(I)
4836     const GrB_Index *I,             // row indices
4837     GrB_Index ni,                   // number of row indices
4838     const GrB_Descriptor desc       // descriptor for w(I) and mask
4839 ) ;
4840 
4841 GB_PUBLIC
4842 GrB_Info GxB_Vector_subassign_UINT64   // w(I)<mask> = accum (w(I),x)
4843 (
4844     GrB_Vector w,                   // input/output vector for results
4845     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4846     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4847     uint64_t x,                     // scalar to assign to w(I)
4848     const GrB_Index *I,             // row indices
4849     GrB_Index ni,                   // number of row indices
4850     const GrB_Descriptor desc       // descriptor for w(I) and mask
4851 ) ;
4852 
4853 GB_PUBLIC
4854 GrB_Info GxB_Vector_subassign_FP32     // w(I)<mask> = accum (w(I),x)
4855 (
4856     GrB_Vector w,                   // input/output vector for results
4857     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4858     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4859     float x,                        // scalar to assign to w(I)
4860     const GrB_Index *I,             // row indices
4861     GrB_Index ni,                   // number of row indices
4862     const GrB_Descriptor desc       // descriptor for w(I) and mask
4863 ) ;
4864 
4865 GB_PUBLIC
4866 GrB_Info GxB_Vector_subassign_FP64     // w(I)<mask> = accum (w(I),x)
4867 (
4868     GrB_Vector w,                   // input/output vector for results
4869     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4870     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4871     double x,                       // scalar to assign to w(I)
4872     const GrB_Index *I,             // row indices
4873     GrB_Index ni,                   // number of row indices
4874     const GrB_Descriptor desc       // descriptor for w(I) and mask
4875 ) ;
4876 
4877 GB_PUBLIC
4878 GrB_Info GxB_Vector_subassign_FC32     // w(I)<mask> = accum (w(I),x)
4879 (
4880     GrB_Vector w,                   // input/output vector for results
4881     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4882     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4883     GxB_FC32_t x,                   // scalar to assign to w(I)
4884     const GrB_Index *I,             // row indices
4885     GrB_Index ni,                   // number of row indices
4886     const GrB_Descriptor desc       // descriptor for w(I) and mask
4887 ) ;
4888 
4889 GB_PUBLIC
4890 GrB_Info GxB_Vector_subassign_FC64     // w(I)<mask> = accum (w(I),x)
4891 (
4892     GrB_Vector w,                   // input/output vector for results
4893     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4894     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4895     GxB_FC64_t x,                   // scalar to assign to w(I)
4896     const GrB_Index *I,             // row indices
4897     GrB_Index ni,                   // number of row indices
4898     const GrB_Descriptor desc       // descriptor for w(I) and mask
4899 ) ;
4900 
4901 GB_PUBLIC
4902 GrB_Info GxB_Vector_subassign_UDT      // w(I)<mask> = accum (w(I),x)
4903 (
4904     GrB_Vector w,                   // input/output vector for results
4905     const GrB_Vector mask,          // optional mask for w(I), unused if NULL
4906     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
4907     void *x,                        // scalar to assign to w(I)
4908     const GrB_Index *I,             // row indices
4909     GrB_Index ni,                   // number of row indices
4910     const GrB_Descriptor desc       // descriptor for w(I) and mask
4911 ) ;
4912 
4913 //------------------------------------------------------------------------------
4914 // GxB_Matrix_subassign_[SCALAR]:  scalar expansion assignment to submatrix
4915 //------------------------------------------------------------------------------
4916 
4917 // Assigns a single scalar to a submatrix, C(I,J)<Mask> = accum(C(I,J),x).  The
4918 // scalar x is implicitly expanded into a matrix A of size ni-by-nj, with each
4919 // entry in A equal to x, and then C(I,J)<Mask> = accum(C(I,J),A) is done.
4920 
4921 GB_PUBLIC
4922 GrB_Info GxB_Matrix_subassign_BOOL  // C(I,J)<Mask> = accum (C(I,J),x)
4923 (
4924     GrB_Matrix C,                   // input/output matrix for results
4925     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4926     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4927     bool x,                         // scalar to assign to C(I,J)
4928     const GrB_Index *I,             // row indices
4929     GrB_Index ni,                   // number of row indices
4930     const GrB_Index *J,             // column indices
4931     GrB_Index nj,                   // number of column indices
4932     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
4933 ) ;
4934 
4935 GB_PUBLIC
4936 GrB_Info GxB_Matrix_subassign_INT8  // C(I,J)<Mask> = accum (C(I,J),x)
4937 (
4938     GrB_Matrix C,                   // input/output matrix for results
4939     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4940     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4941     int8_t x,                       // scalar to assign to C(I,J)
4942     const GrB_Index *I,             // row indices
4943     GrB_Index ni,                   // number of row indices
4944     const GrB_Index *J,             // column indices
4945     GrB_Index nj,                   // number of column indices
4946     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
4947 ) ;
4948 
4949 GB_PUBLIC
4950 GrB_Info GxB_Matrix_subassign_UINT8 // C(I,J)<Mask> = accum (C(I,J),x)
4951 (
4952     GrB_Matrix C,                   // input/output matrix for results
4953     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4954     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4955     uint8_t x,                      // scalar to assign to C(I,J)
4956     const GrB_Index *I,             // row indices
4957     GrB_Index ni,                   // number of row indices
4958     const GrB_Index *J,             // column indices
4959     GrB_Index nj,                   // number of column indices
4960     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
4961 ) ;
4962 
4963 GB_PUBLIC
4964 GrB_Info GxB_Matrix_subassign_INT16 // C(I,J)<Mask> = accum (C(I,J),x)
4965 (
4966     GrB_Matrix C,                   // input/output matrix for results
4967     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4968     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4969     int16_t x,                      // scalar to assign to C(I,J)
4970     const GrB_Index *I,             // row indices
4971     GrB_Index ni,                   // number of row indices
4972     const GrB_Index *J,             // column indices
4973     GrB_Index nj,                   // number of column indices
4974     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
4975 ) ;
4976 
4977 GB_PUBLIC
4978 GrB_Info GxB_Matrix_subassign_UINT16   // C(I,J)<Mask> = accum (C(I,J),x)
4979 (
4980     GrB_Matrix C,                   // input/output matrix for results
4981     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4982     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4983     uint16_t x,                     // scalar to assign to C(I,J)
4984     const GrB_Index *I,             // row indices
4985     GrB_Index ni,                   // number of row indices
4986     const GrB_Index *J,             // column indices
4987     GrB_Index nj,                   // number of column indices
4988     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
4989 ) ;
4990 
4991 GB_PUBLIC
4992 GrB_Info GxB_Matrix_subassign_INT32    // C(I,J)<Mask> = accum (C(I,J),x)
4993 (
4994     GrB_Matrix C,                   // input/output matrix for results
4995     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
4996     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
4997     int32_t x,                      // scalar to assign to C(I,J)
4998     const GrB_Index *I,             // row indices
4999     GrB_Index ni,                   // number of row indices
5000     const GrB_Index *J,             // column indices
5001     GrB_Index nj,                   // number of column indices
5002     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5003 ) ;
5004 
5005 GB_PUBLIC
5006 GrB_Info GxB_Matrix_subassign_UINT32   // C(I,J)<Mask> = accum (C(I,J),x)
5007 (
5008     GrB_Matrix C,                   // input/output matrix for results
5009     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5010     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5011     uint32_t x,                     // scalar to assign to C(I,J)
5012     const GrB_Index *I,             // row indices
5013     GrB_Index ni,                   // number of row indices
5014     const GrB_Index *J,             // column indices
5015     GrB_Index nj,                   // number of column indices
5016     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5017 ) ;
5018 
5019 GB_PUBLIC
5020 GrB_Info GxB_Matrix_subassign_INT64    // C(I,J)<Mask> = accum (C(I,J),x)
5021 (
5022     GrB_Matrix C,                   // input/output matrix for results
5023     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5024     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5025     int64_t x,                      // scalar to assign to C(I,J)
5026     const GrB_Index *I,             // row indices
5027     GrB_Index ni,                   // number of row indices
5028     const GrB_Index *J,             // column indices
5029     GrB_Index nj,                   // number of column indices
5030     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5031 ) ;
5032 
5033 GB_PUBLIC
5034 GrB_Info GxB_Matrix_subassign_UINT64   // C(I,J)<Mask> = accum (C(I,J),x)
5035 (
5036     GrB_Matrix C,                   // input/output matrix for results
5037     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5038     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5039     uint64_t x,                     // scalar to assign to C(I,J)
5040     const GrB_Index *I,             // row indices
5041     GrB_Index ni,                   // number of row indices
5042     const GrB_Index *J,             // column indices
5043     GrB_Index nj,                   // number of column indices
5044     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5045 ) ;
5046 
5047 GB_PUBLIC
5048 GrB_Info GxB_Matrix_subassign_FP32     // C(I,J)<Mask> = accum (C(I,J),x)
5049 (
5050     GrB_Matrix C,                   // input/output matrix for results
5051     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5052     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5053     float x,                        // scalar to assign to C(I,J)
5054     const GrB_Index *I,             // row indices
5055     GrB_Index ni,                   // number of row indices
5056     const GrB_Index *J,             // column indices
5057     GrB_Index nj,                   // number of column indices
5058     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5059 ) ;
5060 
5061 GB_PUBLIC
5062 GrB_Info GxB_Matrix_subassign_FP64     // C(I,J)<Mask> = accum (C(I,J),x)
5063 (
5064     GrB_Matrix C,                   // input/output matrix for results
5065     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5066     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5067     double x,                       // scalar to assign to C(I,J)
5068     const GrB_Index *I,             // row indices
5069     GrB_Index ni,                   // number of row indices
5070     const GrB_Index *J,             // column indices
5071     GrB_Index nj,                   // number of column indices
5072     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5073 ) ;
5074 
5075 GB_PUBLIC
5076 GrB_Info GxB_Matrix_subassign_FC32     // C(I,J)<Mask> = accum (C(I,J),x)
5077 (
5078     GrB_Matrix C,                   // input/output matrix for results
5079     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5080     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5081     GxB_FC32_t x,                   // scalar to assign to C(I,J)
5082     const GrB_Index *I,             // row indices
5083     GrB_Index ni,                   // number of row indices
5084     const GrB_Index *J,             // column indices
5085     GrB_Index nj,                   // number of column indices
5086     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5087 ) ;
5088 
5089 GB_PUBLIC
5090 GrB_Info GxB_Matrix_subassign_FC64     // C(I,J)<Mask> = accum (C(I,J),x)
5091 (
5092     GrB_Matrix C,                   // input/output matrix for results
5093     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5094     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5095     GxB_FC64_t x,                   // scalar to assign to C(I,J)
5096     const GrB_Index *I,             // row indices
5097     GrB_Index ni,                   // number of row indices
5098     const GrB_Index *J,             // column indices
5099     GrB_Index nj,                   // number of column indices
5100     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5101 ) ;
5102 
5103 GB_PUBLIC
5104 GrB_Info GxB_Matrix_subassign_UDT      // C(I,J)<Mask> = accum (C(I,J),x)
5105 (
5106     GrB_Matrix C,                   // input/output matrix for results
5107     const GrB_Matrix Mask,          // optional mask for C(I,J), unused if NULL
5108     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5109     void *x,                        // scalar to assign to C(I,J)
5110     const GrB_Index *I,             // row indices
5111     GrB_Index ni,                   // number of row indices
5112     const GrB_Index *J,             // column indices
5113     GrB_Index nj,                   // number of column indices
5114     const GrB_Descriptor desc       // descriptor for C(I,J) and Mask
5115 ) ;
5116 
5117 //------------------------------------------------------------------------------
5118 // GxB_subassign: generic submatrix/subvector assignment
5119 //------------------------------------------------------------------------------
5120 
5121 // GxB_subassign is a generic function that provides access to all specific
5122 // GxB_*_subassign* functions:
5123 
5124 // GxB_Vector_subassign   (w,m,acc,u,I,ni,d)      // w(I)<m>    = acc(w(I),u)
5125 // GxB_Matrix_subassign   (C,M,acc,A,I,ni,J,nj,d) // C(I,J)<M>  = acc(C(I,J),A)
5126 // GxB_Col_subassign      (C,m,acc,u,I,ni,j,d)    // C(I,j)<m>  = acc(C(I,j),u)
5127 // GxB_Row_subassign      (C,m,acc,u,i,J,nj,d)    // C(i,J)<m'> = acc(C(i,J),u')
5128 // GxB_Vector_subassign_T (w,m,acc,x,I,ni,d)      // w(I)<m>    = acc(w(I),x)
5129 // GxB_Matrix_subassign_T (C,M,acc,x,I,ni,J,nj,d) // C(I,J)<M>  = acc(C(I,J),x)
5130 
5131 #if GxB_STDC_VERSION >= 201112L
5132 #define GxB_subassign(arg1,Mask,accum,arg4,arg5,...)               \
5133     _Generic                                                       \
5134     (                                                              \
5135         (arg1),                                                    \
5136         GrB_Vector :                                               \
5137             _Generic                                               \
5138             (                                                      \
5139                 (arg4),                                            \
5140                 GB_CASES (, GxB, Vector_subassign) ,               \
5141                 default : GxB_Vector_subassign                     \
5142             ),                                                     \
5143         default :                                                  \
5144             _Generic                                               \
5145             (                                                      \
5146                 (arg4),                                            \
5147                 GB_CASES (, GxB, Matrix_subassign) ,               \
5148                 const GrB_Vector :                                 \
5149                     _Generic                                       \
5150                     (                                              \
5151                         (arg5),                                    \
5152                         const GrB_Index *: GxB_Col_subassign ,     \
5153                               GrB_Index *: GxB_Col_subassign ,     \
5154                         default          : GxB_Row_subassign       \
5155                     ),                                             \
5156                 GrB_Vector :                                       \
5157                     _Generic                                       \
5158                     (                                              \
5159                         (arg5),                                    \
5160                         const GrB_Index *: GxB_Col_subassign ,     \
5161                               GrB_Index *: GxB_Col_subassign ,     \
5162                         default          : GxB_Row_subassign       \
5163                     ),                                             \
5164                 default    : GxB_Matrix_subassign                  \
5165             )                                                      \
5166     )                                                              \
5167     (arg1, Mask, accum, arg4, arg5, __VA_ARGS__)
5168 #endif
5169 
5170 //==============================================================================
5171 // GrB_assign: matrix and vector assign: C<Mask>(I,J) = accum (C(I,J), A)
5172 //==============================================================================
5173 
5174 // Assign entries in a matrix or vector; C(I,J) = A in MATLAB notation.
5175 // Each of these can be used with their generic name, GrB_assign.
5176 
5177 GB_PUBLIC
5178 GrB_Info GrB_Vector_assign          // w<mask>(I) = accum (w(I),u)
5179 (
5180     GrB_Vector w,                   // input/output matrix for results
5181     const GrB_Vector mask,          // optional mask for w, unused if NULL
5182     const GrB_BinaryOp accum,       // optional accum for z=accum(w(I),t)
5183     const GrB_Vector u,             // first input:  vector u
5184     const GrB_Index *I,             // row indices
5185     GrB_Index ni,                   // number of row indices
5186     const GrB_Descriptor desc       // descriptor for w and mask
5187 ) ;
5188 
5189 GB_PUBLIC
5190 GrB_Info GrB_Matrix_assign          // C<Mask>(I,J) = accum (C(I,J),A)
5191 (
5192     GrB_Matrix C,                   // input/output matrix for results
5193     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5194     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),T)
5195     const GrB_Matrix A,             // first input:  matrix A
5196     const GrB_Index *I,             // row indices
5197     GrB_Index ni,                   // number of row indices
5198     const GrB_Index *J,             // column indices
5199     GrB_Index nj,                   // number of column indices
5200     const GrB_Descriptor desc       // descriptor for C, Mask, and A
5201 ) ;
5202 
5203 GB_PUBLIC
5204 GrB_Info GrB_Col_assign             // C<mask>(I,j) = accum (C(I,j),u)
5205 (
5206     GrB_Matrix C,                   // input/output matrix for results
5207     const GrB_Vector mask,          // optional mask for C(:,j), unused if NULL
5208     const GrB_BinaryOp accum,       // optional accum for z=accum(C(I,j),t)
5209     const GrB_Vector u,             // input vector
5210     const GrB_Index *I,             // row indices
5211     GrB_Index ni,                   // number of row indices
5212     GrB_Index j,                    // column index
5213     const GrB_Descriptor desc       // descriptor for C(:,j) and mask
5214 ) ;
5215 
5216 GB_PUBLIC
5217 GrB_Info GrB_Row_assign             // C<mask'>(i,J) = accum (C(i,J),u')
5218 (
5219     GrB_Matrix C,                   // input/output matrix for results
5220     const GrB_Vector mask,          // optional mask for C(i,:), unused if NULL
5221     const GrB_BinaryOp accum,       // optional accum for z=accum(C(i,J),t)
5222     const GrB_Vector u,             // input vector
5223     GrB_Index i,                    // row index
5224     const GrB_Index *J,             // column indices
5225     GrB_Index nj,                   // number of column indices
5226     const GrB_Descriptor desc       // descriptor for C(i,:) and mask
5227 ) ;
5228 
5229 //------------------------------------------------------------------------------
5230 // GrB_Vector_assign_[SCALAR]:  scalar expansion assignment to subvector
5231 //------------------------------------------------------------------------------
5232 
5233 // Assigns a single scalar to a subvector, w<mask>(I) = accum(w(I),x).  The
5234 // scalar x is implicitly expanded into a vector u of size ni-by-1, with each
5235 // entry in u equal to x, and then w<mask>(I) = accum(w(I),u) is done.
5236 
5237 GB_PUBLIC
5238 GrB_Info GrB_Vector_assign_BOOL     // w<mask>(I) = accum (w(I),x)
5239 (
5240     GrB_Vector w,                   // input/output vector for results
5241     const GrB_Vector mask,          // optional mask for w, unused if NULL
5242     const GrB_BinaryOp accum,       // optional accum for z=accum(w(I),x)
5243     bool x,                         // scalar to assign to w(I)
5244     const GrB_Index *I,             // row indices
5245     GrB_Index ni,                   // number of row indices
5246     const GrB_Descriptor desc       // descriptor for w and mask
5247 ) ;
5248 
5249 GB_PUBLIC
5250 GrB_Info GrB_Vector_assign_INT8     // w<mask>(I) = accum (w(I),x)
5251 (
5252     GrB_Vector w,                   // input/output vector for results
5253     const GrB_Vector mask,          // optional mask for w, unused if NULL
5254     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5255     int8_t x,                       // scalar to assign to w(I)
5256     const GrB_Index *I,             // row indices
5257     GrB_Index ni,                   // number of row indices
5258     const GrB_Descriptor desc       // descriptor for w and mask
5259 ) ;
5260 
5261 GB_PUBLIC
5262 GrB_Info GrB_Vector_assign_UINT8    // w<mask>(I) = accum (w(I),x)
5263 (
5264     GrB_Vector w,                   // input/output vector for results
5265     const GrB_Vector mask,          // optional mask for w, unused if NULL
5266     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5267     uint8_t x,                      // scalar to assign to w(I)
5268     const GrB_Index *I,             // row indices
5269     GrB_Index ni,                   // number of row indices
5270     const GrB_Descriptor desc       // descriptor for w and mask
5271 ) ;
5272 
5273 GB_PUBLIC
5274 GrB_Info GrB_Vector_assign_INT16    // w<mask>(I) = accum (w(I),x)
5275 (
5276     GrB_Vector w,                   // input/output vector for results
5277     const GrB_Vector mask,          // optional mask for w, unused if NULL
5278     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5279     int16_t x,                      // scalar to assign to w(I)
5280     const GrB_Index *I,             // row indices
5281     GrB_Index ni,                   // number of row indices
5282     const GrB_Descriptor desc       // descriptor for w and mask
5283 ) ;
5284 
5285 GB_PUBLIC
5286 GrB_Info GrB_Vector_assign_UINT16   // w<mask>(I) = accum (w(I),x)
5287 (
5288     GrB_Vector w,                   // input/output vector for results
5289     const GrB_Vector mask,          // optional mask for w, unused if NULL
5290     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5291     uint16_t x,                     // scalar to assign to w(I)
5292     const GrB_Index *I,             // row indices
5293     GrB_Index ni,                   // number of row indices
5294     const GrB_Descriptor desc       // descriptor for w and mask
5295 ) ;
5296 
5297 GB_PUBLIC
5298 GrB_Info GrB_Vector_assign_INT32    // w<mask>(I) = accum (w(I),x)
5299 (
5300     GrB_Vector w,                   // input/output vector for results
5301     const GrB_Vector mask,          // optional mask for w, unused if NULL
5302     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5303     int32_t x,                      // scalar to assign to w(I)
5304     const GrB_Index *I,             // row indices
5305     GrB_Index ni,                   // number of row indices
5306     const GrB_Descriptor desc       // descriptor for w and mask
5307 ) ;
5308 
5309 GB_PUBLIC
5310 GrB_Info GrB_Vector_assign_UINT32   // w<mask>(I) = accum (w(I),x)
5311 (
5312     GrB_Vector w,                   // input/output vector for results
5313     const GrB_Vector mask,          // optional mask for w, unused if NULL
5314     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5315     uint32_t x,                     // scalar to assign to w(I)
5316     const GrB_Index *I,             // row indices
5317     GrB_Index ni,                   // number of row indices
5318     const GrB_Descriptor desc       // descriptor for w and mask
5319 ) ;
5320 
5321 GB_PUBLIC
5322 GrB_Info GrB_Vector_assign_INT64    // w<mask>(I) = accum (w(I),x)
5323 (
5324     GrB_Vector w,                   // input/output vector for results
5325     const GrB_Vector mask,          // optional mask for w, unused if NULL
5326     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5327     int64_t x,                      // scalar to assign to w(I)
5328     const GrB_Index *I,             // row indices
5329     GrB_Index ni,                   // number of row indices
5330     const GrB_Descriptor desc       // descriptor for w and mask
5331 ) ;
5332 
5333 GB_PUBLIC
5334 GrB_Info GrB_Vector_assign_UINT64   // w<mask>(I) = accum (w(I),x)
5335 (
5336     GrB_Vector w,                   // input/output vector for results
5337     const GrB_Vector mask,          // optional mask for w, unused if NULL
5338     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5339     uint64_t x,                     // scalar to assign to w(I)
5340     const GrB_Index *I,             // row indices
5341     GrB_Index ni,                   // number of row indices
5342     const GrB_Descriptor desc       // descriptor for w and mask
5343 ) ;
5344 
5345 GB_PUBLIC
5346 GrB_Info GrB_Vector_assign_FP32     // w<mask>(I) = accum (w(I),x)
5347 (
5348     GrB_Vector w,                   // input/output vector for results
5349     const GrB_Vector mask,          // optional mask for w, unused if NULL
5350     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5351     float x,                        // scalar to assign to w(I)
5352     const GrB_Index *I,             // row indices
5353     GrB_Index ni,                   // number of row indices
5354     const GrB_Descriptor desc       // descriptor for w and mask
5355 ) ;
5356 
5357 GB_PUBLIC
5358 GrB_Info GrB_Vector_assign_FP64     // w<mask>(I) = accum (w(I),x)
5359 (
5360     GrB_Vector w,                   // input/output vector for results
5361     const GrB_Vector mask,          // optional mask for w, unused if NULL
5362     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5363     double x,                       // scalar to assign to w(I)
5364     const GrB_Index *I,             // row indices
5365     GrB_Index ni,                   // number of row indices
5366     const GrB_Descriptor desc       // descriptor for w and mask
5367 ) ;
5368 
5369 GB_PUBLIC
5370 GrB_Info GxB_Vector_assign_FC32     // w<mask>(I) = accum (w(I),x)
5371 (
5372     GrB_Vector w,                   // input/output vector for results
5373     const GrB_Vector mask,          // optional mask for w, unused if NULL
5374     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5375     GxB_FC32_t x,                   // scalar to assign to w(I)
5376     const GrB_Index *I,             // row indices
5377     GrB_Index ni,                   // number of row indices
5378     const GrB_Descriptor desc       // descriptor for w and mask
5379 ) ;
5380 
5381 GB_PUBLIC
5382 GrB_Info GxB_Vector_assign_FC64     // w<mask>(I) = accum (w(I),x)
5383 (
5384     GrB_Vector w,                   // input/output vector for results
5385     const GrB_Vector mask,          // optional mask for w, unused if NULL
5386     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5387     GxB_FC64_t x,                   // scalar to assign to w(I)
5388     const GrB_Index *I,             // row indices
5389     GrB_Index ni,                   // number of row indices
5390     const GrB_Descriptor desc       // descriptor for w and mask
5391 ) ;
5392 
5393 GB_PUBLIC
5394 GrB_Info GrB_Vector_assign_UDT      // w<mask>(I) = accum (w(I),x)
5395 (
5396     GrB_Vector w,                   // input/output vector for results
5397     const GrB_Vector mask,          // optional mask for w, unused if NULL
5398     const GrB_BinaryOp accum,       // optional accum for Z=accum(w(I),x)
5399     void *x,                        // scalar to assign to w(I)
5400     const GrB_Index *I,             // row indices
5401     GrB_Index ni,                   // number of row indices
5402     const GrB_Descriptor desc       // descriptor for w and mask
5403 ) ;
5404 
5405 //------------------------------------------------------------------------------
5406 // GrB_Matrix_assign_[SCALAR]:  scalar expansion assignment to submatrix
5407 //------------------------------------------------------------------------------
5408 
5409 // Assigns a single scalar to a submatrix, C<Mask>(I,J) = accum(C(I,J),x).  The
5410 // scalar x is implicitly expanded into a matrix A of size ni-by-nj, with each
5411 // entry in A equal to x, and then C<Mask>(I,J) = accum(C(I,J),A) is done.
5412 
5413 GB_PUBLIC
5414 GrB_Info GrB_Matrix_assign_BOOL     // C<Mask>(I,J) = accum (C(I,J),x)
5415 (
5416     GrB_Matrix C,                   // input/output matrix for results
5417     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5418     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5419     bool x,                         // scalar to assign to C(I,J)
5420     const GrB_Index *I,             // row indices
5421     GrB_Index ni,                   // number of row indices
5422     const GrB_Index *J,             // column indices
5423     GrB_Index nj,                   // number of column indices
5424     const GrB_Descriptor desc       // descriptor for C and Mask
5425 ) ;
5426 
5427 GB_PUBLIC
5428 GrB_Info GrB_Matrix_assign_INT8     // C<Mask>(I,J) = accum (C(I,J),x)
5429 (
5430     GrB_Matrix C,                   // input/output matrix for results
5431     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5432     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5433     int8_t x,                       // scalar to assign to C(I,J)
5434     const GrB_Index *I,             // row indices
5435     GrB_Index ni,                   // number of row indices
5436     const GrB_Index *J,             // column indices
5437     GrB_Index nj,                   // number of column indices
5438     const GrB_Descriptor desc       // descriptor for C and Mask
5439 ) ;
5440 
5441 GB_PUBLIC
5442 GrB_Info GrB_Matrix_assign_UINT8    // C<Mask>(I,J) = accum (C(I,J),x)
5443 (
5444     GrB_Matrix C,                   // input/output matrix for results
5445     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5446     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5447     uint8_t x,                      // scalar to assign to C(I,J)
5448     const GrB_Index *I,             // row indices
5449     GrB_Index ni,                   // number of row indices
5450     const GrB_Index *J,             // column indices
5451     GrB_Index nj,                   // number of column indices
5452     const GrB_Descriptor desc       // descriptor for C and Mask
5453 ) ;
5454 
5455 GB_PUBLIC
5456 GrB_Info GrB_Matrix_assign_INT16    // C<Mask>(I,J) = accum (C(I,J),x)
5457 (
5458     GrB_Matrix C,                   // input/output matrix for results
5459     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5460     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5461     int16_t x,                      // scalar to assign to C(I,J)
5462     const GrB_Index *I,             // row indices
5463     GrB_Index ni,                   // number of row indices
5464     const GrB_Index *J,             // column indices
5465     GrB_Index nj,                   // number of column indices
5466     const GrB_Descriptor desc       // descriptor for C and Mask
5467 ) ;
5468 
5469 GB_PUBLIC
5470 GrB_Info GrB_Matrix_assign_UINT16   // C<Mask>(I,J) = accum (C(I,J),x)
5471 (
5472     GrB_Matrix C,                   // input/output matrix for results
5473     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5474     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5475     uint16_t x,                     // scalar to assign to C(I,J)
5476     const GrB_Index *I,             // row indices
5477     GrB_Index ni,                   // number of row indices
5478     const GrB_Index *J,             // column indices
5479     GrB_Index nj,                   // number of column indices
5480     const GrB_Descriptor desc       // descriptor for C and Mask
5481 ) ;
5482 
5483 GB_PUBLIC
5484 GrB_Info GrB_Matrix_assign_INT32    // C<Mask>(I,J) = accum (C(I,J),x)
5485 (
5486     GrB_Matrix C,                   // input/output matrix for results
5487     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5488     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5489     int32_t x,                      // scalar to assign to C(I,J)
5490     const GrB_Index *I,             // row indices
5491     GrB_Index ni,                   // number of row indices
5492     const GrB_Index *J,             // column indices
5493     GrB_Index nj,                   // number of column indices
5494     const GrB_Descriptor desc       // descriptor for C and Mask
5495 ) ;
5496 
5497 GB_PUBLIC
5498 GrB_Info GrB_Matrix_assign_UINT32   // C<Mask>(I,J) = accum (C(I,J),x)
5499 (
5500     GrB_Matrix C,                   // input/output matrix for results
5501     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5502     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5503     uint32_t x,                     // scalar to assign to C(I,J)
5504     const GrB_Index *I,             // row indices
5505     GrB_Index ni,                   // number of row indices
5506     const GrB_Index *J,             // column indices
5507     GrB_Index nj,                   // number of column indices
5508     const GrB_Descriptor desc       // descriptor for C and Mask
5509 ) ;
5510 
5511 GB_PUBLIC
5512 GrB_Info GrB_Matrix_assign_INT64    // C<Mask>(I,J) = accum (C(I,J),x)
5513 (
5514     GrB_Matrix C,                   // input/output matrix for results
5515     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5516     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5517     int64_t x,                      // scalar to assign to C(I,J)
5518     const GrB_Index *I,             // row indices
5519     GrB_Index ni,                   // number of row indices
5520     const GrB_Index *J,             // column indices
5521     GrB_Index nj,                   // number of column indices
5522     const GrB_Descriptor desc       // descriptor for C and Mask
5523 ) ;
5524 
5525 GB_PUBLIC
5526 GrB_Info GrB_Matrix_assign_UINT64   // C<Mask>(I,J) = accum (C(I,J),x)
5527 (
5528     GrB_Matrix C,                   // input/output matrix for results
5529     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5530     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5531     uint64_t x,                     // scalar to assign to C(I,J)
5532     const GrB_Index *I,             // row indices
5533     GrB_Index ni,                   // number of row indices
5534     const GrB_Index *J,             // column indices
5535     GrB_Index nj,                   // number of column indices
5536     const GrB_Descriptor desc       // descriptor for C and Mask
5537 ) ;
5538 
5539 GB_PUBLIC
5540 GrB_Info GrB_Matrix_assign_FP32     // C<Mask>(I,J) = accum (C(I,J),x)
5541 (
5542     GrB_Matrix C,                   // input/output matrix for results
5543     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5544     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5545     float x,                        // scalar to assign to C(I,J)
5546     const GrB_Index *I,             // row indices
5547     GrB_Index ni,                   // number of row indices
5548     const GrB_Index *J,             // column indices
5549     GrB_Index nj,                   // number of column indices
5550     const GrB_Descriptor desc       // descriptor for C and Mask
5551 ) ;
5552 
5553 GB_PUBLIC
5554 GrB_Info GrB_Matrix_assign_FP64     // C<Mask>(I,J) = accum (C(I,J),x)
5555 (
5556     GrB_Matrix C,                   // input/output matrix for results
5557     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5558     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5559     double x,                       // scalar to assign to C(I,J)
5560     const GrB_Index *I,             // row indices
5561     GrB_Index ni,                   // number of row indices
5562     const GrB_Index *J,             // column indices
5563     GrB_Index nj,                   // number of column indices
5564     const GrB_Descriptor desc       // descriptor for C and Mask
5565 ) ;
5566 
5567 GB_PUBLIC
5568 GrB_Info GxB_Matrix_assign_FC32     // C<Mask>(I,J) = accum (C(I,J),x)
5569 (
5570     GrB_Matrix C,                   // input/output matrix for results
5571     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5572     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5573     GxB_FC32_t x,                   // scalar to assign to C(I,J)
5574     const GrB_Index *I,             // row indices
5575     GrB_Index ni,                   // number of row indices
5576     const GrB_Index *J,             // column indices
5577     GrB_Index nj,                   // number of column indices
5578     const GrB_Descriptor desc       // descriptor for C and Mask
5579 ) ;
5580 
5581 GB_PUBLIC
5582 GrB_Info GxB_Matrix_assign_FC64     // C<Mask>(I,J) = accum (C(I,J),x)
5583 (
5584     GrB_Matrix C,                   // input/output matrix for results
5585     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5586     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5587     GxB_FC64_t x,                   // scalar to assign to C(I,J)
5588     const GrB_Index *I,             // row indices
5589     GrB_Index ni,                   // number of row indices
5590     const GrB_Index *J,             // column indices
5591     GrB_Index nj,                   // number of column indices
5592     const GrB_Descriptor desc       // descriptor for C and Mask
5593 ) ;
5594 
5595 GB_PUBLIC
5596 GrB_Info GrB_Matrix_assign_UDT      // C<Mask>(I,J) = accum (C(I,J),x)
5597 (
5598     GrB_Matrix C,                   // input/output matrix for results
5599     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5600     const GrB_BinaryOp accum,       // optional accum for Z=accum(C(I,J),x)
5601     void *x,                        // scalar to assign to C(I,J)
5602     const GrB_Index *I,             // row indices
5603     GrB_Index ni,                   // number of row indices
5604     const GrB_Index *J,             // column indices
5605     GrB_Index nj,                   // number of column indices
5606     const GrB_Descriptor desc       // descriptor for C and Mask
5607 ) ;
5608 
5609 //------------------------------------------------------------------------------
5610 // GrB_assign: generic submatrix/subvector assignment
5611 //------------------------------------------------------------------------------
5612 
5613 // GrB_assign is a generic function that provides access to all specific
5614 // GrB_*_assign* functions:
5615 
5616 // GrB_Vector_assign   (w,m,acc,u,I,ni,d)      // w<m>(I)    = acc(w(I),u)
5617 // GrB_Matrix_assign   (C,M,acc,A,I,ni,J,nj,d) // C<M>(I,J)  = acc(C(I,J),A)
5618 // GrB_Col_assign      (C,m,acc,u,I,ni,j,d)    // C<m>(I,j)  = acc(C(I,j),u)
5619 // GrB_Row_assign      (C,m,acc,u,i,J,nj,d)    // C<m'>(i,J) = acc(C(i,J),u')
5620 // GrB_Vector_assign_T (w,m,acc,x,I,ni,d)      // w<m>(I)    = acc(w(I),x)
5621 // GrB_Matrix_assign_T (C,M,acc,x,I,ni,J,nj,d) // C<M>(I,J)  = acc(C(I,J),x)
5622 
5623 #if GxB_STDC_VERSION >= 201112L
5624 #define GrB_assign(arg1,Mask,accum,arg4,arg5,...)               \
5625     _Generic                                                    \
5626     (                                                           \
5627         (arg1),                                                 \
5628         GrB_Vector :                                            \
5629             _Generic                                            \
5630             (                                                   \
5631                 (arg4),                                         \
5632                 GB_CASES (, GrB, Vector_assign) ,               \
5633                 default : GrB_Vector_assign                     \
5634             ),                                                  \
5635         default :                                               \
5636             _Generic                                            \
5637             (                                                   \
5638                 (arg4),                                         \
5639                 GB_CASES (, GrB, Matrix_assign) ,               \
5640                 const GrB_Vector :                              \
5641                     _Generic                                    \
5642                     (                                           \
5643                         (arg5),                                 \
5644                         const GrB_Index *: GrB_Col_assign ,     \
5645                               GrB_Index *: GrB_Col_assign ,     \
5646                         default          : GrB_Row_assign       \
5647                     ),                                          \
5648                 GrB_Vector :                                    \
5649                     _Generic                                    \
5650                     (                                           \
5651                         (arg5),                                 \
5652                         const GrB_Index *: GrB_Col_assign ,     \
5653                               GrB_Index *: GrB_Col_assign ,     \
5654                         default          : GrB_Row_assign       \
5655                     ),                                          \
5656                 default    : GrB_Matrix_assign                  \
5657             )                                                   \
5658     )                                                           \
5659     (arg1, Mask, accum, arg4, arg5, __VA_ARGS__)
5660 #endif
5661 
5662 //==============================================================================
5663 // GrB_apply: matrix and vector apply
5664 //==============================================================================
5665 
5666 // Apply a unary operator to entries in a matrix or vector,
5667 // C<M> = accum (C, op (A)).
5668 
5669 GB_PUBLIC
5670 GrB_Info GrB_Vector_apply           // w<mask> = accum (w, op(u))
5671 (
5672     GrB_Vector w,                   // input/output vector for results
5673     const GrB_Vector mask,          // optional mask for w, unused if NULL
5674     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5675     const GrB_UnaryOp op,           // operator to apply to the entries
5676     const GrB_Vector u,             // first input:  vector u
5677     const GrB_Descriptor desc       // descriptor for w and mask
5678 ) ;
5679 
5680 GB_PUBLIC
5681 GrB_Info GrB_Matrix_apply           // C<Mask> = accum (C, op(A)) or op(A')
5682 (
5683     GrB_Matrix C,                   // input/output matrix for results
5684     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
5685     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
5686     const GrB_UnaryOp op,           // operator to apply to the entries
5687     const GrB_Matrix A,             // first input:  matrix A
5688     const GrB_Descriptor desc       // descriptor for C, mask, and A
5689 ) ;
5690 
5691 //-------------------------------------------
5692 // vector apply: binaryop variants (bind 1st)
5693 //-------------------------------------------
5694 
5695 // Apply a binary operator to the entries in a vector, binding the first
5696 // input to a scalar x, w<mask> = accum (w, op (x,u)).
5697 
5698 GB_PUBLIC
5699 GrB_Info GxB_Vector_apply_BinaryOp1st           // w<mask> = accum (w, op(x,u))
5700 (
5701     GrB_Vector w,                   // input/output vector for results
5702     const GrB_Vector mask,          // optional mask for w, unused if NULL
5703     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5704     const GrB_BinaryOp op,          // operator to apply to the entries
5705     const GxB_Scalar x,             // first input:  scalar x
5706     const GrB_Vector u,             // second input: vector u
5707     const GrB_Descriptor desc       // descriptor for w and mask
5708 ) ;
5709 
5710 GB_PUBLIC
5711 GrB_Info GrB_Vector_apply_BinaryOp1st_BOOL      // w<mask> = accum (w, op(x,u))
5712 (
5713     GrB_Vector w,                   // input/output vector for results
5714     const GrB_Vector mask,          // optional mask for w, unused if NULL
5715     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5716     const GrB_BinaryOp op,          // operator to apply to the entries
5717     bool x,                         // first input:  scalar x
5718     const GrB_Vector u,             // second input: vector u
5719     const GrB_Descriptor desc       // descriptor for w and mask
5720 ) ;
5721 
5722 GB_PUBLIC
5723 GrB_Info GrB_Vector_apply_BinaryOp1st_INT8      // w<mask> = accum (w, op(x,u))
5724 (
5725     GrB_Vector w,                   // input/output vector for results
5726     const GrB_Vector mask,          // optional mask for w, unused if NULL
5727     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5728     const GrB_BinaryOp op,          // operator to apply to the entries
5729     int8_t x,                       // first input:  scalar x
5730     const GrB_Vector u,             // second input: vector u
5731     const GrB_Descriptor desc       // descriptor for w and mask
5732 ) ;
5733 
5734 GB_PUBLIC
5735 GrB_Info GrB_Vector_apply_BinaryOp1st_INT16     // w<mask> = accum (w, op(x,u))
5736 (
5737     GrB_Vector w,                   // input/output vector for results
5738     const GrB_Vector mask,          // optional mask for w, unused if NULL
5739     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5740     const GrB_BinaryOp op,          // operator to apply to the entries
5741     int16_t x,                      // first input:  scalar x
5742     const GrB_Vector u,             // second input: vector u
5743     const GrB_Descriptor desc       // descriptor for w and mask
5744 ) ;
5745 
5746 GB_PUBLIC
5747 GrB_Info GrB_Vector_apply_BinaryOp1st_INT32     // w<mask> = accum (w, op(x,u))
5748 (
5749     GrB_Vector w,                   // input/output vector for results
5750     const GrB_Vector mask,          // optional mask for w, unused if NULL
5751     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5752     const GrB_BinaryOp op,          // operator to apply to the entries
5753     int32_t x,                      // first input:  scalar x
5754     const GrB_Vector u,             // second input: vector u
5755     const GrB_Descriptor desc       // descriptor for w and mask
5756 ) ;
5757 
5758 GB_PUBLIC
5759 GrB_Info GrB_Vector_apply_BinaryOp1st_INT64     // w<mask> = accum (w, op(x,u))
5760 (
5761     GrB_Vector w,                   // input/output vector for results
5762     const GrB_Vector mask,          // optional mask for w, unused if NULL
5763     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5764     const GrB_BinaryOp op,          // operator to apply to the entries
5765     int64_t x,                      // first input:  scalar x
5766     const GrB_Vector u,             // second input: vector u
5767     const GrB_Descriptor desc       // descriptor for w and mask
5768 ) ;
5769 
5770 GB_PUBLIC
5771 GrB_Info GrB_Vector_apply_BinaryOp1st_UINT8     // w<mask> = accum (w, op(x,u))
5772 (
5773     GrB_Vector w,                   // input/output vector for results
5774     const GrB_Vector mask,          // optional mask for w, unused if NULL
5775     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5776     const GrB_BinaryOp op,          // operator to apply to the entries
5777     uint8_t x,                      // first input:  scalar x
5778     const GrB_Vector u,             // second input: vector u
5779     const GrB_Descriptor desc       // descriptor for w and mask
5780 ) ;
5781 
5782 GB_PUBLIC
5783 GrB_Info GrB_Vector_apply_BinaryOp1st_UINT16    // w<mask> = accum (w, op(x,u))
5784 (
5785     GrB_Vector w,                   // input/output vector for results
5786     const GrB_Vector mask,          // optional mask for w, unused if NULL
5787     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5788     const GrB_BinaryOp op,          // operator to apply to the entries
5789     uint16_t x,                     // first input:  scalar x
5790     const GrB_Vector u,             // second input: vector u
5791     const GrB_Descriptor desc       // descriptor for w and mask
5792 ) ;
5793 
5794 GB_PUBLIC
5795 GrB_Info GrB_Vector_apply_BinaryOp1st_UINT32    // w<mask> = accum (w, op(x,u))
5796 (
5797     GrB_Vector w,                   // input/output vector for results
5798     const GrB_Vector mask,          // optional mask for w, unused if NULL
5799     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5800     const GrB_BinaryOp op,          // operator to apply to the entries
5801     uint32_t x,                     // first input:  scalar x
5802     const GrB_Vector u,             // second input: vector u
5803     const GrB_Descriptor desc       // descriptor for w and mask
5804 ) ;
5805 
5806 GB_PUBLIC
5807 GrB_Info GrB_Vector_apply_BinaryOp1st_UINT64    // w<mask> = accum (w, op(x,u))
5808 (
5809     GrB_Vector w,                   // input/output vector for results
5810     const GrB_Vector mask,          // optional mask for w, unused if NULL
5811     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5812     const GrB_BinaryOp op,          // operator to apply to the entries
5813     uint64_t x,                     // first input:  scalar x
5814     const GrB_Vector u,             // second input: vector u
5815     const GrB_Descriptor desc       // descriptor for w and mask
5816 ) ;
5817 
5818 GB_PUBLIC
5819 GrB_Info GrB_Vector_apply_BinaryOp1st_FP32      // w<mask> = accum (w, op(x,u))
5820 (
5821     GrB_Vector w,                   // input/output vector for results
5822     const GrB_Vector mask,          // optional mask for w, unused if NULL
5823     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5824     const GrB_BinaryOp op,          // operator to apply to the entries
5825     float x,                        // first input:  scalar x
5826     const GrB_Vector u,             // second input: vector u
5827     const GrB_Descriptor desc       // descriptor for w and mask
5828 ) ;
5829 
5830 GB_PUBLIC
5831 GrB_Info GrB_Vector_apply_BinaryOp1st_FP64      // w<mask> = accum (w, op(x,u))
5832 (
5833     GrB_Vector w,                   // input/output vector for results
5834     const GrB_Vector mask,          // optional mask for w, unused if NULL
5835     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5836     const GrB_BinaryOp op,          // operator to apply to the entries
5837     double x,                       // first input:  scalar x
5838     const GrB_Vector u,             // second input: vector u
5839     const GrB_Descriptor desc       // descriptor for w and mask
5840 ) ;
5841 
5842 GB_PUBLIC
5843 GrB_Info GxB_Vector_apply_BinaryOp1st_FC32      // w<mask> = accum (w, op(x,u))
5844 (
5845     GrB_Vector w,                   // input/output vector for results
5846     const GrB_Vector mask,          // optional mask for w, unused if NULL
5847     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5848     const GrB_BinaryOp op,          // operator to apply to the entries
5849     GxB_FC32_t x,                   // first input:  scalar x
5850     const GrB_Vector u,             // second input: vector u
5851     const GrB_Descriptor desc       // descriptor for w and mask
5852 ) ;
5853 
5854 GB_PUBLIC
5855 GrB_Info GxB_Vector_apply_BinaryOp1st_FC64      // w<mask> = accum (w, op(x,u))
5856 (
5857     GrB_Vector w,                   // input/output vector for results
5858     const GrB_Vector mask,          // optional mask for w, unused if NULL
5859     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5860     const GrB_BinaryOp op,          // operator to apply to the entries
5861     GxB_FC64_t x,                   // first input:  scalar x
5862     const GrB_Vector u,             // second input: vector u
5863     const GrB_Descriptor desc       // descriptor for w and mask
5864 ) ;
5865 
5866 GB_PUBLIC
5867 GrB_Info GrB_Vector_apply_BinaryOp1st_UDT       // w<mask> = accum (w, op(x,u))
5868 (
5869     GrB_Vector w,                   // input/output vector for results
5870     const GrB_Vector mask,          // optional mask for w, unused if NULL
5871     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5872     const GrB_BinaryOp op,          // operator to apply to the entries
5873     const void *x,                  // first input:  scalar x
5874     const GrB_Vector u,             // second input: vector u
5875     const GrB_Descriptor desc       // descriptor for w and mask
5876 ) ;
5877 
5878 //-------------------------------------------
5879 // vector apply: binaryop variants (bind 2nd)
5880 //-------------------------------------------
5881 
5882 // Apply a binary operator to the entries in a vector, binding the second
5883 // input to a scalar y, w<mask> = accum (w, op (u,y)).
5884 
5885 GB_PUBLIC
5886 GrB_Info GxB_Vector_apply_BinaryOp2nd           // w<mask> = accum (w, op(u,y))
5887 (
5888     GrB_Vector w,                   // input/output vector for results
5889     const GrB_Vector mask,          // optional mask for w, unused if NULL
5890     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5891     const GrB_BinaryOp op,          // operator to apply to the entries
5892     const GrB_Vector u,             // first input:  vector u
5893     const GxB_Scalar y,             // second input: scalar y
5894     const GrB_Descriptor desc       // descriptor for w and mask
5895 ) ;
5896 
5897 GB_PUBLIC
5898 GrB_Info GrB_Vector_apply_BinaryOp2nd_BOOL      // w<mask> = accum (w, op(u,y))
5899 (
5900     GrB_Vector w,                   // input/output vector for results
5901     const GrB_Vector mask,          // optional mask for w, unused if NULL
5902     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5903     const GrB_BinaryOp op,          // operator to apply to the entries
5904     const GrB_Vector u,             // first input:  vector u
5905     bool y,                         // second input: scalar y
5906     const GrB_Descriptor desc       // descriptor for w and mask
5907 ) ;
5908 
5909 GB_PUBLIC
5910 GrB_Info GrB_Vector_apply_BinaryOp2nd_INT8      // w<mask> = accum (w, op(u,y))
5911 (
5912     GrB_Vector w,                   // input/output vector for results
5913     const GrB_Vector mask,          // optional mask for w, unused if NULL
5914     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5915     const GrB_BinaryOp op,          // operator to apply to the entries
5916     const GrB_Vector u,             // first input:  vector u
5917     int8_t y,                       // second input: scalar y
5918     const GrB_Descriptor desc       // descriptor for w and mask
5919 ) ;
5920 
5921 GB_PUBLIC
5922 GrB_Info GrB_Vector_apply_BinaryOp2nd_INT16     // w<mask> = accum (w, op(u,y))
5923 (
5924     GrB_Vector w,                   // input/output vector for results
5925     const GrB_Vector mask,          // optional mask for w, unused if NULL
5926     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5927     const GrB_BinaryOp op,          // operator to apply to the entries
5928     const GrB_Vector u,             // first input:  vector u
5929     int16_t y,                      // second input: scalar y
5930     const GrB_Descriptor desc       // descriptor for w and mask
5931 ) ;
5932 
5933 GB_PUBLIC
5934 GrB_Info GrB_Vector_apply_BinaryOp2nd_INT32     // w<mask> = accum (w, op(u,y))
5935 (
5936     GrB_Vector w,                   // input/output vector for results
5937     const GrB_Vector mask,          // optional mask for w, unused if NULL
5938     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5939     const GrB_BinaryOp op,          // operator to apply to the entries
5940     const GrB_Vector u,             // first input:  vector u
5941     int32_t y,                      // second input: scalar y
5942     const GrB_Descriptor desc       // descriptor for w and mask
5943 ) ;
5944 
5945 GB_PUBLIC
5946 GrB_Info GrB_Vector_apply_BinaryOp2nd_INT64     // w<mask> = accum (w, op(u,y))
5947 (
5948     GrB_Vector w,                   // input/output vector for results
5949     const GrB_Vector mask,          // optional mask for w, unused if NULL
5950     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5951     const GrB_BinaryOp op,          // operator to apply to the entries
5952     const GrB_Vector u,             // first input:  vector u
5953     int64_t y,                      // second input: scalar y
5954     const GrB_Descriptor desc       // descriptor for w and mask
5955 ) ;
5956 
5957 GB_PUBLIC
5958 GrB_Info GrB_Vector_apply_BinaryOp2nd_UINT8     // w<mask> = accum (w, op(u,y))
5959 (
5960     GrB_Vector w,                   // input/output vector for results
5961     const GrB_Vector mask,          // optional mask for w, unused if NULL
5962     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5963     const GrB_BinaryOp op,          // operator to apply to the entries
5964     const GrB_Vector u,             // first input:  vector u
5965     uint8_t y,                      // second input: scalar y
5966     const GrB_Descriptor desc       // descriptor for w and mask
5967 ) ;
5968 
5969 GB_PUBLIC
5970 GrB_Info GrB_Vector_apply_BinaryOp2nd_UINT16    // w<mask> = accum (w, op(u,y))
5971 (
5972     GrB_Vector w,                   // input/output vector for results
5973     const GrB_Vector mask,          // optional mask for w, unused if NULL
5974     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5975     const GrB_BinaryOp op,          // operator to apply to the entries
5976     const GrB_Vector u,             // first input:  vector u
5977     uint16_t y,                     // second input: scalar y
5978     const GrB_Descriptor desc       // descriptor for w and mask
5979 ) ;
5980 
5981 GB_PUBLIC
5982 GrB_Info GrB_Vector_apply_BinaryOp2nd_UINT32    // w<mask> = accum (w, op(u,y))
5983 (
5984     GrB_Vector w,                   // input/output vector for results
5985     const GrB_Vector mask,          // optional mask for w, unused if NULL
5986     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5987     const GrB_BinaryOp op,          // operator to apply to the entries
5988     const GrB_Vector u,             // first input:  vector u
5989     uint32_t y,                     // second input: scalar y
5990     const GrB_Descriptor desc       // descriptor for w and mask
5991 ) ;
5992 
5993 GB_PUBLIC
5994 GrB_Info GrB_Vector_apply_BinaryOp2nd_UINT64    // w<mask> = accum (w, op(u,y))
5995 (
5996     GrB_Vector w,                   // input/output vector for results
5997     const GrB_Vector mask,          // optional mask for w, unused if NULL
5998     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
5999     const GrB_BinaryOp op,          // operator to apply to the entries
6000     const GrB_Vector u,             // first input:  vector u
6001     uint64_t y,                     // second input: scalar y
6002     const GrB_Descriptor desc       // descriptor for w and mask
6003 ) ;
6004 
6005 GB_PUBLIC
6006 GrB_Info GrB_Vector_apply_BinaryOp2nd_FP32      // w<mask> = accum (w, op(u,y))
6007 (
6008     GrB_Vector w,                   // input/output vector for results
6009     const GrB_Vector mask,          // optional mask for w, unused if NULL
6010     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6011     const GrB_BinaryOp op,          // operator to apply to the entries
6012     const GrB_Vector u,             // first input:  vector u
6013     float y,                        // second input: scalar y
6014     const GrB_Descriptor desc       // descriptor for w and mask
6015 ) ;
6016 
6017 GB_PUBLIC
6018 GrB_Info GrB_Vector_apply_BinaryOp2nd_FP64      // w<mask> = accum (w, op(u,y))
6019 (
6020     GrB_Vector w,                   // input/output vector for results
6021     const GrB_Vector mask,          // optional mask for w, unused if NULL
6022     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6023     const GrB_BinaryOp op,          // operator to apply to the entries
6024     const GrB_Vector u,             // first input:  vector u
6025     double y,                       // second input: scalar y
6026     const GrB_Descriptor desc       // descriptor for w and mask
6027 ) ;
6028 
6029 GB_PUBLIC
6030 GrB_Info GxB_Vector_apply_BinaryOp2nd_FC32      // w<mask> = accum (w, op(u,y))
6031 (
6032     GrB_Vector w,                   // input/output vector for results
6033     const GrB_Vector mask,          // optional mask for w, unused if NULL
6034     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6035     const GrB_BinaryOp op,          // operator to apply to the entries
6036     const GrB_Vector u,             // first input:  vector u
6037     GxB_FC32_t y,                   // second input: scalar y
6038     const GrB_Descriptor desc       // descriptor for w and mask
6039 ) ;
6040 
6041 GB_PUBLIC
6042 GrB_Info GxB_Vector_apply_BinaryOp2nd_FC64      // w<mask> = accum (w, op(u,y))
6043 (
6044     GrB_Vector w,                   // input/output vector for results
6045     const GrB_Vector mask,          // optional mask for w, unused if NULL
6046     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6047     const GrB_BinaryOp op,          // operator to apply to the entries
6048     const GrB_Vector u,             // first input:  vector u
6049     GxB_FC64_t y,                   // second input: scalar y
6050     const GrB_Descriptor desc       // descriptor for w and mask
6051 ) ;
6052 
6053 GB_PUBLIC
6054 GrB_Info GrB_Vector_apply_BinaryOp2nd_UDT       // w<mask> = accum (w, op(u,y))
6055 (
6056     GrB_Vector w,                   // input/output vector for results
6057     const GrB_Vector mask,          // optional mask for w, unused if NULL
6058     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6059     const GrB_BinaryOp op,          // operator to apply to the entries
6060     const GrB_Vector u,             // first input:  vector u
6061     const void *y,                  // second input: scalar y
6062     const GrB_Descriptor desc       // descriptor for w and mask
6063 ) ;
6064 
6065 //-------------------------------------------
6066 // matrix apply: binaryop variants (bind 1st)
6067 //-------------------------------------------
6068 
6069 // Apply a binary operator to the entries in a matrix, binding the first input
6070 // to a scalar x, C<Mask> = accum (C, op (x,A)), or op(x,A').
6071 
6072 GB_PUBLIC
6073 GrB_Info GxB_Matrix_apply_BinaryOp1st           // C<M>=accum(C,op(x,A))
6074 (
6075     GrB_Matrix C,                   // input/output matrix for results
6076     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6077     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6078     const GrB_BinaryOp op,          // operator to apply to the entries
6079     const GxB_Scalar x,             // first input:  scalar x
6080     const GrB_Matrix A,             // second input: matrix A
6081     const GrB_Descriptor desc       // descriptor for C, mask, and A
6082 ) ;
6083 
6084 GB_PUBLIC
6085 GrB_Info GrB_Matrix_apply_BinaryOp1st_BOOL      // C<M>=accum(C,op(x,A))
6086 (
6087     GrB_Matrix C,                   // input/output matrix for results
6088     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6089     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6090     const GrB_BinaryOp op,          // operator to apply to the entries
6091     bool x,                         // first input:  scalar x
6092     const GrB_Matrix A,             // second input: matrix A
6093     const GrB_Descriptor desc       // descriptor for C, mask, and A
6094 ) ;
6095 
6096 GB_PUBLIC
6097 GrB_Info GrB_Matrix_apply_BinaryOp1st_INT8      // C<M>=accum(C,op(x,A))
6098 (
6099     GrB_Matrix C,                   // input/output matrix for results
6100     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6101     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6102     const GrB_BinaryOp op,          // operator to apply to the entries
6103     int8_t x,                       // first input:  scalar x
6104     const GrB_Matrix A,             // second input: matrix A
6105     const GrB_Descriptor desc       // descriptor for C, mask, and A
6106 ) ;
6107 
6108 GB_PUBLIC
6109 GrB_Info GrB_Matrix_apply_BinaryOp1st_INT16     // C<M>=accum(C,op(x,A))
6110 (
6111     GrB_Matrix C,                   // input/output matrix for results
6112     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6113     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6114     const GrB_BinaryOp op,          // operator to apply to the entries
6115     int16_t x,                      // first input:  scalar x
6116     const GrB_Matrix A,             // second input: matrix A
6117     const GrB_Descriptor desc       // descriptor for C, mask, and A
6118 ) ;
6119 
6120 GB_PUBLIC
6121 GrB_Info GrB_Matrix_apply_BinaryOp1st_INT32     // C<M>=accum(C,op(x,A))
6122 (
6123     GrB_Matrix C,                   // input/output matrix for results
6124     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6125     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6126     const GrB_BinaryOp op,          // operator to apply to the entries
6127     int32_t x,                      // first input:  scalar x
6128     const GrB_Matrix A,             // second input: matrix A
6129     const GrB_Descriptor desc       // descriptor for C, mask, and A
6130 ) ;
6131 
6132 GB_PUBLIC
6133 GrB_Info GrB_Matrix_apply_BinaryOp1st_INT64     // C<M>=accum(C,op(x,A))
6134 (
6135     GrB_Matrix C,                   // input/output matrix for results
6136     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6137     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6138     const GrB_BinaryOp op,          // operator to apply to the entries
6139     int64_t x,                      // first input:  scalar x
6140     const GrB_Matrix A,             // second input: matrix A
6141     const GrB_Descriptor desc       // descriptor for C, mask, and A
6142 ) ;
6143 
6144 GB_PUBLIC
6145 GrB_Info GrB_Matrix_apply_BinaryOp1st_UINT8      // C<M>=accum(C,op(x,A))
6146 (
6147     GrB_Matrix C,                   // input/output matrix for results
6148     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6149     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6150     const GrB_BinaryOp op,          // operator to apply to the entries
6151     uint8_t x,                      // first input:  scalar x
6152     const GrB_Matrix A,             // second input: matrix A
6153     const GrB_Descriptor desc       // descriptor for C, mask, and A
6154 ) ;
6155 
6156 GB_PUBLIC
6157 GrB_Info GrB_Matrix_apply_BinaryOp1st_UINT16     // C<M>=accum(C,op(x,A))
6158 (
6159     GrB_Matrix C,                   // input/output matrix for results
6160     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6161     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6162     const GrB_BinaryOp op,          // operator to apply to the entries
6163     uint16_t x,                     // first input:  scalar x
6164     const GrB_Matrix A,             // second input: matrix A
6165     const GrB_Descriptor desc       // descriptor for C, mask, and A
6166 ) ;
6167 
6168 GB_PUBLIC
6169 GrB_Info GrB_Matrix_apply_BinaryOp1st_UINT32     // C<M>=accum(C,op(x,A))
6170 (
6171     GrB_Matrix C,                   // input/output matrix for results
6172     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6173     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6174     const GrB_BinaryOp op,          // operator to apply to the entries
6175     uint32_t x,                     // first input:  scalar x
6176     const GrB_Matrix A,             // second input: matrix A
6177     const GrB_Descriptor desc       // descriptor for C, mask, and A
6178 ) ;
6179 
6180 GB_PUBLIC
6181 GrB_Info GrB_Matrix_apply_BinaryOp1st_UINT64     // C<M>=accum(C,op(x,A))
6182 (
6183     GrB_Matrix C,                   // input/output matrix for results
6184     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6185     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6186     const GrB_BinaryOp op,          // operator to apply to the entries
6187     uint64_t x,                     // first input:  scalar x
6188     const GrB_Matrix A,             // second input: matrix A
6189     const GrB_Descriptor desc       // descriptor for C, mask, and A
6190 ) ;
6191 
6192 GB_PUBLIC
6193 GrB_Info GrB_Matrix_apply_BinaryOp1st_FP32      // C<M>=accum(C,op(x,A))
6194 (
6195     GrB_Matrix C,                   // input/output matrix for results
6196     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6197     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6198     const GrB_BinaryOp op,          // operator to apply to the entries
6199     float x,                        // first input:  scalar x
6200     const GrB_Matrix A,             // second input: matrix A
6201     const GrB_Descriptor desc       // descriptor for C, mask, and A
6202 ) ;
6203 
6204 GB_PUBLIC
6205 GrB_Info GrB_Matrix_apply_BinaryOp1st_FP64      // C<M>=accum(C,op(x,A))
6206 (
6207     GrB_Matrix C,                   // input/output matrix for results
6208     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6209     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6210     const GrB_BinaryOp op,          // operator to apply to the entries
6211     double x,                       // first input:  scalar x
6212     const GrB_Matrix A,             // second input: matrix A
6213     const GrB_Descriptor desc       // descriptor for C, mask, and A
6214 ) ;
6215 
6216 GB_PUBLIC
6217 GrB_Info GxB_Matrix_apply_BinaryOp1st_FC32      // C<M>=accum(C,op(x,A))
6218 (
6219     GrB_Matrix C,                   // input/output matrix for results
6220     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6221     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6222     const GrB_BinaryOp op,          // operator to apply to the entries
6223     GxB_FC32_t x,                   // first input:  scalar x
6224     const GrB_Matrix A,             // second input: matrix A
6225     const GrB_Descriptor desc       // descriptor for C, mask, and A
6226 ) ;
6227 
6228 GB_PUBLIC
6229 GrB_Info GxB_Matrix_apply_BinaryOp1st_FC64      // C<M>=accum(C,op(x,A))
6230 (
6231     GrB_Matrix C,                   // input/output matrix for results
6232     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6233     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6234     const GrB_BinaryOp op,          // operator to apply to the entries
6235     GxB_FC64_t x,                   // first input:  scalar x
6236     const GrB_Matrix A,             // second input: matrix A
6237     const GrB_Descriptor desc       // descriptor for C, mask, and A
6238 ) ;
6239 
6240 GB_PUBLIC
6241 GrB_Info GrB_Matrix_apply_BinaryOp1st_UDT       // C<M>=accum(C,op(x,A))
6242 (
6243     GrB_Matrix C,                   // input/output matrix for results
6244     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6245     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6246     const GrB_BinaryOp op,          // operator to apply to the entries
6247     const void *x,                  // first input:  scalar x
6248     const GrB_Matrix A,             // second input: matrix A
6249     const GrB_Descriptor desc       // descriptor for C, mask, and A
6250 ) ;
6251 
6252 //-------------------------------------------
6253 // matrix apply: binaryop variants (bind 2nd)
6254 //-------------------------------------------
6255 
6256 // Apply a binary operator to the entries in a matrix, binding the second input
6257 // to a scalar y, C<Mask> = accum (C, op (A,y)), or op(A',y).
6258 
6259 GB_PUBLIC
6260 GrB_Info GxB_Matrix_apply_BinaryOp2nd           // C<M>=accum(C,op(x,A))
6261 (
6262     GrB_Matrix C,                   // input/output matrix for results
6263     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6264     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6265     const GrB_BinaryOp op,          // operator to apply to the entries
6266     const GrB_Matrix A,             // first input:  matrix A
6267     const GxB_Scalar y,             // second input: scalar y
6268     const GrB_Descriptor desc       // descriptor for C, mask, and A
6269 ) ;
6270 
6271 GB_PUBLIC
6272 GrB_Info GrB_Matrix_apply_BinaryOp2nd_BOOL      // C<M>=accum(C,op(x,A))
6273 (
6274     GrB_Matrix C,                   // input/output matrix for results
6275     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6276     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6277     const GrB_BinaryOp op,          // operator to apply to the entries
6278     const GrB_Matrix A,             // first input:  matrix A
6279     bool y,                         // second input: scalar y
6280     const GrB_Descriptor desc       // descriptor for C, mask, and A
6281 ) ;
6282 
6283 GB_PUBLIC
6284 GrB_Info GrB_Matrix_apply_BinaryOp2nd_INT8      // C<M>=accum(C,op(x,A))
6285 (
6286     GrB_Matrix C,                   // input/output matrix for results
6287     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6288     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6289     const GrB_BinaryOp op,          // operator to apply to the entries
6290     const GrB_Matrix A,             // first input:  matrix A
6291     int8_t y,                       // second input: scalar y
6292     const GrB_Descriptor desc       // descriptor for C, mask, and A
6293 ) ;
6294 
6295 GB_PUBLIC
6296 GrB_Info GrB_Matrix_apply_BinaryOp2nd_INT16     // C<M>=accum(C,op(x,A))
6297 (
6298     GrB_Matrix C,                   // input/output matrix for results
6299     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6300     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6301     const GrB_BinaryOp op,          // operator to apply to the entries
6302     const GrB_Matrix A,             // first input:  matrix A
6303     int16_t y,                      // second input: scalar y
6304     const GrB_Descriptor desc       // descriptor for C, mask, and A
6305 ) ;
6306 
6307 GB_PUBLIC
6308 GrB_Info GrB_Matrix_apply_BinaryOp2nd_INT32     // C<M>=accum(C,op(x,A))
6309 (
6310     GrB_Matrix C,                   // input/output matrix for results
6311     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6312     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6313     const GrB_BinaryOp op,          // operator to apply to the entries
6314     const GrB_Matrix A,             // first input:  matrix A
6315     int32_t y,                      // second input: scalar y
6316     const GrB_Descriptor desc       // descriptor for C, mask, and A
6317 ) ;
6318 
6319 GB_PUBLIC
6320 GrB_Info GrB_Matrix_apply_BinaryOp2nd_INT64     // C<M>=accum(C,op(x,A))
6321 (
6322     GrB_Matrix C,                   // input/output matrix for results
6323     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6324     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6325     const GrB_BinaryOp op,          // operator to apply to the entries
6326     const GrB_Matrix A,             // first input:  matrix A
6327     int64_t y,                      // second input: scalar y
6328     const GrB_Descriptor desc       // descriptor for C, mask, and A
6329 ) ;
6330 
6331 GB_PUBLIC
6332 GrB_Info GrB_Matrix_apply_BinaryOp2nd_UINT8      // C<M>=accum(C,op(x,A))
6333 (
6334     GrB_Matrix C,                   // input/output matrix for results
6335     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6336     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6337     const GrB_BinaryOp op,          // operator to apply to the entries
6338     const GrB_Matrix A,             // first input:  matrix A
6339     uint8_t y,                      // second input: scalar y
6340     const GrB_Descriptor desc       // descriptor for C, mask, and A
6341 ) ;
6342 
6343 GB_PUBLIC
6344 GrB_Info GrB_Matrix_apply_BinaryOp2nd_UINT16     // C<M>=accum(C,op(x,A))
6345 (
6346     GrB_Matrix C,                   // input/output matrix for results
6347     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6348     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6349     const GrB_BinaryOp op,          // operator to apply to the entries
6350     const GrB_Matrix A,             // first input:  matrix A
6351     uint16_t y,                     // second input: scalar y
6352     const GrB_Descriptor desc       // descriptor for C, mask, and A
6353 ) ;
6354 
6355 GB_PUBLIC
6356 GrB_Info GrB_Matrix_apply_BinaryOp2nd_UINT32     // C<M>=accum(C,op(x,A))
6357 (
6358     GrB_Matrix C,                   // input/output matrix for results
6359     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6360     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6361     const GrB_BinaryOp op,          // operator to apply to the entries
6362     const GrB_Matrix A,             // first input:  matrix A
6363     uint32_t y,                     // second input: scalar y
6364     const GrB_Descriptor desc       // descriptor for C, mask, and A
6365 ) ;
6366 
6367 GB_PUBLIC
6368 GrB_Info GrB_Matrix_apply_BinaryOp2nd_UINT64     // C<M>=accum(C,op(x,A))
6369 (
6370     GrB_Matrix C,                   // input/output matrix for results
6371     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6372     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6373     const GrB_BinaryOp op,          // operator to apply to the entries
6374     const GrB_Matrix A,             // first input:  matrix A
6375     uint64_t y,                     // second input: scalar y
6376     const GrB_Descriptor desc       // descriptor for C, mask, and A
6377 ) ;
6378 
6379 GB_PUBLIC
6380 GrB_Info GrB_Matrix_apply_BinaryOp2nd_FP32      // C<M>=accum(C,op(x,A))
6381 (
6382     GrB_Matrix C,                   // input/output matrix for results
6383     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6384     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6385     const GrB_BinaryOp op,          // operator to apply to the entries
6386     const GrB_Matrix A,             // first input:  matrix A
6387     float y,                        // second input: scalar y
6388     const GrB_Descriptor desc       // descriptor for C, mask, and A
6389 ) ;
6390 
6391 GB_PUBLIC
6392 GrB_Info GrB_Matrix_apply_BinaryOp2nd_FP64      // C<M>=accum(C,op(x,A))
6393 (
6394     GrB_Matrix C,                   // input/output matrix for results
6395     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6396     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6397     const GrB_BinaryOp op,          // operator to apply to the entries
6398     const GrB_Matrix A,             // first input:  matrix A
6399     double y,                       // second input: scalar y
6400     const GrB_Descriptor desc       // descriptor for C, mask, and A
6401 ) ;
6402 
6403 GB_PUBLIC
6404 GrB_Info GxB_Matrix_apply_BinaryOp2nd_FC32      // C<M>=accum(C,op(x,A))
6405 (
6406     GrB_Matrix C,                   // input/output matrix for results
6407     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6408     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6409     const GrB_BinaryOp op,          // operator to apply to the entries
6410     const GrB_Matrix A,             // first input:  matrix A
6411     GxB_FC32_t y,                   // second input: scalar y
6412     const GrB_Descriptor desc       // descriptor for C, mask, and A
6413 ) ;
6414 
6415 GB_PUBLIC
6416 GrB_Info GxB_Matrix_apply_BinaryOp2nd_FC64      // C<M>=accum(C,op(x,A))
6417 (
6418     GrB_Matrix C,                   // input/output matrix for results
6419     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6420     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6421     const GrB_BinaryOp op,          // operator to apply to the entries
6422     const GrB_Matrix A,             // first input:  matrix A
6423     GxB_FC64_t y,                   // second input: scalar y
6424     const GrB_Descriptor desc       // descriptor for C, mask, and A
6425 ) ;
6426 
6427 GB_PUBLIC
6428 GrB_Info GrB_Matrix_apply_BinaryOp2nd_UDT       // C<M>=accum(C,op(x,A))
6429 (
6430     GrB_Matrix C,                   // input/output matrix for results
6431     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6432     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6433     const GrB_BinaryOp op,          // operator to apply to the entries
6434     const GrB_Matrix A,             // first input:  matrix A
6435     const void *y,                  // second input: scalar y
6436     const GrB_Descriptor desc       // descriptor for C, mask, and A
6437 ) ;
6438 
6439 //------------------------------------------------------------------------------
6440 // GrB_apply: generic matrix/vector apply
6441 //------------------------------------------------------------------------------
6442 
6443 // GrB_apply is a generic function for applying a unary operator to a matrix
6444 // or vector and provides access to these functions:
6445 
6446 // GrB_Vector_apply (w,mask,acc,op,u,d)  // w<mask> = accum (w, op(u))
6447 // GrB_Matrix_apply (C,Mask,acc,op,A,d)  // C<Mask> = accum (C, op(A))
6448 
6449 // GrB_Vector_apply                  (w,m,acc,unop ,u,d)
6450 // GxB_Vector_apply_BinaryOp1st      (w,m,acc,binop,x,u,d)
6451 // GrB_Vector_apply_BinaryOp1st_TYPE (w,m,acc,binop,x,u,d)
6452 // GxB_Vector_apply_BinaryOp2nd      (w,m,acc,binop,u,y,d)
6453 // GrB_Vector_apply_BinaryOp2nd_TYPE (w,m,acc,binop,u,y,d)
6454 
6455 // GrB_Matrix_apply                  (C,M,acc,unop ,A,d)
6456 // GxB_Matrix_apply_BinaryOp1st      (C,M,acc,binop,x,A,d)
6457 // GrB_Matrix_apply_BinaryOp1st_TYPE (C,M,acc,binop,x,A,d)
6458 // GxB_Matrix_apply_BinaryOp2nd      (C,M,acc,binop,A,y,d)
6459 // GrB_Matrix_apply_BinaryOp2nd_TYPE (C,M,acc,binop,A,y,d)
6460 
6461 #if GxB_STDC_VERSION >= 201112L
6462 
6463 #define GB_BIND(kind,x,y,...)                                               \
6464     _Generic                                                                \
6465     (                                                                       \
6466         (x),                                                                \
6467         GxB_Scalar: GB_CONCAT ( GxB, _, kind, _apply_BinaryOp1st )  ,       \
6468         GB_CASES (, GrB, GB_CONCAT ( kind, _apply_BinaryOp1st,, )) ,        \
6469         default :                                                           \
6470             _Generic                                                        \
6471             (                                                               \
6472                 (y),                                                        \
6473                 default : GB_CONCAT ( GxB, _, kind, _apply_BinaryOp2nd )  , \
6474                 GB_CASES (, GrB, GB_CONCAT ( kind , _apply_BinaryOp2nd,, )) \
6475             )                                                               \
6476     )
6477 
6478 #define GrB_apply(C,Mask,accum,op,...)                                      \
6479     _Generic                                                                \
6480     (                                                                       \
6481         (C),                                                                \
6482         GrB_Vector :                                                        \
6483             _Generic                                                        \
6484             (                                                               \
6485                 (op),                                                       \
6486                 GrB_UnaryOp  : GrB_Vector_apply ,                           \
6487                 GrB_BinaryOp : GB_BIND (Vector, __VA_ARGS__)                \
6488             ),                                                              \
6489         GrB_Matrix :                                                        \
6490             _Generic                                                        \
6491             (                                                               \
6492                 (op),                                                       \
6493                 GrB_UnaryOp  : GrB_Matrix_apply ,                           \
6494                 GrB_BinaryOp : GB_BIND (Matrix, __VA_ARGS__)                \
6495             )                                                               \
6496     )                                                                       \
6497     (C, Mask, accum, op, __VA_ARGS__)
6498 #endif
6499 
6500 //==============================================================================
6501 // GxB_select: matrix and vector selection
6502 //==============================================================================
6503 
6504 // Select a subset of entries from a matrix or vector.
6505 // C<Mask> = accum (C, op (A,k)), where the entries of op(A,k) are a subset of
6506 // the entries of A.
6507 
6508 GB_PUBLIC
6509 GrB_Info GxB_Vector_select          // w<mask> = accum (w, op(u,k))
6510 (
6511     GrB_Vector w,                   // input/output vector for results
6512     const GrB_Vector mask,          // optional mask for w, unused if NULL
6513     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6514     const GxB_SelectOp op,          // operator to apply to the entries
6515     const GrB_Vector u,             // first input:  vector u
6516     const GxB_Scalar Thunk,         // optional input for the select operator
6517     const GrB_Descriptor desc       // descriptor for w and mask
6518 ) ;
6519 
6520 GB_PUBLIC
6521 GrB_Info GxB_Matrix_select          // C<Mask> = accum (C, op(A,k)) or op(A',k)
6522 (
6523     GrB_Matrix C,                   // input/output matrix for results
6524     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6525     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6526     const GxB_SelectOp op,          // operator to apply to the entries
6527     const GrB_Matrix A,             // first input:  matrix A
6528     const GxB_Scalar Thunk,         // optional input for the select operator
6529     const GrB_Descriptor desc       // descriptor for C, mask, and A
6530 ) ;
6531 
6532 //------------------------------------------------------------------------------
6533 // GxB_select: generic matrix/vector select
6534 //------------------------------------------------------------------------------
6535 
6536 // GxB_select is a generic function for applying a select operator to a matrix
6537 // or vector and provides access to these functions:
6538 
6539 // GrB_Vector_select (w,mask,acc,op,u,k,d)  // w<mask> = accum (w, op(u,k))
6540 // GrB_Matrix_select (C,Mask,acc,op,A,k,d)  // C<Mask> = accum (C, op(A,k))
6541 
6542 #if GxB_STDC_VERSION >= 201112L
6543 #define GxB_select(C,Mask,accum,op,A,Thunk,desc)    \
6544     _Generic                                        \
6545     (                                               \
6546         (C),                                        \
6547         GrB_Vector   : GxB_Vector_select ,          \
6548         GrB_Matrix   : GxB_Matrix_select            \
6549     )                                               \
6550     (C, Mask, accum, op, A, Thunk, desc)
6551 #endif
6552 
6553 //==============================================================================
6554 // GrB_reduce: matrix and vector reduction
6555 //==============================================================================
6556 
6557 // Reduce the entries in a matrix to a vector, a column vector t such that
6558 // t(i) = sum (A (i,:)), and where "sum" is a commutative and associative
6559 // monoid with an identity value.  A can be transposed, which reduces down the
6560 // columns instead of the rows.  This behavior is the transpose of the MATLAB
6561 // convention, where r=sum(A) produces a row vector and sums each column.
6562 
6563 // For GrB_Matrix_reduce_BinaryOp, the GrB_BinaryOp op must correspond to a
6564 // known built-in monoid:
6565 //
6566 //      operator                data-types (all built-in)
6567 //      ----------------------  ---------------------------
6568 //      MIN, MAX                INT*, UINT*, FP*
6569 //      TIMES, PLUS             INT*, UINT*, FP*, FC*
6570 //      ANY                     INT*, UINT*, FP*, FC*, BOOL
6571 //      LOR, LAND, LXOR, EQ     BOOL
6572 //      BOR, BAND, BXOR, BXNOR  UINT*
6573 
6574 GB_PUBLIC
6575 GrB_Info GrB_Matrix_reduce_Monoid   // w<mask> = accum (w,reduce(A))
6576 (
6577     GrB_Vector w,                   // input/output vector for results
6578     const GrB_Vector mask,          // optional mask for w, unused if NULL
6579     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6580     const GrB_Monoid monoid,        // reduce operator for t=reduce(A)
6581     const GrB_Matrix A,             // first input:  matrix A
6582     const GrB_Descriptor desc       // descriptor for w, mask, and A
6583 ) ;
6584 
6585 GB_PUBLIC
6586 GrB_Info GrB_Matrix_reduce_BinaryOp // w<mask> = accum (w,reduce(A))
6587 (
6588     GrB_Vector w,                   // input/output vector for results
6589     const GrB_Vector mask,          // optional mask for w, unused if NULL
6590     const GrB_BinaryOp accum,       // optional accum for z=accum(w,t)
6591     const GrB_BinaryOp op,          // reduce operator for t=reduce(A)
6592     const GrB_Matrix A,             // first input:  matrix A
6593     const GrB_Descriptor desc       // descriptor for w, mask, and A
6594 ) ;
6595 
6596 //------------------------------------------------------------------------------
6597 // reduce a vector to a scalar
6598 //------------------------------------------------------------------------------
6599 
6600 // Reduce entries in a vector to a scalar, c = accum (c, reduce_to_scalar(u))
6601 
6602 GB_PUBLIC
6603 GrB_Info GrB_Vector_reduce_BOOL     // c = accum (c, reduce_to_scalar (u))
6604 (
6605     bool *c,                        // result scalar
6606     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6607     const GrB_Monoid monoid,        // monoid to do the reduction
6608     const GrB_Vector u,             // vector to reduce
6609     const GrB_Descriptor desc       // descriptor (currently unused)
6610 ) ;
6611 
6612 GB_PUBLIC
6613 GrB_Info GrB_Vector_reduce_INT8     // c = accum (c, reduce_to_scalar (u))
6614 (
6615     int8_t *c,                      // result scalar
6616     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6617     const GrB_Monoid monoid,        // monoid to do the reduction
6618     const GrB_Vector u,             // vector to reduce
6619     const GrB_Descriptor desc       // descriptor (currently unused)
6620 ) ;
6621 
6622 GB_PUBLIC
6623 GrB_Info GrB_Vector_reduce_UINT8    // c = accum (c, reduce_to_scalar (u))
6624 (
6625     uint8_t *c,                     // result scalar
6626     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6627     const GrB_Monoid monoid,        // monoid to do the reduction
6628     const GrB_Vector u,             // vector to reduce
6629     const GrB_Descriptor desc       // descriptor (currently unused)
6630 ) ;
6631 
6632 GB_PUBLIC
6633 GrB_Info GrB_Vector_reduce_INT16    // c = accum (c, reduce_to_scalar (u))
6634 (
6635     int16_t *c,                     // result scalar
6636     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6637     const GrB_Monoid monoid,        // monoid to do the reduction
6638     const GrB_Vector u,             // vector to reduce
6639     const GrB_Descriptor desc       // descriptor (currently unused)
6640 ) ;
6641 
6642 GB_PUBLIC
6643 GrB_Info GrB_Vector_reduce_UINT16   // c = accum (c, reduce_to_scalar (u))
6644 (
6645     uint16_t *c,                    // result scalar
6646     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6647     const GrB_Monoid monoid,        // monoid to do the reduction
6648     const GrB_Vector u,             // vector to reduce
6649     const GrB_Descriptor desc       // descriptor (currently unused)
6650 ) ;
6651 
6652 GB_PUBLIC
6653 GrB_Info GrB_Vector_reduce_INT32    // c = accum (c, reduce_to_scalar (u))
6654 (
6655     int32_t *c,                     // result scalar
6656     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6657     const GrB_Monoid monoid,        // monoid to do the reduction
6658     const GrB_Vector u,             // vector to reduce
6659     const GrB_Descriptor desc       // descriptor (currently unused)
6660 ) ;
6661 
6662 GB_PUBLIC
6663 GrB_Info GrB_Vector_reduce_UINT32   // c = accum (c, reduce_to_scalar (u))
6664 (
6665     uint32_t *c,                    // result scalar
6666     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6667     const GrB_Monoid monoid,        // monoid to do the reduction
6668     const GrB_Vector u,             // vector to reduce
6669     const GrB_Descriptor desc       // descriptor (currently unused)
6670 ) ;
6671 
6672 GB_PUBLIC
6673 GrB_Info GrB_Vector_reduce_INT64    // c = accum (c, reduce_to_scalar (u))
6674 (
6675     int64_t *c,                     // result scalar
6676     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6677     const GrB_Monoid monoid,        // monoid to do the reduction
6678     const GrB_Vector u,             // vector to reduce
6679     const GrB_Descriptor desc       // descriptor (currently unused)
6680 ) ;
6681 
6682 GB_PUBLIC
6683 GrB_Info GrB_Vector_reduce_UINT64   // c = accum (c, reduce_to_scalar (u))
6684 (
6685     uint64_t *c,                    // result scalar
6686     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6687     const GrB_Monoid monoid,        // monoid to do the reduction
6688     const GrB_Vector u,             // vector to reduce
6689     const GrB_Descriptor desc       // descriptor (currently unused)
6690 ) ;
6691 
6692 GB_PUBLIC
6693 GrB_Info GrB_Vector_reduce_FP32     // c = accum (c, reduce_to_scalar (u))
6694 (
6695     float *c,                       // result scalar
6696     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6697     const GrB_Monoid monoid,        // monoid to do the reduction
6698     const GrB_Vector u,             // vector to reduce
6699     const GrB_Descriptor desc       // descriptor (currently unused)
6700 ) ;
6701 
6702 GB_PUBLIC
6703 GrB_Info GrB_Vector_reduce_FP64     // c = accum (c, reduce_to_scalar (u))
6704 (
6705     double *c,                      // result scalar
6706     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6707     const GrB_Monoid monoid,        // monoid to do the reduction
6708     const GrB_Vector u,             // vector to reduce
6709     const GrB_Descriptor desc       // descriptor (currently unused)
6710 ) ;
6711 
6712 GB_PUBLIC
6713 GrB_Info GxB_Vector_reduce_FC32     // c = accum (c, reduce_to_scalar (u))
6714 (
6715     GxB_FC32_t *c,                  // result scalar
6716     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6717     const GrB_Monoid monoid,        // monoid to do the reduction
6718     const GrB_Vector u,             // vector to reduce
6719     const GrB_Descriptor desc       // descriptor (currently unused)
6720 ) ;
6721 
6722 GB_PUBLIC
6723 GrB_Info GxB_Vector_reduce_FC64     // c = accum (c, reduce_to_scalar (u))
6724 (
6725     GxB_FC64_t *c,                  // result scalar
6726     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6727     const GrB_Monoid monoid,        // monoid to do the reduction
6728     const GrB_Vector u,             // vector to reduce
6729     const GrB_Descriptor desc       // descriptor (currently unused)
6730 ) ;
6731 
6732 GB_PUBLIC
6733 GrB_Info GrB_Vector_reduce_UDT      // c = accum (c, reduce_to_scalar (u))
6734 (
6735     void *c,                        // result scalar
6736     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6737     const GrB_Monoid monoid,        // monoid to do the reduction
6738     const GrB_Vector u,             // vector to reduce
6739     const GrB_Descriptor desc       // descriptor (currently unused)
6740 ) ;
6741 
6742 //------------------------------------------------------------------------------
6743 // reduce a matrix to a scalar
6744 //------------------------------------------------------------------------------
6745 
6746 // Reduce entries in a matrix to a scalar, c = accum (c, reduce_to_scalar(A))
6747 
6748 GB_PUBLIC
6749 GrB_Info GrB_Matrix_reduce_BOOL     // c = accum (c, reduce_to_scalar (A))
6750 (
6751     bool *c,                        // result scalar
6752     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6753     const GrB_Monoid monoid,        // monoid to do the reduction
6754     const GrB_Matrix A,             // matrix to reduce
6755     const GrB_Descriptor desc       // descriptor (currently unused)
6756 ) ;
6757 
6758 GB_PUBLIC
6759 GrB_Info GrB_Matrix_reduce_INT8     // c = accum (c, reduce_to_scalar (A))
6760 (
6761     int8_t *c,                      // result scalar
6762     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6763     const GrB_Monoid monoid,        // monoid to do the reduction
6764     const GrB_Matrix A,             // matrix to reduce
6765     const GrB_Descriptor desc       // descriptor (currently unused)
6766 ) ;
6767 
6768 GB_PUBLIC
6769 GrB_Info GrB_Matrix_reduce_UINT8    // c = accum (c, reduce_to_scalar (A))
6770 (
6771     uint8_t *c,                     // result scalar
6772     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6773     const GrB_Monoid monoid,        // monoid to do the reduction
6774     const GrB_Matrix A,             // matrix to reduce
6775     const GrB_Descriptor desc       // descriptor (currently unused)
6776 ) ;
6777 
6778 GB_PUBLIC
6779 GrB_Info GrB_Matrix_reduce_INT16    // c = accum (c, reduce_to_scalar (A))
6780 (
6781     int16_t *c,                     // result scalar
6782     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6783     const GrB_Monoid monoid,        // monoid to do the reduction
6784     const GrB_Matrix A,             // matrix to reduce
6785     const GrB_Descriptor desc       // descriptor (currently unused)
6786 ) ;
6787 
6788 GB_PUBLIC
6789 GrB_Info GrB_Matrix_reduce_UINT16   // c = accum (c, reduce_to_scalar (A))
6790 (
6791     uint16_t *c,                    // result scalar
6792     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6793     const GrB_Monoid monoid,        // monoid to do the reduction
6794     const GrB_Matrix A,             // matrix to reduce
6795     const GrB_Descriptor desc       // descriptor (currently unused)
6796 ) ;
6797 
6798 GB_PUBLIC
6799 GrB_Info GrB_Matrix_reduce_INT32    // c = accum (c, reduce_to_scalar (A))
6800 (
6801     int32_t *c,                     // result scalar
6802     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6803     const GrB_Monoid monoid,        // monoid to do the reduction
6804     const GrB_Matrix A,             // matrix to reduce
6805     const GrB_Descriptor desc       // descriptor (currently unused)
6806 ) ;
6807 
6808 GB_PUBLIC
6809 GrB_Info GrB_Matrix_reduce_UINT32   // c = accum (c, reduce_to_scalar (A))
6810 (
6811     uint32_t *c,                    // result scalar
6812     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6813     const GrB_Monoid monoid,        // monoid to do the reduction
6814     const GrB_Matrix A,             // matrix to reduce
6815     const GrB_Descriptor desc       // descriptor (currently unused)
6816 ) ;
6817 
6818 GB_PUBLIC
6819 GrB_Info GrB_Matrix_reduce_INT64    // c = accum (c, reduce_to_scalar (A))
6820 (
6821     int64_t *c,                     // result scalar
6822     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6823     const GrB_Monoid monoid,        // monoid to do the reduction
6824     const GrB_Matrix A,             // matrix to reduce
6825     const GrB_Descriptor desc       // descriptor (currently unused)
6826 ) ;
6827 
6828 GB_PUBLIC
6829 GrB_Info GrB_Matrix_reduce_UINT64   // c = accum (c, reduce_to_scalar (A))
6830 (
6831     uint64_t *c,                    // result scalar
6832     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6833     const GrB_Monoid monoid,        // monoid to do the reduction
6834     const GrB_Matrix A,             // matrix to reduce
6835     const GrB_Descriptor desc       // descriptor (currently unused)
6836 ) ;
6837 
6838 GB_PUBLIC
6839 GrB_Info GrB_Matrix_reduce_FP32     // c = accum (c, reduce_to_scalar (A))
6840 (
6841     float *c,                       // result scalar
6842     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6843     const GrB_Monoid monoid,        // monoid to do the reduction
6844     const GrB_Matrix A,             // matrix to reduce
6845     const GrB_Descriptor desc       // descriptor (currently unused)
6846 ) ;
6847 
6848 GB_PUBLIC
6849 GrB_Info GrB_Matrix_reduce_FP64     // c = accum (c, reduce_to_scalar (A))
6850 (
6851     double *c,                      // result scalar
6852     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6853     const GrB_Monoid monoid,        // monoid to do the reduction
6854     const GrB_Matrix A,             // matrix to reduce
6855     const GrB_Descriptor desc       // descriptor (currently unused)
6856 ) ;
6857 
6858 GB_PUBLIC
6859 GrB_Info GxB_Matrix_reduce_FC32     // c = accum (c, reduce_to_scalar (A))
6860 (
6861     GxB_FC32_t *c,                  // result scalar
6862     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6863     const GrB_Monoid monoid,        // monoid to do the reduction
6864     const GrB_Matrix A,             // matrix to reduce
6865     const GrB_Descriptor desc       // descriptor (currently unused)
6866 ) ;
6867 
6868 GB_PUBLIC
6869 GrB_Info GxB_Matrix_reduce_FC64     // c = accum (c, reduce_to_scalar (A))
6870 (
6871     GxB_FC64_t *c,                  // result scalar
6872     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6873     const GrB_Monoid monoid,        // monoid to do the reduction
6874     const GrB_Matrix A,             // matrix to reduce
6875     const GrB_Descriptor desc       // descriptor (currently unused)
6876 ) ;
6877 
6878 GB_PUBLIC
6879 GrB_Info GrB_Matrix_reduce_UDT      // c = accum (c, reduce_to_scalar (A))
6880 (
6881     void *c,                        // result scalar
6882     const GrB_BinaryOp accum,       // optional accum for c=accum(c,t)
6883     const GrB_Monoid monoid,        // monoid to do the reduction
6884     const GrB_Matrix A,             // matrix to reduce
6885     const GrB_Descriptor desc       // descriptor (currently unused)
6886 ) ;
6887 
6888 //------------------------------------------------------------------------------
6889 // GrB_reduce: generic matrix/vector reduction to a vector or scalar
6890 //------------------------------------------------------------------------------
6891 
6892 // GrB_reduce is a generic function that provides access to all GrB_*reduce*
6893 // functions:
6894 
6895 // reduce matrix to vector:
6896 // GrB_Matrix_reduce_Monoid   (w,mask,acc,mo,A,d) // w<mask> = acc (w,reduce(A))
6897 // GrB_Matrix_reduce_BinaryOp (w,mask,acc,op,A,d) // w<mask> = acc (w,reduce(A))
6898 // reduce matrix to scalar:
6899 // GrB_Vector_reduce_[SCALAR] (c,acc,monoid,u,d)  // c = acc (c,reduce(u))
6900 // GrB_Matrix_reduce_[SCALAR] (c,acc,monoid,A,d)  // c = acc (c,reduce(A))
6901 
6902 #if GxB_STDC_VERSION >= 201112L
6903 #define GB_REDUCE_TO_SCALAR(kind,c)                                 \
6904     _Generic                                                        \
6905     (                                                               \
6906         (c),                                                        \
6907         GB_CASES (*, GrB, GB_CONCAT ( kind, _reduce,, )),           \
6908         default: GB_CONCAT ( GrB, _, kind, _reduce_UDT )            \
6909     )
6910 
6911 #define GrB_reduce(arg1,arg2,arg3,arg4,...)                         \
6912     _Generic                                                        \
6913     (                                                               \
6914         (arg4),                                                     \
6915         const GrB_Vector   : GB_REDUCE_TO_SCALAR (Vector, arg1),    \
6916               GrB_Vector   : GB_REDUCE_TO_SCALAR (Vector, arg1),    \
6917         const GrB_Matrix   : GB_REDUCE_TO_SCALAR (Matrix, arg1),    \
6918               GrB_Matrix   : GB_REDUCE_TO_SCALAR (Matrix, arg1),    \
6919         const GrB_Monoid   : GrB_Matrix_reduce_Monoid   ,           \
6920               GrB_Monoid   : GrB_Matrix_reduce_Monoid   ,           \
6921         const GrB_BinaryOp : GrB_Matrix_reduce_BinaryOp ,           \
6922               GrB_BinaryOp : GrB_Matrix_reduce_BinaryOp             \
6923     )                                                               \
6924     (arg1, arg2, arg3, arg4, __VA_ARGS__)
6925 #endif
6926 
6927 //==============================================================================
6928 // GrB_transpose: matrix transpose
6929 //==============================================================================
6930 
6931 GB_PUBLIC
6932 GrB_Info GrB_transpose              // C<Mask> = accum (C, A')
6933 (
6934     GrB_Matrix C,                   // input/output matrix for results
6935     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6936     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6937     const GrB_Matrix A,             // first input:  matrix A
6938     const GrB_Descriptor desc       // descriptor for C, Mask, and A
6939 ) ;
6940 
6941 //==============================================================================
6942 // GrB_kronecker:  Kronecker product
6943 //==============================================================================
6944 
6945 // GxB_kron is historical; use GrB_kronecker instead
6946 GB_PUBLIC
6947 GrB_Info GxB_kron                   // C<Mask> = accum(C,kron(A,B)) (historical)
6948 (
6949     GrB_Matrix C,                   // input/output matrix for results
6950     const GrB_Matrix Mask,          // optional mask for C, unused if NULL
6951     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6952     const GrB_BinaryOp op,          // defines '*' for T=kron(A,B)
6953     const GrB_Matrix A,             // first input:  matrix A
6954     const GrB_Matrix B,             // second input: matrix B
6955     const GrB_Descriptor desc       // descriptor for C, Mask, A, and B
6956 ) ;
6957 
6958 GB_PUBLIC
6959 GrB_Info GrB_Matrix_kronecker_BinaryOp  // C<M> = accum (C, kron(A,B))
6960 (
6961     GrB_Matrix C,                   // input/output matrix for results
6962     const GrB_Matrix M,             // optional mask for C, unused if NULL
6963     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6964     const GrB_BinaryOp op,          // defines '*' for T=kron(A,B)
6965     const GrB_Matrix A,             // first input:  matrix A
6966     const GrB_Matrix B,             // second input: matrix B
6967     const GrB_Descriptor desc       // descriptor for C, M, A, and B
6968 ) ;
6969 
6970 GB_PUBLIC
6971 GrB_Info GrB_Matrix_kronecker_Monoid  // C<M> = accum (C, kron(A,B))
6972 (
6973     GrB_Matrix C,                   // input/output matrix for results
6974     const GrB_Matrix M,             // optional mask for C, unused if NULL
6975     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6976     const GrB_Monoid monoid,        // defines '*' for T=kron(A,B)
6977     const GrB_Matrix A,             // first input:  matrix A
6978     const GrB_Matrix B,             // second input: matrix B
6979     const GrB_Descriptor desc       // descriptor for C, M, A, and B
6980 ) ;
6981 
6982 GB_PUBLIC
6983 GrB_Info GrB_Matrix_kronecker_Semiring  // C<M> = accum (C, kron(A,B))
6984 (
6985     GrB_Matrix C,                   // input/output matrix for results
6986     const GrB_Matrix M,             // optional mask for C, unused if NULL
6987     const GrB_BinaryOp accum,       // optional accum for Z=accum(C,T)
6988     const GrB_Semiring semiring,    // defines '*' for T=kron(A,B)
6989     const GrB_Matrix A,             // first input:  matrix A
6990     const GrB_Matrix B,             // second input: matrix B
6991     const GrB_Descriptor desc       // descriptor for C, M, A, and B
6992 ) ;
6993 
6994 #if GxB_STDC_VERSION >= 201112L
6995 #define GrB_kronecker(C,Mask,accum,op,A,B,desc)                 \
6996     _Generic                                                    \
6997     (                                                           \
6998         (op),                                                   \
6999         const GrB_Semiring : GrB_Matrix_kronecker_Semiring ,    \
7000               GrB_Semiring : GrB_Matrix_kronecker_Semiring ,    \
7001         const GrB_Monoid   : GrB_Matrix_kronecker_Monoid   ,    \
7002               GrB_Monoid   : GrB_Matrix_kronecker_Monoid   ,    \
7003         const GrB_BinaryOp : GrB_Matrix_kronecker_BinaryOp ,    \
7004               GrB_BinaryOp : GrB_Matrix_kronecker_BinaryOp      \
7005     )                                                           \
7006     (C, Mask, accum, op, A, B, desc)
7007 #endif
7008 
7009 
7010 //==============================================================================
7011 // GrB_Monoid: built-in monoids
7012 //==============================================================================
7013 
7014 GB_PUBLIC GrB_Monoid
7015 
7016     //--------------------------------------------------------------------------
7017     // 10 MIN monoids: (not for complex types)
7018     //--------------------------------------------------------------------------
7019 
7020     // GxB_MIN monoids, historical, use GrB_MIN_MONOID_* instead:
7021     GxB_MIN_INT8_MONOID,        // identity: INT8_MAX     terminal: INT8_MIN
7022     GxB_MIN_INT16_MONOID,       // identity: INT16_MAX    terminal: INT16_MIN
7023     GxB_MIN_INT32_MONOID,       // identity: INT32_MAX    terminal: INT32_MIN
7024     GxB_MIN_INT64_MONOID,       // identity: INT64_MAX    terminal: INT32_MIN
7025     GxB_MIN_UINT8_MONOID,       // identity: UINT8_MAX    terminal: 0
7026     GxB_MIN_UINT16_MONOID,      // identity: UINT16_MAX   terminal: 0
7027     GxB_MIN_UINT32_MONOID,      // identity: UINT32_MAX   terminal: 0
7028     GxB_MIN_UINT64_MONOID,      // identity: UINT64_MAX   terminal: 0
7029     GxB_MIN_FP32_MONOID,        // identity: INFINITY     terminal: -INFINITY
7030     GxB_MIN_FP64_MONOID,        // identity: INFINITY     terminal: -INFINITY
7031 
7032     // preferred names from the v1.3 spec:
7033     GrB_MIN_MONOID_INT8,        // identity: INT8_MAX     terminal: INT8_MIN
7034     GrB_MIN_MONOID_INT16,       // identity: INT16_MAX    terminal: INT16_MIN
7035     GrB_MIN_MONOID_INT32,       // identity: INT32_MAX    terminal: INT32_MIN
7036     GrB_MIN_MONOID_INT64,       // identity: INT64_MAX    terminal: INT32_MIN
7037     GrB_MIN_MONOID_UINT8,       // identity: UINT8_MAX    terminal: 0
7038     GrB_MIN_MONOID_UINT16,      // identity: UINT16_MAX   terminal: 0
7039     GrB_MIN_MONOID_UINT32,      // identity: UINT32_MAX   terminal: 0
7040     GrB_MIN_MONOID_UINT64,      // identity: UINT64_MAX   terminal: 0
7041     GrB_MIN_MONOID_FP32,        // identity: INFINITY     terminal: -INFINITY
7042     GrB_MIN_MONOID_FP64,        // identity: INFINITY     terminal: -INFINITY
7043 
7044     //--------------------------------------------------------------------------
7045     // 10 MAX monoids:
7046     //--------------------------------------------------------------------------
7047 
7048     // GxB_MAX monoids, historical, use GrB_MAX_MONOID_* instead:
7049     GxB_MAX_INT8_MONOID,        // identity: INT8_MIN     terminal: INT8_MAX
7050     GxB_MAX_INT16_MONOID,       // identity: INT16_MIN    terminal: INT16_MAX
7051     GxB_MAX_INT32_MONOID,       // identity: INT32_MIN    terminal: INT32_MAX
7052     GxB_MAX_INT64_MONOID,       // identity: INT64_MIN    terminal: INT64_MAX
7053     GxB_MAX_UINT8_MONOID,       // identity: 0            terminal: UINT8_MAX
7054     GxB_MAX_UINT16_MONOID,      // identity: 0            terminal: UINT16_MAX
7055     GxB_MAX_UINT32_MONOID,      // identity: 0            terminal: UINT32_MAX
7056     GxB_MAX_UINT64_MONOID,      // identity: 0            terminal: UINT64_MAX
7057     GxB_MAX_FP32_MONOID,        // identity: -INFINITY    terminal: INFINITY
7058     GxB_MAX_FP64_MONOID,        // identity: -INFINITY    terminal: INFINITY
7059 
7060     // preferred names from the v1.3 spec:
7061     GrB_MAX_MONOID_INT8,        // identity: INT8_MIN     terminal: INT8_MAX
7062     GrB_MAX_MONOID_INT16,       // identity: INT16_MIN    terminal: INT16_MAX
7063     GrB_MAX_MONOID_INT32,       // identity: INT32_MIN    terminal: INT32_MAX
7064     GrB_MAX_MONOID_INT64,       // identity: INT64_MIN    terminal: INT64_MAX
7065     GrB_MAX_MONOID_UINT8,       // identity: 0            terminal: UINT8_MAX
7066     GrB_MAX_MONOID_UINT16,      // identity: 0            terminal: UINT16_MAX
7067     GrB_MAX_MONOID_UINT32,      // identity: 0            terminal: UINT32_MAX
7068     GrB_MAX_MONOID_UINT64,      // identity: 0            terminal: UINT64_MAX
7069     GrB_MAX_MONOID_FP32,        // identity: -INFINITY    terminal: INFINITY
7070     GrB_MAX_MONOID_FP64,        // identity: -INFINITY    terminal: INFINITY
7071 
7072     //--------------------------------------------------------------------------
7073     // 12 PLUS monoids:
7074     //--------------------------------------------------------------------------
7075 
7076     // GxB_PLUS monoids, historical, use GrB_PLUS_MONOID_* instead:
7077     GxB_PLUS_INT8_MONOID,       // identity: 0
7078     GxB_PLUS_INT16_MONOID,      // identity: 0
7079     GxB_PLUS_INT32_MONOID,      // identity: 0
7080     GxB_PLUS_INT64_MONOID,      // identity: 0
7081     GxB_PLUS_UINT8_MONOID,      // identity: 0
7082     GxB_PLUS_UINT16_MONOID,     // identity: 0
7083     GxB_PLUS_UINT32_MONOID,     // identity: 0
7084     GxB_PLUS_UINT64_MONOID,     // identity: 0
7085     GxB_PLUS_FP32_MONOID,       // identity: 0
7086     GxB_PLUS_FP64_MONOID,       // identity: 0
7087 
7088     // preferred names from the v1.3 spec:
7089     GrB_PLUS_MONOID_INT8,       // identity: 0
7090     GrB_PLUS_MONOID_INT16,      // identity: 0
7091     GrB_PLUS_MONOID_INT32,      // identity: 0
7092     GrB_PLUS_MONOID_INT64,      // identity: 0
7093     GrB_PLUS_MONOID_UINT8,      // identity: 0
7094     GrB_PLUS_MONOID_UINT16,     // identity: 0
7095     GrB_PLUS_MONOID_UINT32,     // identity: 0
7096     GrB_PLUS_MONOID_UINT64,     // identity: 0
7097     GrB_PLUS_MONOID_FP32,       // identity: 0
7098     GrB_PLUS_MONOID_FP64,       // identity: 0
7099 
7100     // complex monoids:
7101     GxB_PLUS_FC32_MONOID,       // identity: 0
7102     GxB_PLUS_FC64_MONOID,       // identity: 0
7103 
7104     //--------------------------------------------------------------------------
7105     // 12 TIMES monoids: identity value is 1, int* and uint* are terminal
7106     //--------------------------------------------------------------------------
7107 
7108     // GxB_TIMES monoids, historical, use GrB_TIMES_MONOID_* instead:
7109     GxB_TIMES_INT8_MONOID,      // identity: 1            terminal: 0
7110     GxB_TIMES_INT16_MONOID,     // identity: 1            terminal: 0
7111     GxB_TIMES_INT32_MONOID,     // identity: 1            terminal: 0
7112     GxB_TIMES_INT64_MONOID,     // identity: 1            terminal: 0
7113     GxB_TIMES_UINT8_MONOID,     // identity: 1            terminal: 0
7114     GxB_TIMES_UINT16_MONOID,    // identity: 1            terminal: 0
7115     GxB_TIMES_UINT32_MONOID,    // identity: 1            terminal: 0
7116     GxB_TIMES_UINT64_MONOID,    // identity: 1            terminal: 0
7117     GxB_TIMES_FP32_MONOID,      // identity: 1
7118     GxB_TIMES_FP64_MONOID,      // identity: 1
7119 
7120     // preferred names from the v1.3 spec:
7121     GrB_TIMES_MONOID_INT8,      // identity: 1            terminal: 0
7122     GrB_TIMES_MONOID_INT16,     // identity: 1            terminal: 0
7123     GrB_TIMES_MONOID_INT32,     // identity: 1            terminal: 0
7124     GrB_TIMES_MONOID_INT64,     // identity: 1            terminal: 0
7125     GrB_TIMES_MONOID_UINT8,     // identity: 1            terminal: 0
7126     GrB_TIMES_MONOID_UINT16,    // identity: 1            terminal: 0
7127     GrB_TIMES_MONOID_UINT32,    // identity: 1            terminal: 0
7128     GrB_TIMES_MONOID_UINT64,    // identity: 1            terminal: 0
7129     GrB_TIMES_MONOID_FP32,      // identity: 1
7130     GrB_TIMES_MONOID_FP64,      // identity: 1
7131 
7132     // complex monoids:
7133     GxB_TIMES_FC32_MONOID,      // identity: 1
7134     GxB_TIMES_FC64_MONOID,      // identity: 1
7135 
7136     //--------------------------------------------------------------------------
7137     // 13 ANY monoids:
7138     //--------------------------------------------------------------------------
7139 
7140     GxB_ANY_BOOL_MONOID,        // identity: any value    terminal: any value
7141     GxB_ANY_INT8_MONOID,        // identity: any value    terminal: any value
7142     GxB_ANY_INT16_MONOID,       // identity: any value    terminal: any value
7143     GxB_ANY_INT32_MONOID,       // identity: any value    terminal: any value
7144     GxB_ANY_INT64_MONOID,       // identity: any value    terminal: any value
7145     GxB_ANY_UINT8_MONOID,       // identity: any value    terminal: any value
7146     GxB_ANY_UINT16_MONOID,      // identity: any value    terminal: any value
7147     GxB_ANY_UINT32_MONOID,      // identity: any value    terminal: any value
7148     GxB_ANY_UINT64_MONOID,      // identity: any value    terminal: any value
7149     GxB_ANY_FP32_MONOID,        // identity: any value    terminal: any value
7150     GxB_ANY_FP64_MONOID,        // identity: any value    terminal: any value
7151     GxB_ANY_FC32_MONOID,        // identity: any value    terminal: any value
7152     GxB_ANY_FC64_MONOID,        // identity: any value    terminal: any value
7153 
7154     //--------------------------------------------------------------------------
7155     // 4 Boolean monoids: (see also the GxB_ANY_BOOL_MONOID above)
7156     //--------------------------------------------------------------------------
7157 
7158     // GxB_* boolean monoids, historical, use GrB_* instead:
7159     GxB_LOR_BOOL_MONOID,        // identity: false        terminal: true
7160     GxB_LAND_BOOL_MONOID,       // identity: true         terminal: false
7161     GxB_LXOR_BOOL_MONOID,       // identity: false
7162     GxB_LXNOR_BOOL_MONOID,      // identity: true
7163     GxB_EQ_BOOL_MONOID,         // (alternative name for GrB_LXNOR_MONOID_BOOL)
7164 
7165     // preferred names from the v1.3 spec:
7166     GrB_LOR_MONOID_BOOL,        // identity: false        terminal: true
7167     GrB_LAND_MONOID_BOOL,       // identity: true         terminal: false
7168     GrB_LXOR_MONOID_BOOL,       // identity: false
7169     GrB_LXNOR_MONOID_BOOL,      // identity: true
7170 
7171     //--------------------------------------------------------------------------
7172     // 16 Bitwise-or monoids:
7173     //--------------------------------------------------------------------------
7174 
7175     // BOR monoids (bitwise or):
7176     GxB_BOR_UINT8_MONOID,       // identity: 0   terminal: 0xFF
7177     GxB_BOR_UINT16_MONOID,      // identity: 0   terminal: 0xFFFF
7178     GxB_BOR_UINT32_MONOID,      // identity: 0   terminal: 0xFFFFFFFF
7179     GxB_BOR_UINT64_MONOID,      // identity: 0   terminal: 0xFFFFFFFFFFFFFFFF
7180 
7181     // BAND monoids (bitwise and):
7182     GxB_BAND_UINT8_MONOID,      // identity: 0xFF               terminal: 0
7183     GxB_BAND_UINT16_MONOID,     // identity: 0xFFFF             terminal: 0
7184     GxB_BAND_UINT32_MONOID,     // identity: 0xFFFFFFFF         terminal: 0
7185     GxB_BAND_UINT64_MONOID,     // identity: 0xFFFFFFFFFFFFFFFF terminal: 0
7186 
7187     // BXOR monoids (bitwise xor):
7188     GxB_BXOR_UINT8_MONOID,      // identity: 0
7189     GxB_BXOR_UINT16_MONOID,     // identity: 0
7190     GxB_BXOR_UINT32_MONOID,     // identity: 0
7191     GxB_BXOR_UINT64_MONOID,     // identity: 0
7192 
7193     // BXNOR monoids (bitwise xnor):
7194     GxB_BXNOR_UINT8_MONOID,     // identity: 0xFF
7195     GxB_BXNOR_UINT16_MONOID,    // identity: 0xFFFF
7196     GxB_BXNOR_UINT32_MONOID,    // identity: 0xFFFFFFFF
7197     GxB_BXNOR_UINT64_MONOID ;   // identity: 0xFFFFFFFFFFFFFFFF
7198 
7199 //==============================================================================
7200 // GrB_Semiring: built-in semirings
7201 //==============================================================================
7202 
7203 // Using built-in types and operators, SuiteSparse:GraphBLAS provides
7204 // 1553 pre-defined, built-in semirings:
7205 
7206 // 1000 semirings with a multiply operator TxT -> T where T is non-Boolean,
7207 // from the complete cross product of:
7208 
7209 //      5 monoids: MIN, MAX, PLUS, TIMES, ANY
7210 //      20 multiply operators:
7211 //          FIRST, SECOND, PAIR, MIN, MAX, PLUS, MINUS, TIMES, DIV, RDIV, RMINUS
7212 //          ISEQ, ISNE, ISGT, ISLT, ISGE, ISLE,
7213 //          LOR, LAND, LXOR
7214 //      10 non-Boolean real types, T
7215 //
7216 //      Note that min_pair, max_pair, times_pair are all identical to any_pair.
7217 //      These 30 semirings are named below, but are internally remapped to
7218 //      their corresponding any_pair semiring.
7219 
7220 // 300 semirings with a comparison operator TxT -> bool, where T is
7221 // non-Boolean, from the complete cross product of:
7222 
7223 //      5 Boolean monoids: LAND, LOR, LXOR, EQ (=LXNOR), ANY
7224 //      6 multiply operators: EQ, NE, GT, LT, GE, LE
7225 //      10 non-Boolean real types, T
7226 
7227 // 55 semirings with purely Boolean types, bool x bool -> bool, from the
7228 // complete cross product of:
7229 
7230 //      5 Boolean monoids LAND, LOR, LXOR, EQ (=LXNOR), ANY
7231 //      11 multiply operators:
7232 //          FIRST, SECOND, LOR, LAND, LXOR, EQ (=LXNOR), GT, LT, GE, LE, PAIR
7233 //
7234 //      Note that lor_pair, land_pair, and eq_pair are all identical to
7235 //      any_pair.  These 3 semirings are named below, but are internally
7236 //      remapped to any_pair_bool semiring.
7237 
7238 // 54 complex semirings: TxT -> T where T is float complex or double complex:
7239 
7240 //      3 complex monoids: PLUS, TIMES, ANY
7241 //      9 complex multiply operators:
7242 //          FIRST, SECOND, PAIR, PLUS, MINUS, TIMES, DIV, RDIV, RMINUS
7243 //      2 complex types
7244 //
7245 //      Note that times_pair is identical to any_pair.
7246 //      These 2 semirings are named below, but are internally remapped to
7247 //      their corresponding any_pair semiring.
7248 
7249 // 64 bitwise semirings: TxT -> T where T is an unsigned integer:
7250 
7251 //      4 bitwise monoids: BOR, BAND, BXOR, BXNOR
7252 //      4 bitwise multiply operators: BOR, BAND, BXOR, BXNOR
7253 //      4 unsigned integer types: UINT8, UINT16, UINT32, UINT64
7254 
7255 // 80 positional semirings: XxX -> T where T is int64 or int32, and the type of
7256 // X is ignored:
7257 
7258 //      5 monoids: MIN, MAX, PLUS, TIMES, ANY
7259 //      8 multiply operators:
7260 //          FIRSTI, FIRSTI1, FIRSTJ, FIRSTJ1,
7261 //          SECONDI, SECONDI1, SECONDJ, SECONDJ1
7262 //      2 types: int32, int64
7263 
7264 // The ANY operator is also valid to use as a multiplicative operator in a
7265 // semiring, but serves no purpose in that case.  The ANY operator is meant as
7266 // a fast additive operator for a monoid, that terminates, or short-circuits,
7267 // as soon as any value is found.  A valid user semiring can be constructed
7268 // with ANY as the multiply operator, but they are not predefined below.
7269 
7270 // Likewise, additional built-in operators can be used as multiplicative
7271 // operators for floating-point semirings (POW, ATAN2, HYPOT, ...) and many
7272 // more semirings can be constructed from bitwise monoids and many integer
7273 // binary (non-bitwise) multiplicative operators, but these are not
7274 // pre-defined.
7275 
7276 // In the names below, each semiring has a name of the form GxB_add_mult_T
7277 // where add is the additive monoid, mult is the multiply operator, and T is
7278 // the type.  The type T is always the type of x and y for the z=mult(x,y)
7279 // operator.  The monoid's three types and the ztype of the mult operator are
7280 // always the same.  This is the type T for the first set, and Boolean for
7281 // the second and third sets of semirngs.
7282 
7283 // 1553 = 1000 + 300 + 55 + 54 + 64 + 80 semirings are named below, but 35 = 30
7284 // + 3 + 2 are identical to the corresponding any_pair semirings of the same
7285 // type.  For positional semirings, the mulitiply ops FIRSTJ and SECONDI are
7286 // identical, as are FIRSTJ1 and SECONDI1.  These semirings still appear as
7287 // predefined, for convenience.
7288 
7289 GB_PUBLIC GrB_Semiring
7290 
7291 //------------------------------------------------------------------------------
7292 // 1000 non-Boolean semirings where all types are the same, given by suffix _T
7293 //------------------------------------------------------------------------------
7294 
7295     // semirings with multiply op: z = FIRST (x,y), all types x,y,z the same:
7296     GxB_MIN_FIRST_INT8     , GxB_MAX_FIRST_INT8     , GxB_PLUS_FIRST_INT8    , GxB_TIMES_FIRST_INT8   , GxB_ANY_FIRST_INT8     ,
7297     GxB_MIN_FIRST_INT16    , GxB_MAX_FIRST_INT16    , GxB_PLUS_FIRST_INT16   , GxB_TIMES_FIRST_INT16  , GxB_ANY_FIRST_INT16    ,
7298     GxB_MIN_FIRST_INT32    , GxB_MAX_FIRST_INT32    , GxB_PLUS_FIRST_INT32   , GxB_TIMES_FIRST_INT32  , GxB_ANY_FIRST_INT32    ,
7299     GxB_MIN_FIRST_INT64    , GxB_MAX_FIRST_INT64    , GxB_PLUS_FIRST_INT64   , GxB_TIMES_FIRST_INT64  , GxB_ANY_FIRST_INT64    ,
7300     GxB_MIN_FIRST_UINT8    , GxB_MAX_FIRST_UINT8    , GxB_PLUS_FIRST_UINT8   , GxB_TIMES_FIRST_UINT8  , GxB_ANY_FIRST_UINT8    ,
7301     GxB_MIN_FIRST_UINT16   , GxB_MAX_FIRST_UINT16   , GxB_PLUS_FIRST_UINT16  , GxB_TIMES_FIRST_UINT16 , GxB_ANY_FIRST_UINT16   ,
7302     GxB_MIN_FIRST_UINT32   , GxB_MAX_FIRST_UINT32   , GxB_PLUS_FIRST_UINT32  , GxB_TIMES_FIRST_UINT32 , GxB_ANY_FIRST_UINT32   ,
7303     GxB_MIN_FIRST_UINT64   , GxB_MAX_FIRST_UINT64   , GxB_PLUS_FIRST_UINT64  , GxB_TIMES_FIRST_UINT64 , GxB_ANY_FIRST_UINT64   ,
7304     GxB_MIN_FIRST_FP32     , GxB_MAX_FIRST_FP32     , GxB_PLUS_FIRST_FP32    , GxB_TIMES_FIRST_FP32   , GxB_ANY_FIRST_FP32     ,
7305     GxB_MIN_FIRST_FP64     , GxB_MAX_FIRST_FP64     , GxB_PLUS_FIRST_FP64    , GxB_TIMES_FIRST_FP64   , GxB_ANY_FIRST_FP64     ,
7306 
7307     // semirings with multiply op: z = SECOND (x,y), all types x,y,z the same:
7308     GxB_MIN_SECOND_INT8    , GxB_MAX_SECOND_INT8    , GxB_PLUS_SECOND_INT8   , GxB_TIMES_SECOND_INT8  , GxB_ANY_SECOND_INT8    ,
7309     GxB_MIN_SECOND_INT16   , GxB_MAX_SECOND_INT16   , GxB_PLUS_SECOND_INT16  , GxB_TIMES_SECOND_INT16 , GxB_ANY_SECOND_INT16   ,
7310     GxB_MIN_SECOND_INT32   , GxB_MAX_SECOND_INT32   , GxB_PLUS_SECOND_INT32  , GxB_TIMES_SECOND_INT32 , GxB_ANY_SECOND_INT32   ,
7311     GxB_MIN_SECOND_INT64   , GxB_MAX_SECOND_INT64   , GxB_PLUS_SECOND_INT64  , GxB_TIMES_SECOND_INT64 , GxB_ANY_SECOND_INT64   ,
7312     GxB_MIN_SECOND_UINT8   , GxB_MAX_SECOND_UINT8   , GxB_PLUS_SECOND_UINT8  , GxB_TIMES_SECOND_UINT8 , GxB_ANY_SECOND_UINT8   ,
7313     GxB_MIN_SECOND_UINT16  , GxB_MAX_SECOND_UINT16  , GxB_PLUS_SECOND_UINT16 , GxB_TIMES_SECOND_UINT16, GxB_ANY_SECOND_UINT16  ,
7314     GxB_MIN_SECOND_UINT32  , GxB_MAX_SECOND_UINT32  , GxB_PLUS_SECOND_UINT32 , GxB_TIMES_SECOND_UINT32, GxB_ANY_SECOND_UINT32  ,
7315     GxB_MIN_SECOND_UINT64  , GxB_MAX_SECOND_UINT64  , GxB_PLUS_SECOND_UINT64 , GxB_TIMES_SECOND_UINT64, GxB_ANY_SECOND_UINT64  ,
7316     GxB_MIN_SECOND_FP32    , GxB_MAX_SECOND_FP32    , GxB_PLUS_SECOND_FP32   , GxB_TIMES_SECOND_FP32  , GxB_ANY_SECOND_FP32    ,
7317     GxB_MIN_SECOND_FP64    , GxB_MAX_SECOND_FP64    , GxB_PLUS_SECOND_FP64   , GxB_TIMES_SECOND_FP64  , GxB_ANY_SECOND_FP64    ,
7318 
7319     // semirings with multiply op: z = PAIR (x,y), all types x,y,z the same:
7320     // (note that min_pair, max_pair, times_pair are all identical to any_pair, and are marked below)
7321     GxB_MIN_PAIR_INT8  /**/, GxB_MAX_PAIR_INT8  /**/, GxB_PLUS_PAIR_INT8     , GxB_TIMES_PAIR_INT8  /**/, GxB_ANY_PAIR_INT8    ,
7322     GxB_MIN_PAIR_INT16 /**/, GxB_MAX_PAIR_INT16 /**/, GxB_PLUS_PAIR_INT16    , GxB_TIMES_PAIR_INT16 /**/, GxB_ANY_PAIR_INT16   ,
7323     GxB_MIN_PAIR_INT32 /**/, GxB_MAX_PAIR_INT32 /**/, GxB_PLUS_PAIR_INT32    , GxB_TIMES_PAIR_INT32 /**/, GxB_ANY_PAIR_INT32   ,
7324     GxB_MIN_PAIR_INT64 /**/, GxB_MAX_PAIR_INT64 /**/, GxB_PLUS_PAIR_INT64    , GxB_TIMES_PAIR_INT64 /**/, GxB_ANY_PAIR_INT64   ,
7325     GxB_MIN_PAIR_UINT8 /**/, GxB_MAX_PAIR_UINT8 /**/, GxB_PLUS_PAIR_UINT8    , GxB_TIMES_PAIR_UINT8 /**/, GxB_ANY_PAIR_UINT8   ,
7326     GxB_MIN_PAIR_UINT16/**/, GxB_MAX_PAIR_UINT16/**/, GxB_PLUS_PAIR_UINT16   , GxB_TIMES_PAIR_UINT16/**/, GxB_ANY_PAIR_UINT16  ,
7327     GxB_MIN_PAIR_UINT32/**/, GxB_MAX_PAIR_UINT32/**/, GxB_PLUS_PAIR_UINT32   , GxB_TIMES_PAIR_UINT32/**/, GxB_ANY_PAIR_UINT32  ,
7328     GxB_MIN_PAIR_UINT64/**/, GxB_MAX_PAIR_UINT64/**/, GxB_PLUS_PAIR_UINT64   , GxB_TIMES_PAIR_UINT64/**/, GxB_ANY_PAIR_UINT64  ,
7329     GxB_MIN_PAIR_FP32  /**/, GxB_MAX_PAIR_FP32  /**/, GxB_PLUS_PAIR_FP32     , GxB_TIMES_PAIR_FP32  /**/, GxB_ANY_PAIR_FP32    ,
7330     GxB_MIN_PAIR_FP64  /**/, GxB_MAX_PAIR_FP64  /**/, GxB_PLUS_PAIR_FP64     , GxB_TIMES_PAIR_FP64  /**/, GxB_ANY_PAIR_FP64    ,
7331 
7332     // semirings with multiply op: z = MIN (x,y), all types x,y,z the same:
7333     GxB_MIN_MIN_INT8       , GxB_MAX_MIN_INT8       , GxB_PLUS_MIN_INT8      , GxB_TIMES_MIN_INT8     , GxB_ANY_MIN_INT8       ,
7334     GxB_MIN_MIN_INT16      , GxB_MAX_MIN_INT16      , GxB_PLUS_MIN_INT16     , GxB_TIMES_MIN_INT16    , GxB_ANY_MIN_INT16      ,
7335     GxB_MIN_MIN_INT32      , GxB_MAX_MIN_INT32      , GxB_PLUS_MIN_INT32     , GxB_TIMES_MIN_INT32    , GxB_ANY_MIN_INT32      ,
7336     GxB_MIN_MIN_INT64      , GxB_MAX_MIN_INT64      , GxB_PLUS_MIN_INT64     , GxB_TIMES_MIN_INT64    , GxB_ANY_MIN_INT64      ,
7337     GxB_MIN_MIN_UINT8      , GxB_MAX_MIN_UINT8      , GxB_PLUS_MIN_UINT8     , GxB_TIMES_MIN_UINT8    , GxB_ANY_MIN_UINT8      ,
7338     GxB_MIN_MIN_UINT16     , GxB_MAX_MIN_UINT16     , GxB_PLUS_MIN_UINT16    , GxB_TIMES_MIN_UINT16   , GxB_ANY_MIN_UINT16     ,
7339     GxB_MIN_MIN_UINT32     , GxB_MAX_MIN_UINT32     , GxB_PLUS_MIN_UINT32    , GxB_TIMES_MIN_UINT32   , GxB_ANY_MIN_UINT32     ,
7340     GxB_MIN_MIN_UINT64     , GxB_MAX_MIN_UINT64     , GxB_PLUS_MIN_UINT64    , GxB_TIMES_MIN_UINT64   , GxB_ANY_MIN_UINT64     ,
7341     GxB_MIN_MIN_FP32       , GxB_MAX_MIN_FP32       , GxB_PLUS_MIN_FP32      , GxB_TIMES_MIN_FP32     , GxB_ANY_MIN_FP32       ,
7342     GxB_MIN_MIN_FP64       , GxB_MAX_MIN_FP64       , GxB_PLUS_MIN_FP64      , GxB_TIMES_MIN_FP64     , GxB_ANY_MIN_FP64       ,
7343 
7344     // semirings with multiply op: z = MAX (x,y), all types x,y,z the same:
7345     GxB_MIN_MAX_INT8       , GxB_MAX_MAX_INT8       , GxB_PLUS_MAX_INT8      , GxB_TIMES_MAX_INT8     , GxB_ANY_MAX_INT8       ,
7346     GxB_MIN_MAX_INT16      , GxB_MAX_MAX_INT16      , GxB_PLUS_MAX_INT16     , GxB_TIMES_MAX_INT16    , GxB_ANY_MAX_INT16      ,
7347     GxB_MIN_MAX_INT32      , GxB_MAX_MAX_INT32      , GxB_PLUS_MAX_INT32     , GxB_TIMES_MAX_INT32    , GxB_ANY_MAX_INT32      ,
7348     GxB_MIN_MAX_INT64      , GxB_MAX_MAX_INT64      , GxB_PLUS_MAX_INT64     , GxB_TIMES_MAX_INT64    , GxB_ANY_MAX_INT64      ,
7349     GxB_MIN_MAX_UINT8      , GxB_MAX_MAX_UINT8      , GxB_PLUS_MAX_UINT8     , GxB_TIMES_MAX_UINT8    , GxB_ANY_MAX_UINT8      ,
7350     GxB_MIN_MAX_UINT16     , GxB_MAX_MAX_UINT16     , GxB_PLUS_MAX_UINT16    , GxB_TIMES_MAX_UINT16   , GxB_ANY_MAX_UINT16     ,
7351     GxB_MIN_MAX_UINT32     , GxB_MAX_MAX_UINT32     , GxB_PLUS_MAX_UINT32    , GxB_TIMES_MAX_UINT32   , GxB_ANY_MAX_UINT32     ,
7352     GxB_MIN_MAX_UINT64     , GxB_MAX_MAX_UINT64     , GxB_PLUS_MAX_UINT64    , GxB_TIMES_MAX_UINT64   , GxB_ANY_MAX_UINT64     ,
7353     GxB_MIN_MAX_FP32       , GxB_MAX_MAX_FP32       , GxB_PLUS_MAX_FP32      , GxB_TIMES_MAX_FP32     , GxB_ANY_MAX_FP32       ,
7354     GxB_MIN_MAX_FP64       , GxB_MAX_MAX_FP64       , GxB_PLUS_MAX_FP64      , GxB_TIMES_MAX_FP64     , GxB_ANY_MAX_FP64       ,
7355 
7356     // semirings with multiply op: z = PLUS (x,y), all types x,y,z the same:
7357     GxB_MIN_PLUS_INT8      , GxB_MAX_PLUS_INT8      , GxB_PLUS_PLUS_INT8     , GxB_TIMES_PLUS_INT8    , GxB_ANY_PLUS_INT8      ,
7358     GxB_MIN_PLUS_INT16     , GxB_MAX_PLUS_INT16     , GxB_PLUS_PLUS_INT16    , GxB_TIMES_PLUS_INT16   , GxB_ANY_PLUS_INT16     ,
7359     GxB_MIN_PLUS_INT32     , GxB_MAX_PLUS_INT32     , GxB_PLUS_PLUS_INT32    , GxB_TIMES_PLUS_INT32   , GxB_ANY_PLUS_INT32     ,
7360     GxB_MIN_PLUS_INT64     , GxB_MAX_PLUS_INT64     , GxB_PLUS_PLUS_INT64    , GxB_TIMES_PLUS_INT64   , GxB_ANY_PLUS_INT64     ,
7361     GxB_MIN_PLUS_UINT8     , GxB_MAX_PLUS_UINT8     , GxB_PLUS_PLUS_UINT8    , GxB_TIMES_PLUS_UINT8   , GxB_ANY_PLUS_UINT8     ,
7362     GxB_MIN_PLUS_UINT16    , GxB_MAX_PLUS_UINT16    , GxB_PLUS_PLUS_UINT16   , GxB_TIMES_PLUS_UINT16  , GxB_ANY_PLUS_UINT16    ,
7363     GxB_MIN_PLUS_UINT32    , GxB_MAX_PLUS_UINT32    , GxB_PLUS_PLUS_UINT32   , GxB_TIMES_PLUS_UINT32  , GxB_ANY_PLUS_UINT32    ,
7364     GxB_MIN_PLUS_UINT64    , GxB_MAX_PLUS_UINT64    , GxB_PLUS_PLUS_UINT64   , GxB_TIMES_PLUS_UINT64  , GxB_ANY_PLUS_UINT64    ,
7365     GxB_MIN_PLUS_FP32      , GxB_MAX_PLUS_FP32      , GxB_PLUS_PLUS_FP32     , GxB_TIMES_PLUS_FP32    , GxB_ANY_PLUS_FP32      ,
7366     GxB_MIN_PLUS_FP64      , GxB_MAX_PLUS_FP64      , GxB_PLUS_PLUS_FP64     , GxB_TIMES_PLUS_FP64    , GxB_ANY_PLUS_FP64      ,
7367 
7368     // semirings with multiply op: z = MINUS (x,y), all types x,y,z the same:
7369     GxB_MIN_MINUS_INT8     , GxB_MAX_MINUS_INT8     , GxB_PLUS_MINUS_INT8    , GxB_TIMES_MINUS_INT8   , GxB_ANY_MINUS_INT8     ,
7370     GxB_MIN_MINUS_INT16    , GxB_MAX_MINUS_INT16    , GxB_PLUS_MINUS_INT16   , GxB_TIMES_MINUS_INT16  , GxB_ANY_MINUS_INT16    ,
7371     GxB_MIN_MINUS_INT32    , GxB_MAX_MINUS_INT32    , GxB_PLUS_MINUS_INT32   , GxB_TIMES_MINUS_INT32  , GxB_ANY_MINUS_INT32    ,
7372     GxB_MIN_MINUS_INT64    , GxB_MAX_MINUS_INT64    , GxB_PLUS_MINUS_INT64   , GxB_TIMES_MINUS_INT64  , GxB_ANY_MINUS_INT64    ,
7373     GxB_MIN_MINUS_UINT8    , GxB_MAX_MINUS_UINT8    , GxB_PLUS_MINUS_UINT8   , GxB_TIMES_MINUS_UINT8  , GxB_ANY_MINUS_UINT8    ,
7374     GxB_MIN_MINUS_UINT16   , GxB_MAX_MINUS_UINT16   , GxB_PLUS_MINUS_UINT16  , GxB_TIMES_MINUS_UINT16 , GxB_ANY_MINUS_UINT16   ,
7375     GxB_MIN_MINUS_UINT32   , GxB_MAX_MINUS_UINT32   , GxB_PLUS_MINUS_UINT32  , GxB_TIMES_MINUS_UINT32 , GxB_ANY_MINUS_UINT32   ,
7376     GxB_MIN_MINUS_UINT64   , GxB_MAX_MINUS_UINT64   , GxB_PLUS_MINUS_UINT64  , GxB_TIMES_MINUS_UINT64 , GxB_ANY_MINUS_UINT64   ,
7377     GxB_MIN_MINUS_FP32     , GxB_MAX_MINUS_FP32     , GxB_PLUS_MINUS_FP32    , GxB_TIMES_MINUS_FP32   , GxB_ANY_MINUS_FP32     ,
7378     GxB_MIN_MINUS_FP64     , GxB_MAX_MINUS_FP64     , GxB_PLUS_MINUS_FP64    , GxB_TIMES_MINUS_FP64   , GxB_ANY_MINUS_FP64     ,
7379 
7380     // semirings with multiply op: z = TIMES (x,y), all types x,y,z the same:
7381     GxB_MIN_TIMES_INT8     , GxB_MAX_TIMES_INT8     , GxB_PLUS_TIMES_INT8    , GxB_TIMES_TIMES_INT8   , GxB_ANY_TIMES_INT8     ,
7382     GxB_MIN_TIMES_INT16    , GxB_MAX_TIMES_INT16    , GxB_PLUS_TIMES_INT16   , GxB_TIMES_TIMES_INT16  , GxB_ANY_TIMES_INT16    ,
7383     GxB_MIN_TIMES_INT32    , GxB_MAX_TIMES_INT32    , GxB_PLUS_TIMES_INT32   , GxB_TIMES_TIMES_INT32  , GxB_ANY_TIMES_INT32    ,
7384     GxB_MIN_TIMES_INT64    , GxB_MAX_TIMES_INT64    , GxB_PLUS_TIMES_INT64   , GxB_TIMES_TIMES_INT64  , GxB_ANY_TIMES_INT64    ,
7385     GxB_MIN_TIMES_UINT8    , GxB_MAX_TIMES_UINT8    , GxB_PLUS_TIMES_UINT8   , GxB_TIMES_TIMES_UINT8  , GxB_ANY_TIMES_UINT8    ,
7386     GxB_MIN_TIMES_UINT16   , GxB_MAX_TIMES_UINT16   , GxB_PLUS_TIMES_UINT16  , GxB_TIMES_TIMES_UINT16 , GxB_ANY_TIMES_UINT16   ,
7387     GxB_MIN_TIMES_UINT32   , GxB_MAX_TIMES_UINT32   , GxB_PLUS_TIMES_UINT32  , GxB_TIMES_TIMES_UINT32 , GxB_ANY_TIMES_UINT32   ,
7388     GxB_MIN_TIMES_UINT64   , GxB_MAX_TIMES_UINT64   , GxB_PLUS_TIMES_UINT64  , GxB_TIMES_TIMES_UINT64 , GxB_ANY_TIMES_UINT64   ,
7389     GxB_MIN_TIMES_FP32     , GxB_MAX_TIMES_FP32     , GxB_PLUS_TIMES_FP32    , GxB_TIMES_TIMES_FP32   , GxB_ANY_TIMES_FP32     ,
7390     GxB_MIN_TIMES_FP64     , GxB_MAX_TIMES_FP64     , GxB_PLUS_TIMES_FP64    , GxB_TIMES_TIMES_FP64   , GxB_ANY_TIMES_FP64     ,
7391 
7392     // semirings with multiply op: z = DIV (x,y), all types x,y,z the same:
7393     GxB_MIN_DIV_INT8       , GxB_MAX_DIV_INT8       , GxB_PLUS_DIV_INT8      , GxB_TIMES_DIV_INT8     , GxB_ANY_DIV_INT8       ,
7394     GxB_MIN_DIV_INT16      , GxB_MAX_DIV_INT16      , GxB_PLUS_DIV_INT16     , GxB_TIMES_DIV_INT16    , GxB_ANY_DIV_INT16      ,
7395     GxB_MIN_DIV_INT32      , GxB_MAX_DIV_INT32      , GxB_PLUS_DIV_INT32     , GxB_TIMES_DIV_INT32    , GxB_ANY_DIV_INT32      ,
7396     GxB_MIN_DIV_INT64      , GxB_MAX_DIV_INT64      , GxB_PLUS_DIV_INT64     , GxB_TIMES_DIV_INT64    , GxB_ANY_DIV_INT64      ,
7397     GxB_MIN_DIV_UINT8      , GxB_MAX_DIV_UINT8      , GxB_PLUS_DIV_UINT8     , GxB_TIMES_DIV_UINT8    , GxB_ANY_DIV_UINT8      ,
7398     GxB_MIN_DIV_UINT16     , GxB_MAX_DIV_UINT16     , GxB_PLUS_DIV_UINT16    , GxB_TIMES_DIV_UINT16   , GxB_ANY_DIV_UINT16     ,
7399     GxB_MIN_DIV_UINT32     , GxB_MAX_DIV_UINT32     , GxB_PLUS_DIV_UINT32    , GxB_TIMES_DIV_UINT32   , GxB_ANY_DIV_UINT32     ,
7400     GxB_MIN_DIV_UINT64     , GxB_MAX_DIV_UINT64     , GxB_PLUS_DIV_UINT64    , GxB_TIMES_DIV_UINT64   , GxB_ANY_DIV_UINT64     ,
7401     GxB_MIN_DIV_FP32       , GxB_MAX_DIV_FP32       , GxB_PLUS_DIV_FP32      , GxB_TIMES_DIV_FP32     , GxB_ANY_DIV_FP32       ,
7402     GxB_MIN_DIV_FP64       , GxB_MAX_DIV_FP64       , GxB_PLUS_DIV_FP64      , GxB_TIMES_DIV_FP64     , GxB_ANY_DIV_FP64       ,
7403 
7404     // semirings with multiply op: z = RDIV (x,y), all types x,y,z the same:
7405     GxB_MIN_RDIV_INT8      , GxB_MAX_RDIV_INT8      , GxB_PLUS_RDIV_INT8     , GxB_TIMES_RDIV_INT8    , GxB_ANY_RDIV_INT8      ,
7406     GxB_MIN_RDIV_INT16     , GxB_MAX_RDIV_INT16     , GxB_PLUS_RDIV_INT16    , GxB_TIMES_RDIV_INT16   , GxB_ANY_RDIV_INT16     ,
7407     GxB_MIN_RDIV_INT32     , GxB_MAX_RDIV_INT32     , GxB_PLUS_RDIV_INT32    , GxB_TIMES_RDIV_INT32   , GxB_ANY_RDIV_INT32     ,
7408     GxB_MIN_RDIV_INT64     , GxB_MAX_RDIV_INT64     , GxB_PLUS_RDIV_INT64    , GxB_TIMES_RDIV_INT64   , GxB_ANY_RDIV_INT64     ,
7409     GxB_MIN_RDIV_UINT8     , GxB_MAX_RDIV_UINT8     , GxB_PLUS_RDIV_UINT8    , GxB_TIMES_RDIV_UINT8   , GxB_ANY_RDIV_UINT8     ,
7410     GxB_MIN_RDIV_UINT16    , GxB_MAX_RDIV_UINT16    , GxB_PLUS_RDIV_UINT16   , GxB_TIMES_RDIV_UINT16  , GxB_ANY_RDIV_UINT16    ,
7411     GxB_MIN_RDIV_UINT32    , GxB_MAX_RDIV_UINT32    , GxB_PLUS_RDIV_UINT32   , GxB_TIMES_RDIV_UINT32  , GxB_ANY_RDIV_UINT32    ,
7412     GxB_MIN_RDIV_UINT64    , GxB_MAX_RDIV_UINT64    , GxB_PLUS_RDIV_UINT64   , GxB_TIMES_RDIV_UINT64  , GxB_ANY_RDIV_UINT64    ,
7413     GxB_MIN_RDIV_FP32      , GxB_MAX_RDIV_FP32      , GxB_PLUS_RDIV_FP32     , GxB_TIMES_RDIV_FP32    , GxB_ANY_RDIV_FP32      ,
7414     GxB_MIN_RDIV_FP64      , GxB_MAX_RDIV_FP64      , GxB_PLUS_RDIV_FP64     , GxB_TIMES_RDIV_FP64    , GxB_ANY_RDIV_FP64      ,
7415 
7416     // semirings with multiply op: z = RMINUS (x,y), all types x,y,z the same:
7417     GxB_MIN_RMINUS_INT8    , GxB_MAX_RMINUS_INT8    , GxB_PLUS_RMINUS_INT8   , GxB_TIMES_RMINUS_INT8  , GxB_ANY_RMINUS_INT8    ,
7418     GxB_MIN_RMINUS_INT16   , GxB_MAX_RMINUS_INT16   , GxB_PLUS_RMINUS_INT16  , GxB_TIMES_RMINUS_INT16 , GxB_ANY_RMINUS_INT16   ,
7419     GxB_MIN_RMINUS_INT32   , GxB_MAX_RMINUS_INT32   , GxB_PLUS_RMINUS_INT32  , GxB_TIMES_RMINUS_INT32 , GxB_ANY_RMINUS_INT32   ,
7420     GxB_MIN_RMINUS_INT64   , GxB_MAX_RMINUS_INT64   , GxB_PLUS_RMINUS_INT64  , GxB_TIMES_RMINUS_INT64 , GxB_ANY_RMINUS_INT64   ,
7421     GxB_MIN_RMINUS_UINT8   , GxB_MAX_RMINUS_UINT8   , GxB_PLUS_RMINUS_UINT8  , GxB_TIMES_RMINUS_UINT8 , GxB_ANY_RMINUS_UINT8   ,
7422     GxB_MIN_RMINUS_UINT16  , GxB_MAX_RMINUS_UINT16  , GxB_PLUS_RMINUS_UINT16 , GxB_TIMES_RMINUS_UINT16, GxB_ANY_RMINUS_UINT16  ,
7423     GxB_MIN_RMINUS_UINT32  , GxB_MAX_RMINUS_UINT32  , GxB_PLUS_RMINUS_UINT32 , GxB_TIMES_RMINUS_UINT32, GxB_ANY_RMINUS_UINT32  ,
7424     GxB_MIN_RMINUS_UINT64  , GxB_MAX_RMINUS_UINT64  , GxB_PLUS_RMINUS_UINT64 , GxB_TIMES_RMINUS_UINT64, GxB_ANY_RMINUS_UINT64  ,
7425     GxB_MIN_RMINUS_FP32    , GxB_MAX_RMINUS_FP32    , GxB_PLUS_RMINUS_FP32   , GxB_TIMES_RMINUS_FP32  , GxB_ANY_RMINUS_FP32    ,
7426     GxB_MIN_RMINUS_FP64    , GxB_MAX_RMINUS_FP64    , GxB_PLUS_RMINUS_FP64   , GxB_TIMES_RMINUS_FP64  , GxB_ANY_RMINUS_FP64    ,
7427 
7428     // semirings with multiply op: z = ISEQ (x,y), all types x,y,z the same:
7429     GxB_MIN_ISEQ_INT8      , GxB_MAX_ISEQ_INT8      , GxB_PLUS_ISEQ_INT8     , GxB_TIMES_ISEQ_INT8    , GxB_ANY_ISEQ_INT8      ,
7430     GxB_MIN_ISEQ_INT16     , GxB_MAX_ISEQ_INT16     , GxB_PLUS_ISEQ_INT16    , GxB_TIMES_ISEQ_INT16   , GxB_ANY_ISEQ_INT16     ,
7431     GxB_MIN_ISEQ_INT32     , GxB_MAX_ISEQ_INT32     , GxB_PLUS_ISEQ_INT32    , GxB_TIMES_ISEQ_INT32   , GxB_ANY_ISEQ_INT32     ,
7432     GxB_MIN_ISEQ_INT64     , GxB_MAX_ISEQ_INT64     , GxB_PLUS_ISEQ_INT64    , GxB_TIMES_ISEQ_INT64   , GxB_ANY_ISEQ_INT64     ,
7433     GxB_MIN_ISEQ_UINT8     , GxB_MAX_ISEQ_UINT8     , GxB_PLUS_ISEQ_UINT8    , GxB_TIMES_ISEQ_UINT8   , GxB_ANY_ISEQ_UINT8     ,
7434     GxB_MIN_ISEQ_UINT16    , GxB_MAX_ISEQ_UINT16    , GxB_PLUS_ISEQ_UINT16   , GxB_TIMES_ISEQ_UINT16  , GxB_ANY_ISEQ_UINT16    ,
7435     GxB_MIN_ISEQ_UINT32    , GxB_MAX_ISEQ_UINT32    , GxB_PLUS_ISEQ_UINT32   , GxB_TIMES_ISEQ_UINT32  , GxB_ANY_ISEQ_UINT32    ,
7436     GxB_MIN_ISEQ_UINT64    , GxB_MAX_ISEQ_UINT64    , GxB_PLUS_ISEQ_UINT64   , GxB_TIMES_ISEQ_UINT64  , GxB_ANY_ISEQ_UINT64    ,
7437     GxB_MIN_ISEQ_FP32      , GxB_MAX_ISEQ_FP32      , GxB_PLUS_ISEQ_FP32     , GxB_TIMES_ISEQ_FP32    , GxB_ANY_ISEQ_FP32      ,
7438     GxB_MIN_ISEQ_FP64      , GxB_MAX_ISEQ_FP64      , GxB_PLUS_ISEQ_FP64     , GxB_TIMES_ISEQ_FP64    , GxB_ANY_ISEQ_FP64      ,
7439 
7440     // semirings with multiply op: z = ISNE (x,y), all types x,y,z the same:
7441     GxB_MIN_ISNE_INT8      , GxB_MAX_ISNE_INT8      , GxB_PLUS_ISNE_INT8     , GxB_TIMES_ISNE_INT8    , GxB_ANY_ISNE_INT8      ,
7442     GxB_MIN_ISNE_INT16     , GxB_MAX_ISNE_INT16     , GxB_PLUS_ISNE_INT16    , GxB_TIMES_ISNE_INT16   , GxB_ANY_ISNE_INT16     ,
7443     GxB_MIN_ISNE_INT32     , GxB_MAX_ISNE_INT32     , GxB_PLUS_ISNE_INT32    , GxB_TIMES_ISNE_INT32   , GxB_ANY_ISNE_INT32     ,
7444     GxB_MIN_ISNE_INT64     , GxB_MAX_ISNE_INT64     , GxB_PLUS_ISNE_INT64    , GxB_TIMES_ISNE_INT64   , GxB_ANY_ISNE_INT64     ,
7445     GxB_MIN_ISNE_UINT8     , GxB_MAX_ISNE_UINT8     , GxB_PLUS_ISNE_UINT8    , GxB_TIMES_ISNE_UINT8   , GxB_ANY_ISNE_UINT8     ,
7446     GxB_MIN_ISNE_UINT16    , GxB_MAX_ISNE_UINT16    , GxB_PLUS_ISNE_UINT16   , GxB_TIMES_ISNE_UINT16  , GxB_ANY_ISNE_UINT16    ,
7447     GxB_MIN_ISNE_UINT32    , GxB_MAX_ISNE_UINT32    , GxB_PLUS_ISNE_UINT32   , GxB_TIMES_ISNE_UINT32  , GxB_ANY_ISNE_UINT32    ,
7448     GxB_MIN_ISNE_UINT64    , GxB_MAX_ISNE_UINT64    , GxB_PLUS_ISNE_UINT64   , GxB_TIMES_ISNE_UINT64  , GxB_ANY_ISNE_UINT64    ,
7449     GxB_MIN_ISNE_FP32      , GxB_MAX_ISNE_FP32      , GxB_PLUS_ISNE_FP32     , GxB_TIMES_ISNE_FP32    , GxB_ANY_ISNE_FP32      ,
7450     GxB_MIN_ISNE_FP64      , GxB_MAX_ISNE_FP64      , GxB_PLUS_ISNE_FP64     , GxB_TIMES_ISNE_FP64    , GxB_ANY_ISNE_FP64      ,
7451 
7452     // semirings with multiply op: z = ISGT (x,y), all types x,y,z the same:
7453     GxB_MIN_ISGT_INT8      , GxB_MAX_ISGT_INT8      , GxB_PLUS_ISGT_INT8     , GxB_TIMES_ISGT_INT8    , GxB_ANY_ISGT_INT8      ,
7454     GxB_MIN_ISGT_INT16     , GxB_MAX_ISGT_INT16     , GxB_PLUS_ISGT_INT16    , GxB_TIMES_ISGT_INT16   , GxB_ANY_ISGT_INT16     ,
7455     GxB_MIN_ISGT_INT32     , GxB_MAX_ISGT_INT32     , GxB_PLUS_ISGT_INT32    , GxB_TIMES_ISGT_INT32   , GxB_ANY_ISGT_INT32     ,
7456     GxB_MIN_ISGT_INT64     , GxB_MAX_ISGT_INT64     , GxB_PLUS_ISGT_INT64    , GxB_TIMES_ISGT_INT64   , GxB_ANY_ISGT_INT64     ,
7457     GxB_MIN_ISGT_UINT8     , GxB_MAX_ISGT_UINT8     , GxB_PLUS_ISGT_UINT8    , GxB_TIMES_ISGT_UINT8   , GxB_ANY_ISGT_UINT8     ,
7458     GxB_MIN_ISGT_UINT16    , GxB_MAX_ISGT_UINT16    , GxB_PLUS_ISGT_UINT16   , GxB_TIMES_ISGT_UINT16  , GxB_ANY_ISGT_UINT16    ,
7459     GxB_MIN_ISGT_UINT32    , GxB_MAX_ISGT_UINT32    , GxB_PLUS_ISGT_UINT32   , GxB_TIMES_ISGT_UINT32  , GxB_ANY_ISGT_UINT32    ,
7460     GxB_MIN_ISGT_UINT64    , GxB_MAX_ISGT_UINT64    , GxB_PLUS_ISGT_UINT64   , GxB_TIMES_ISGT_UINT64  , GxB_ANY_ISGT_UINT64    ,
7461     GxB_MIN_ISGT_FP32      , GxB_MAX_ISGT_FP32      , GxB_PLUS_ISGT_FP32     , GxB_TIMES_ISGT_FP32    , GxB_ANY_ISGT_FP32      ,
7462     GxB_MIN_ISGT_FP64      , GxB_MAX_ISGT_FP64      , GxB_PLUS_ISGT_FP64     , GxB_TIMES_ISGT_FP64    , GxB_ANY_ISGT_FP64      ,
7463 
7464     // semirings with multiply op: z = ISLT (x,y), all types x,y,z the same:
7465     GxB_MIN_ISLT_INT8      , GxB_MAX_ISLT_INT8      , GxB_PLUS_ISLT_INT8     , GxB_TIMES_ISLT_INT8    , GxB_ANY_ISLT_INT8      ,
7466     GxB_MIN_ISLT_INT16     , GxB_MAX_ISLT_INT16     , GxB_PLUS_ISLT_INT16    , GxB_TIMES_ISLT_INT16   , GxB_ANY_ISLT_INT16     ,
7467     GxB_MIN_ISLT_INT32     , GxB_MAX_ISLT_INT32     , GxB_PLUS_ISLT_INT32    , GxB_TIMES_ISLT_INT32   , GxB_ANY_ISLT_INT32     ,
7468     GxB_MIN_ISLT_INT64     , GxB_MAX_ISLT_INT64     , GxB_PLUS_ISLT_INT64    , GxB_TIMES_ISLT_INT64   , GxB_ANY_ISLT_INT64     ,
7469     GxB_MIN_ISLT_UINT8     , GxB_MAX_ISLT_UINT8     , GxB_PLUS_ISLT_UINT8    , GxB_TIMES_ISLT_UINT8   , GxB_ANY_ISLT_UINT8     ,
7470     GxB_MIN_ISLT_UINT16    , GxB_MAX_ISLT_UINT16    , GxB_PLUS_ISLT_UINT16   , GxB_TIMES_ISLT_UINT16  , GxB_ANY_ISLT_UINT16    ,
7471     GxB_MIN_ISLT_UINT32    , GxB_MAX_ISLT_UINT32    , GxB_PLUS_ISLT_UINT32   , GxB_TIMES_ISLT_UINT32  , GxB_ANY_ISLT_UINT32    ,
7472     GxB_MIN_ISLT_UINT64    , GxB_MAX_ISLT_UINT64    , GxB_PLUS_ISLT_UINT64   , GxB_TIMES_ISLT_UINT64  , GxB_ANY_ISLT_UINT64    ,
7473     GxB_MIN_ISLT_FP32      , GxB_MAX_ISLT_FP32      , GxB_PLUS_ISLT_FP32     , GxB_TIMES_ISLT_FP32    , GxB_ANY_ISLT_FP32      ,
7474     GxB_MIN_ISLT_FP64      , GxB_MAX_ISLT_FP64      , GxB_PLUS_ISLT_FP64     , GxB_TIMES_ISLT_FP64    , GxB_ANY_ISLT_FP64      ,
7475 
7476     // semirings with multiply op: z = ISGE (x,y), all types x,y,z the same:
7477     GxB_MIN_ISGE_INT8      , GxB_MAX_ISGE_INT8      , GxB_PLUS_ISGE_INT8     , GxB_TIMES_ISGE_INT8    , GxB_ANY_ISGE_INT8      ,
7478     GxB_MIN_ISGE_INT16     , GxB_MAX_ISGE_INT16     , GxB_PLUS_ISGE_INT16    , GxB_TIMES_ISGE_INT16   , GxB_ANY_ISGE_INT16     ,
7479     GxB_MIN_ISGE_INT32     , GxB_MAX_ISGE_INT32     , GxB_PLUS_ISGE_INT32    , GxB_TIMES_ISGE_INT32   , GxB_ANY_ISGE_INT32     ,
7480     GxB_MIN_ISGE_INT64     , GxB_MAX_ISGE_INT64     , GxB_PLUS_ISGE_INT64    , GxB_TIMES_ISGE_INT64   , GxB_ANY_ISGE_INT64     ,
7481     GxB_MIN_ISGE_UINT8     , GxB_MAX_ISGE_UINT8     , GxB_PLUS_ISGE_UINT8    , GxB_TIMES_ISGE_UINT8   , GxB_ANY_ISGE_UINT8     ,
7482     GxB_MIN_ISGE_UINT16    , GxB_MAX_ISGE_UINT16    , GxB_PLUS_ISGE_UINT16   , GxB_TIMES_ISGE_UINT16  , GxB_ANY_ISGE_UINT16    ,
7483     GxB_MIN_ISGE_UINT32    , GxB_MAX_ISGE_UINT32    , GxB_PLUS_ISGE_UINT32   , GxB_TIMES_ISGE_UINT32  , GxB_ANY_ISGE_UINT32    ,
7484     GxB_MIN_ISGE_UINT64    , GxB_MAX_ISGE_UINT64    , GxB_PLUS_ISGE_UINT64   , GxB_TIMES_ISGE_UINT64  , GxB_ANY_ISGE_UINT64    ,
7485     GxB_MIN_ISGE_FP32      , GxB_MAX_ISGE_FP32      , GxB_PLUS_ISGE_FP32     , GxB_TIMES_ISGE_FP32    , GxB_ANY_ISGE_FP32      ,
7486     GxB_MIN_ISGE_FP64      , GxB_MAX_ISGE_FP64      , GxB_PLUS_ISGE_FP64     , GxB_TIMES_ISGE_FP64    , GxB_ANY_ISGE_FP64      ,
7487 
7488     // semirings with multiply op: z = ISLE (x,y), all types x,y,z the same:
7489     GxB_MIN_ISLE_INT8      , GxB_MAX_ISLE_INT8      , GxB_PLUS_ISLE_INT8     , GxB_TIMES_ISLE_INT8    , GxB_ANY_ISLE_INT8      ,
7490     GxB_MIN_ISLE_INT16     , GxB_MAX_ISLE_INT16     , GxB_PLUS_ISLE_INT16    , GxB_TIMES_ISLE_INT16   , GxB_ANY_ISLE_INT16     ,
7491     GxB_MIN_ISLE_INT32     , GxB_MAX_ISLE_INT32     , GxB_PLUS_ISLE_INT32    , GxB_TIMES_ISLE_INT32   , GxB_ANY_ISLE_INT32     ,
7492     GxB_MIN_ISLE_INT64     , GxB_MAX_ISLE_INT64     , GxB_PLUS_ISLE_INT64    , GxB_TIMES_ISLE_INT64   , GxB_ANY_ISLE_INT64     ,
7493     GxB_MIN_ISLE_UINT8     , GxB_MAX_ISLE_UINT8     , GxB_PLUS_ISLE_UINT8    , GxB_TIMES_ISLE_UINT8   , GxB_ANY_ISLE_UINT8     ,
7494     GxB_MIN_ISLE_UINT16    , GxB_MAX_ISLE_UINT16    , GxB_PLUS_ISLE_UINT16   , GxB_TIMES_ISLE_UINT16  , GxB_ANY_ISLE_UINT16    ,
7495     GxB_MIN_ISLE_UINT32    , GxB_MAX_ISLE_UINT32    , GxB_PLUS_ISLE_UINT32   , GxB_TIMES_ISLE_UINT32  , GxB_ANY_ISLE_UINT32    ,
7496     GxB_MIN_ISLE_UINT64    , GxB_MAX_ISLE_UINT64    , GxB_PLUS_ISLE_UINT64   , GxB_TIMES_ISLE_UINT64  , GxB_ANY_ISLE_UINT64    ,
7497     GxB_MIN_ISLE_FP32      , GxB_MAX_ISLE_FP32      , GxB_PLUS_ISLE_FP32     , GxB_TIMES_ISLE_FP32    , GxB_ANY_ISLE_FP32      ,
7498     GxB_MIN_ISLE_FP64      , GxB_MAX_ISLE_FP64      , GxB_PLUS_ISLE_FP64     , GxB_TIMES_ISLE_FP64    , GxB_ANY_ISLE_FP64      ,
7499 
7500     // semirings with multiply op: z = LOR (x,y), all types x,y,z the same:
7501     GxB_MIN_LOR_INT8       , GxB_MAX_LOR_INT8       , GxB_PLUS_LOR_INT8      , GxB_TIMES_LOR_INT8     , GxB_ANY_LOR_INT8       ,
7502     GxB_MIN_LOR_INT16      , GxB_MAX_LOR_INT16      , GxB_PLUS_LOR_INT16     , GxB_TIMES_LOR_INT16    , GxB_ANY_LOR_INT16      ,
7503     GxB_MIN_LOR_INT32      , GxB_MAX_LOR_INT32      , GxB_PLUS_LOR_INT32     , GxB_TIMES_LOR_INT32    , GxB_ANY_LOR_INT32      ,
7504     GxB_MIN_LOR_INT64      , GxB_MAX_LOR_INT64      , GxB_PLUS_LOR_INT64     , GxB_TIMES_LOR_INT64    , GxB_ANY_LOR_INT64      ,
7505     GxB_MIN_LOR_UINT8      , GxB_MAX_LOR_UINT8      , GxB_PLUS_LOR_UINT8     , GxB_TIMES_LOR_UINT8    , GxB_ANY_LOR_UINT8      ,
7506     GxB_MIN_LOR_UINT16     , GxB_MAX_LOR_UINT16     , GxB_PLUS_LOR_UINT16    , GxB_TIMES_LOR_UINT16   , GxB_ANY_LOR_UINT16     ,
7507     GxB_MIN_LOR_UINT32     , GxB_MAX_LOR_UINT32     , GxB_PLUS_LOR_UINT32    , GxB_TIMES_LOR_UINT32   , GxB_ANY_LOR_UINT32     ,
7508     GxB_MIN_LOR_UINT64     , GxB_MAX_LOR_UINT64     , GxB_PLUS_LOR_UINT64    , GxB_TIMES_LOR_UINT64   , GxB_ANY_LOR_UINT64     ,
7509     GxB_MIN_LOR_FP32       , GxB_MAX_LOR_FP32       , GxB_PLUS_LOR_FP32      , GxB_TIMES_LOR_FP32     , GxB_ANY_LOR_FP32       ,
7510     GxB_MIN_LOR_FP64       , GxB_MAX_LOR_FP64       , GxB_PLUS_LOR_FP64      , GxB_TIMES_LOR_FP64     , GxB_ANY_LOR_FP64       ,
7511 
7512     // semirings with multiply op: z = LAND (x,y), all types x,y,z the same:
7513     GxB_MIN_LAND_INT8      , GxB_MAX_LAND_INT8      , GxB_PLUS_LAND_INT8     , GxB_TIMES_LAND_INT8    , GxB_ANY_LAND_INT8      ,
7514     GxB_MIN_LAND_INT16     , GxB_MAX_LAND_INT16     , GxB_PLUS_LAND_INT16    , GxB_TIMES_LAND_INT16   , GxB_ANY_LAND_INT16     ,
7515     GxB_MIN_LAND_INT32     , GxB_MAX_LAND_INT32     , GxB_PLUS_LAND_INT32    , GxB_TIMES_LAND_INT32   , GxB_ANY_LAND_INT32     ,
7516     GxB_MIN_LAND_INT64     , GxB_MAX_LAND_INT64     , GxB_PLUS_LAND_INT64    , GxB_TIMES_LAND_INT64   , GxB_ANY_LAND_INT64     ,
7517     GxB_MIN_LAND_UINT8     , GxB_MAX_LAND_UINT8     , GxB_PLUS_LAND_UINT8    , GxB_TIMES_LAND_UINT8   , GxB_ANY_LAND_UINT8     ,
7518     GxB_MIN_LAND_UINT16    , GxB_MAX_LAND_UINT16    , GxB_PLUS_LAND_UINT16   , GxB_TIMES_LAND_UINT16  , GxB_ANY_LAND_UINT16    ,
7519     GxB_MIN_LAND_UINT32    , GxB_MAX_LAND_UINT32    , GxB_PLUS_LAND_UINT32   , GxB_TIMES_LAND_UINT32  , GxB_ANY_LAND_UINT32    ,
7520     GxB_MIN_LAND_UINT64    , GxB_MAX_LAND_UINT64    , GxB_PLUS_LAND_UINT64   , GxB_TIMES_LAND_UINT64  , GxB_ANY_LAND_UINT64    ,
7521     GxB_MIN_LAND_FP32      , GxB_MAX_LAND_FP32      , GxB_PLUS_LAND_FP32     , GxB_TIMES_LAND_FP32    , GxB_ANY_LAND_FP32      ,
7522     GxB_MIN_LAND_FP64      , GxB_MAX_LAND_FP64      , GxB_PLUS_LAND_FP64     , GxB_TIMES_LAND_FP64    , GxB_ANY_LAND_FP64      ,
7523 
7524     // semirings with multiply op: z = LXOR (x,y), all types x,y,z the same:
7525     GxB_MIN_LXOR_INT8      , GxB_MAX_LXOR_INT8      , GxB_PLUS_LXOR_INT8     , GxB_TIMES_LXOR_INT8    , GxB_ANY_LXOR_INT8      ,
7526     GxB_MIN_LXOR_INT16     , GxB_MAX_LXOR_INT16     , GxB_PLUS_LXOR_INT16    , GxB_TIMES_LXOR_INT16   , GxB_ANY_LXOR_INT16     ,
7527     GxB_MIN_LXOR_INT32     , GxB_MAX_LXOR_INT32     , GxB_PLUS_LXOR_INT32    , GxB_TIMES_LXOR_INT32   , GxB_ANY_LXOR_INT32     ,
7528     GxB_MIN_LXOR_INT64     , GxB_MAX_LXOR_INT64     , GxB_PLUS_LXOR_INT64    , GxB_TIMES_LXOR_INT64   , GxB_ANY_LXOR_INT64     ,
7529     GxB_MIN_LXOR_UINT8     , GxB_MAX_LXOR_UINT8     , GxB_PLUS_LXOR_UINT8    , GxB_TIMES_LXOR_UINT8   , GxB_ANY_LXOR_UINT8     ,
7530     GxB_MIN_LXOR_UINT16    , GxB_MAX_LXOR_UINT16    , GxB_PLUS_LXOR_UINT16   , GxB_TIMES_LXOR_UINT16  , GxB_ANY_LXOR_UINT16    ,
7531     GxB_MIN_LXOR_UINT32    , GxB_MAX_LXOR_UINT32    , GxB_PLUS_LXOR_UINT32   , GxB_TIMES_LXOR_UINT32  , GxB_ANY_LXOR_UINT32    ,
7532     GxB_MIN_LXOR_UINT64    , GxB_MAX_LXOR_UINT64    , GxB_PLUS_LXOR_UINT64   , GxB_TIMES_LXOR_UINT64  , GxB_ANY_LXOR_UINT64    ,
7533     GxB_MIN_LXOR_FP32      , GxB_MAX_LXOR_FP32      , GxB_PLUS_LXOR_FP32     , GxB_TIMES_LXOR_FP32    , GxB_ANY_LXOR_FP32      ,
7534     GxB_MIN_LXOR_FP64      , GxB_MAX_LXOR_FP64      , GxB_PLUS_LXOR_FP64     , GxB_TIMES_LXOR_FP64    , GxB_ANY_LXOR_FP64      ,
7535 
7536 //------------------------------------------------------------------------------
7537 // 300 semirings with a comparison operator TxT -> bool, where T is non-Boolean
7538 //------------------------------------------------------------------------------
7539 
7540     // In the 4th column the GxB_EQ_*_* semirings could also be called
7541     // GxB_LXNOR_*_*, since the EQ and LXNOR boolean operators are identical
7542     // but those names are not included.
7543 
7544     // semirings with multiply op: z = EQ (x,y), where z is boolean and x,y are given by the suffix:
7545     GxB_LOR_EQ_INT8        , GxB_LAND_EQ_INT8       , GxB_LXOR_EQ_INT8       , GxB_EQ_EQ_INT8         , GxB_ANY_EQ_INT8        ,
7546     GxB_LOR_EQ_INT16       , GxB_LAND_EQ_INT16      , GxB_LXOR_EQ_INT16      , GxB_EQ_EQ_INT16        , GxB_ANY_EQ_INT16       ,
7547     GxB_LOR_EQ_INT32       , GxB_LAND_EQ_INT32      , GxB_LXOR_EQ_INT32      , GxB_EQ_EQ_INT32        , GxB_ANY_EQ_INT32       ,
7548     GxB_LOR_EQ_INT64       , GxB_LAND_EQ_INT64      , GxB_LXOR_EQ_INT64      , GxB_EQ_EQ_INT64        , GxB_ANY_EQ_INT64       ,
7549     GxB_LOR_EQ_UINT8       , GxB_LAND_EQ_UINT8      , GxB_LXOR_EQ_UINT8      , GxB_EQ_EQ_UINT8        , GxB_ANY_EQ_UINT8       ,
7550     GxB_LOR_EQ_UINT16      , GxB_LAND_EQ_UINT16     , GxB_LXOR_EQ_UINT16     , GxB_EQ_EQ_UINT16       , GxB_ANY_EQ_UINT16      ,
7551     GxB_LOR_EQ_UINT32      , GxB_LAND_EQ_UINT32     , GxB_LXOR_EQ_UINT32     , GxB_EQ_EQ_UINT32       , GxB_ANY_EQ_UINT32      ,
7552     GxB_LOR_EQ_UINT64      , GxB_LAND_EQ_UINT64     , GxB_LXOR_EQ_UINT64     , GxB_EQ_EQ_UINT64       , GxB_ANY_EQ_UINT64      ,
7553     GxB_LOR_EQ_FP32        , GxB_LAND_EQ_FP32       , GxB_LXOR_EQ_FP32       , GxB_EQ_EQ_FP32         , GxB_ANY_EQ_FP32        ,
7554     GxB_LOR_EQ_FP64        , GxB_LAND_EQ_FP64       , GxB_LXOR_EQ_FP64       , GxB_EQ_EQ_FP64         , GxB_ANY_EQ_FP64        ,
7555 
7556     // semirings with multiply op: z = NE (x,y), where z is boolean and x,y are given by the suffix:
7557     GxB_LOR_NE_INT8        , GxB_LAND_NE_INT8       , GxB_LXOR_NE_INT8       , GxB_EQ_NE_INT8         , GxB_ANY_NE_INT8        ,
7558     GxB_LOR_NE_INT16       , GxB_LAND_NE_INT16      , GxB_LXOR_NE_INT16      , GxB_EQ_NE_INT16        , GxB_ANY_NE_INT16       ,
7559     GxB_LOR_NE_INT32       , GxB_LAND_NE_INT32      , GxB_LXOR_NE_INT32      , GxB_EQ_NE_INT32        , GxB_ANY_NE_INT32       ,
7560     GxB_LOR_NE_INT64       , GxB_LAND_NE_INT64      , GxB_LXOR_NE_INT64      , GxB_EQ_NE_INT64        , GxB_ANY_NE_INT64       ,
7561     GxB_LOR_NE_UINT8       , GxB_LAND_NE_UINT8      , GxB_LXOR_NE_UINT8      , GxB_EQ_NE_UINT8        , GxB_ANY_NE_UINT8       ,
7562     GxB_LOR_NE_UINT16      , GxB_LAND_NE_UINT16     , GxB_LXOR_NE_UINT16     , GxB_EQ_NE_UINT16       , GxB_ANY_NE_UINT16      ,
7563     GxB_LOR_NE_UINT32      , GxB_LAND_NE_UINT32     , GxB_LXOR_NE_UINT32     , GxB_EQ_NE_UINT32       , GxB_ANY_NE_UINT32      ,
7564     GxB_LOR_NE_UINT64      , GxB_LAND_NE_UINT64     , GxB_LXOR_NE_UINT64     , GxB_EQ_NE_UINT64       , GxB_ANY_NE_UINT64      ,
7565     GxB_LOR_NE_FP32        , GxB_LAND_NE_FP32       , GxB_LXOR_NE_FP32       , GxB_EQ_NE_FP32         , GxB_ANY_NE_FP32        ,
7566     GxB_LOR_NE_FP64        , GxB_LAND_NE_FP64       , GxB_LXOR_NE_FP64       , GxB_EQ_NE_FP64         , GxB_ANY_NE_FP64        ,
7567 
7568     // semirings with multiply op: z = GT (x,y), where z is boolean and x,y are given by the suffix:
7569     GxB_LOR_GT_INT8        , GxB_LAND_GT_INT8       , GxB_LXOR_GT_INT8       , GxB_EQ_GT_INT8         , GxB_ANY_GT_INT8        ,
7570     GxB_LOR_GT_INT16       , GxB_LAND_GT_INT16      , GxB_LXOR_GT_INT16      , GxB_EQ_GT_INT16        , GxB_ANY_GT_INT16       ,
7571     GxB_LOR_GT_INT32       , GxB_LAND_GT_INT32      , GxB_LXOR_GT_INT32      , GxB_EQ_GT_INT32        , GxB_ANY_GT_INT32       ,
7572     GxB_LOR_GT_INT64       , GxB_LAND_GT_INT64      , GxB_LXOR_GT_INT64      , GxB_EQ_GT_INT64        , GxB_ANY_GT_INT64       ,
7573     GxB_LOR_GT_UINT8       , GxB_LAND_GT_UINT8      , GxB_LXOR_GT_UINT8      , GxB_EQ_GT_UINT8        , GxB_ANY_GT_UINT8       ,
7574     GxB_LOR_GT_UINT16      , GxB_LAND_GT_UINT16     , GxB_LXOR_GT_UINT16     , GxB_EQ_GT_UINT16       , GxB_ANY_GT_UINT16      ,
7575     GxB_LOR_GT_UINT32      , GxB_LAND_GT_UINT32     , GxB_LXOR_GT_UINT32     , GxB_EQ_GT_UINT32       , GxB_ANY_GT_UINT32      ,
7576     GxB_LOR_GT_UINT64      , GxB_LAND_GT_UINT64     , GxB_LXOR_GT_UINT64     , GxB_EQ_GT_UINT64       , GxB_ANY_GT_UINT64      ,
7577     GxB_LOR_GT_FP32        , GxB_LAND_GT_FP32       , GxB_LXOR_GT_FP32       , GxB_EQ_GT_FP32         , GxB_ANY_GT_FP32        ,
7578     GxB_LOR_GT_FP64        , GxB_LAND_GT_FP64       , GxB_LXOR_GT_FP64       , GxB_EQ_GT_FP64         , GxB_ANY_GT_FP64        ,
7579 
7580     // semirings with multiply op: z = LT (x,y), where z is boolean and x,y are given by the suffix:
7581     GxB_LOR_LT_INT8        , GxB_LAND_LT_INT8       , GxB_LXOR_LT_INT8       , GxB_EQ_LT_INT8         , GxB_ANY_LT_INT8        ,
7582     GxB_LOR_LT_INT16       , GxB_LAND_LT_INT16      , GxB_LXOR_LT_INT16      , GxB_EQ_LT_INT16        , GxB_ANY_LT_INT16       ,
7583     GxB_LOR_LT_INT32       , GxB_LAND_LT_INT32      , GxB_LXOR_LT_INT32      , GxB_EQ_LT_INT32        , GxB_ANY_LT_INT32       ,
7584     GxB_LOR_LT_INT64       , GxB_LAND_LT_INT64      , GxB_LXOR_LT_INT64      , GxB_EQ_LT_INT64        , GxB_ANY_LT_INT64       ,
7585     GxB_LOR_LT_UINT8       , GxB_LAND_LT_UINT8      , GxB_LXOR_LT_UINT8      , GxB_EQ_LT_UINT8        , GxB_ANY_LT_UINT8       ,
7586     GxB_LOR_LT_UINT16      , GxB_LAND_LT_UINT16     , GxB_LXOR_LT_UINT16     , GxB_EQ_LT_UINT16       , GxB_ANY_LT_UINT16      ,
7587     GxB_LOR_LT_UINT32      , GxB_LAND_LT_UINT32     , GxB_LXOR_LT_UINT32     , GxB_EQ_LT_UINT32       , GxB_ANY_LT_UINT32      ,
7588     GxB_LOR_LT_UINT64      , GxB_LAND_LT_UINT64     , GxB_LXOR_LT_UINT64     , GxB_EQ_LT_UINT64       , GxB_ANY_LT_UINT64      ,
7589     GxB_LOR_LT_FP32        , GxB_LAND_LT_FP32       , GxB_LXOR_LT_FP32       , GxB_EQ_LT_FP32         , GxB_ANY_LT_FP32        ,
7590     GxB_LOR_LT_FP64        , GxB_LAND_LT_FP64       , GxB_LXOR_LT_FP64       , GxB_EQ_LT_FP64         , GxB_ANY_LT_FP64        ,
7591 
7592     // semirings with multiply op: z = GE (x,y), where z is boolean and x,y are given by the suffix:
7593     GxB_LOR_GE_INT8        , GxB_LAND_GE_INT8       , GxB_LXOR_GE_INT8       , GxB_EQ_GE_INT8         , GxB_ANY_GE_INT8        ,
7594     GxB_LOR_GE_INT16       , GxB_LAND_GE_INT16      , GxB_LXOR_GE_INT16      , GxB_EQ_GE_INT16        , GxB_ANY_GE_INT16       ,
7595     GxB_LOR_GE_INT32       , GxB_LAND_GE_INT32      , GxB_LXOR_GE_INT32      , GxB_EQ_GE_INT32        , GxB_ANY_GE_INT32       ,
7596     GxB_LOR_GE_INT64       , GxB_LAND_GE_INT64      , GxB_LXOR_GE_INT64      , GxB_EQ_GE_INT64        , GxB_ANY_GE_INT64       ,
7597     GxB_LOR_GE_UINT8       , GxB_LAND_GE_UINT8      , GxB_LXOR_GE_UINT8      , GxB_EQ_GE_UINT8        , GxB_ANY_GE_UINT8       ,
7598     GxB_LOR_GE_UINT16      , GxB_LAND_GE_UINT16     , GxB_LXOR_GE_UINT16     , GxB_EQ_GE_UINT16       , GxB_ANY_GE_UINT16      ,
7599     GxB_LOR_GE_UINT32      , GxB_LAND_GE_UINT32     , GxB_LXOR_GE_UINT32     , GxB_EQ_GE_UINT32       , GxB_ANY_GE_UINT32      ,
7600     GxB_LOR_GE_UINT64      , GxB_LAND_GE_UINT64     , GxB_LXOR_GE_UINT64     , GxB_EQ_GE_UINT64       , GxB_ANY_GE_UINT64      ,
7601     GxB_LOR_GE_FP32        , GxB_LAND_GE_FP32       , GxB_LXOR_GE_FP32       , GxB_EQ_GE_FP32         , GxB_ANY_GE_FP32        ,
7602     GxB_LOR_GE_FP64        , GxB_LAND_GE_FP64       , GxB_LXOR_GE_FP64       , GxB_EQ_GE_FP64         , GxB_ANY_GE_FP64        ,
7603 
7604     // semirings with multiply op: z = LE (x,y), where z is boolean and x,y are given by the suffix:
7605     GxB_LOR_LE_INT8        , GxB_LAND_LE_INT8       , GxB_LXOR_LE_INT8       , GxB_EQ_LE_INT8         , GxB_ANY_LE_INT8        ,
7606     GxB_LOR_LE_INT16       , GxB_LAND_LE_INT16      , GxB_LXOR_LE_INT16      , GxB_EQ_LE_INT16        , GxB_ANY_LE_INT16       ,
7607     GxB_LOR_LE_INT32       , GxB_LAND_LE_INT32      , GxB_LXOR_LE_INT32      , GxB_EQ_LE_INT32        , GxB_ANY_LE_INT32       ,
7608     GxB_LOR_LE_INT64       , GxB_LAND_LE_INT64      , GxB_LXOR_LE_INT64      , GxB_EQ_LE_INT64        , GxB_ANY_LE_INT64       ,
7609     GxB_LOR_LE_UINT8       , GxB_LAND_LE_UINT8      , GxB_LXOR_LE_UINT8      , GxB_EQ_LE_UINT8        , GxB_ANY_LE_UINT8       ,
7610     GxB_LOR_LE_UINT16      , GxB_LAND_LE_UINT16     , GxB_LXOR_LE_UINT16     , GxB_EQ_LE_UINT16       , GxB_ANY_LE_UINT16      ,
7611     GxB_LOR_LE_UINT32      , GxB_LAND_LE_UINT32     , GxB_LXOR_LE_UINT32     , GxB_EQ_LE_UINT32       , GxB_ANY_LE_UINT32      ,
7612     GxB_LOR_LE_UINT64      , GxB_LAND_LE_UINT64     , GxB_LXOR_LE_UINT64     , GxB_EQ_LE_UINT64       , GxB_ANY_LE_UINT64      ,
7613     GxB_LOR_LE_FP32        , GxB_LAND_LE_FP32       , GxB_LXOR_LE_FP32       , GxB_EQ_LE_FP32         , GxB_ANY_LE_FP32        ,
7614     GxB_LOR_LE_FP64        , GxB_LAND_LE_FP64       , GxB_LXOR_LE_FP64       , GxB_EQ_LE_FP64         , GxB_ANY_LE_FP64        ,
7615 
7616 //------------------------------------------------------------------------------
7617 // 55 semirings with purely Boolean types, bool x bool -> bool
7618 //------------------------------------------------------------------------------
7619 
7620     // Note that lor_pair, land_pair, and eq_pair are all identical to any_pair.
7621     // These 3 are marked below.  GxB_EQ_*_BOOL could be called
7622     // GxB_LXNOR_*_BOOL, and GxB_*_EQ_BOOL could be called GxB_*_LXNOR_BOOL,
7623     // but those names are not included.
7624 
7625     // purely boolean semirings in the form GxB_(add monoid)_(multiply operator)_BOOL:
7626     GxB_LOR_FIRST_BOOL     , GxB_LAND_FIRST_BOOL    , GxB_LXOR_FIRST_BOOL    , GxB_EQ_FIRST_BOOL      , GxB_ANY_FIRST_BOOL     ,
7627     GxB_LOR_SECOND_BOOL    , GxB_LAND_SECOND_BOOL   , GxB_LXOR_SECOND_BOOL   , GxB_EQ_SECOND_BOOL     , GxB_ANY_SECOND_BOOL    ,
7628     GxB_LOR_PAIR_BOOL/**/  , GxB_LAND_PAIR_BOOL/**/ , GxB_LXOR_PAIR_BOOL     , GxB_EQ_PAIR_BOOL/**/   , GxB_ANY_PAIR_BOOL      ,
7629     GxB_LOR_LOR_BOOL       , GxB_LAND_LOR_BOOL      , GxB_LXOR_LOR_BOOL      , GxB_EQ_LOR_BOOL        , GxB_ANY_LOR_BOOL       ,
7630     GxB_LOR_LAND_BOOL      , GxB_LAND_LAND_BOOL     , GxB_LXOR_LAND_BOOL     , GxB_EQ_LAND_BOOL       , GxB_ANY_LAND_BOOL      ,
7631     GxB_LOR_LXOR_BOOL      , GxB_LAND_LXOR_BOOL     , GxB_LXOR_LXOR_BOOL     , GxB_EQ_LXOR_BOOL       , GxB_ANY_LXOR_BOOL      ,
7632     GxB_LOR_EQ_BOOL        , GxB_LAND_EQ_BOOL       , GxB_LXOR_EQ_BOOL       , GxB_EQ_EQ_BOOL         , GxB_ANY_EQ_BOOL        ,
7633     GxB_LOR_GT_BOOL        , GxB_LAND_GT_BOOL       , GxB_LXOR_GT_BOOL       , GxB_EQ_GT_BOOL         , GxB_ANY_GT_BOOL        ,
7634     GxB_LOR_LT_BOOL        , GxB_LAND_LT_BOOL       , GxB_LXOR_LT_BOOL       , GxB_EQ_LT_BOOL         , GxB_ANY_LT_BOOL        ,
7635     GxB_LOR_GE_BOOL        , GxB_LAND_GE_BOOL       , GxB_LXOR_GE_BOOL       , GxB_EQ_GE_BOOL         , GxB_ANY_GE_BOOL        ,
7636     GxB_LOR_LE_BOOL        , GxB_LAND_LE_BOOL       , GxB_LXOR_LE_BOOL       , GxB_EQ_LE_BOOL         , GxB_ANY_LE_BOOL        ,
7637 
7638 //------------------------------------------------------------------------------
7639 // 54 complex semirings
7640 //------------------------------------------------------------------------------
7641 
7642     // 3 monoids (plus, times, any), 2 types (FC32 and FC64), and 9
7643     // multiplicative operators.
7644 
7645     // Note that times_pair is identical to any_pair.
7646     // These 2 are marked below.
7647 
7648     GxB_PLUS_FIRST_FC32    , GxB_TIMES_FIRST_FC32   , GxB_ANY_FIRST_FC32     ,
7649     GxB_PLUS_FIRST_FC64    , GxB_TIMES_FIRST_FC64   , GxB_ANY_FIRST_FC64     ,
7650 
7651     GxB_PLUS_SECOND_FC32   , GxB_TIMES_SECOND_FC32  , GxB_ANY_SECOND_FC32    ,
7652     GxB_PLUS_SECOND_FC64   , GxB_TIMES_SECOND_FC64  , GxB_ANY_SECOND_FC64    ,
7653 
7654     GxB_PLUS_PAIR_FC32     , GxB_TIMES_PAIR_FC32/**/, GxB_ANY_PAIR_FC32      ,
7655     GxB_PLUS_PAIR_FC64     , GxB_TIMES_PAIR_FC64/**/, GxB_ANY_PAIR_FC64      ,
7656 
7657     GxB_PLUS_PLUS_FC32     , GxB_TIMES_PLUS_FC32    , GxB_ANY_PLUS_FC32      ,
7658     GxB_PLUS_PLUS_FC64     , GxB_TIMES_PLUS_FC64    , GxB_ANY_PLUS_FC64      ,
7659 
7660     GxB_PLUS_MINUS_FC32    , GxB_TIMES_MINUS_FC32   , GxB_ANY_MINUS_FC32     ,
7661     GxB_PLUS_MINUS_FC64    , GxB_TIMES_MINUS_FC64   , GxB_ANY_MINUS_FC64     ,
7662 
7663     GxB_PLUS_TIMES_FC32    , GxB_TIMES_TIMES_FC32   , GxB_ANY_TIMES_FC32     ,
7664     GxB_PLUS_TIMES_FC64    , GxB_TIMES_TIMES_FC64   , GxB_ANY_TIMES_FC64     ,
7665 
7666     GxB_PLUS_DIV_FC32      , GxB_TIMES_DIV_FC32     , GxB_ANY_DIV_FC32       ,
7667     GxB_PLUS_DIV_FC64      , GxB_TIMES_DIV_FC64     , GxB_ANY_DIV_FC64       ,
7668 
7669     GxB_PLUS_RDIV_FC32     , GxB_TIMES_RDIV_FC32    , GxB_ANY_RDIV_FC32      ,
7670     GxB_PLUS_RDIV_FC64     , GxB_TIMES_RDIV_FC64    , GxB_ANY_RDIV_FC64      ,
7671 
7672     GxB_PLUS_RMINUS_FC32   , GxB_TIMES_RMINUS_FC32  , GxB_ANY_RMINUS_FC32    ,
7673     GxB_PLUS_RMINUS_FC64   , GxB_TIMES_RMINUS_FC64  , GxB_ANY_RMINUS_FC64    ,
7674 
7675 //------------------------------------------------------------------------------
7676 // 64 bitwise semirings
7677 //------------------------------------------------------------------------------
7678 
7679     // monoids: (BOR, BAND, BXOR, BXNOR) x
7680     // mult:    (BOR, BAND, BXOR, BXNOR) x
7681     // types:   (UINT8, UINT16, UINT32, UINT64)
7682 
7683     GxB_BOR_BOR_UINT8      , GxB_BOR_BOR_UINT16     , GxB_BOR_BOR_UINT32     , GxB_BOR_BOR_UINT64     ,
7684     GxB_BOR_BAND_UINT8     , GxB_BOR_BAND_UINT16    , GxB_BOR_BAND_UINT32    , GxB_BOR_BAND_UINT64    ,
7685     GxB_BOR_BXOR_UINT8     , GxB_BOR_BXOR_UINT16    , GxB_BOR_BXOR_UINT32    , GxB_BOR_BXOR_UINT64    ,
7686     GxB_BOR_BXNOR_UINT8    , GxB_BOR_BXNOR_UINT16   , GxB_BOR_BXNOR_UINT32   , GxB_BOR_BXNOR_UINT64   ,
7687 
7688     GxB_BAND_BOR_UINT8     , GxB_BAND_BOR_UINT16    , GxB_BAND_BOR_UINT32    , GxB_BAND_BOR_UINT64    ,
7689     GxB_BAND_BAND_UINT8    , GxB_BAND_BAND_UINT16   , GxB_BAND_BAND_UINT32   , GxB_BAND_BAND_UINT64   ,
7690     GxB_BAND_BXOR_UINT8    , GxB_BAND_BXOR_UINT16   , GxB_BAND_BXOR_UINT32   , GxB_BAND_BXOR_UINT64   ,
7691     GxB_BAND_BXNOR_UINT8   , GxB_BAND_BXNOR_UINT16  , GxB_BAND_BXNOR_UINT32  , GxB_BAND_BXNOR_UINT64  ,
7692 
7693     GxB_BXOR_BOR_UINT8     , GxB_BXOR_BOR_UINT16    , GxB_BXOR_BOR_UINT32    , GxB_BXOR_BOR_UINT64    ,
7694     GxB_BXOR_BAND_UINT8    , GxB_BXOR_BAND_UINT16   , GxB_BXOR_BAND_UINT32   , GxB_BXOR_BAND_UINT64   ,
7695     GxB_BXOR_BXOR_UINT8    , GxB_BXOR_BXOR_UINT16   , GxB_BXOR_BXOR_UINT32   , GxB_BXOR_BXOR_UINT64   ,
7696     GxB_BXOR_BXNOR_UINT8   , GxB_BXOR_BXNOR_UINT16  , GxB_BXOR_BXNOR_UINT32  , GxB_BXOR_BXNOR_UINT64  ,
7697 
7698     GxB_BXNOR_BOR_UINT8    , GxB_BXNOR_BOR_UINT16   , GxB_BXNOR_BOR_UINT32   , GxB_BXNOR_BOR_UINT64   ,
7699     GxB_BXNOR_BAND_UINT8   , GxB_BXNOR_BAND_UINT16  , GxB_BXNOR_BAND_UINT32  , GxB_BXNOR_BAND_UINT64  ,
7700     GxB_BXNOR_BXOR_UINT8   , GxB_BXNOR_BXOR_UINT16  , GxB_BXNOR_BXOR_UINT32  , GxB_BXNOR_BXOR_UINT64  ,
7701     GxB_BXNOR_BXNOR_UINT8  , GxB_BXNOR_BXNOR_UINT16 , GxB_BXNOR_BXNOR_UINT32 , GxB_BXNOR_BXNOR_UINT64 ,
7702 
7703 //------------------------------------------------------------------------------
7704 // 80 positional semirings
7705 //------------------------------------------------------------------------------
7706 
7707     // monoids: (MIN, MAX, ANY, PLUS, TIMES) x
7708     // mult:    (FIRSTI, FIRSTI1, FIRSTJ, FIRSTJ1, SECONDI, SECONDI1, SECONDJ, SECONDJ1)
7709     // types:   (INT32, INT64)
7710 
7711     GxB_MIN_FIRSTI_INT32,     GxB_MIN_FIRSTI_INT64,
7712     GxB_MAX_FIRSTI_INT32,     GxB_MAX_FIRSTI_INT64,
7713     GxB_ANY_FIRSTI_INT32,     GxB_ANY_FIRSTI_INT64,
7714     GxB_PLUS_FIRSTI_INT32,    GxB_PLUS_FIRSTI_INT64,
7715     GxB_TIMES_FIRSTI_INT32,   GxB_TIMES_FIRSTI_INT64,
7716 
7717     GxB_MIN_FIRSTI1_INT32,    GxB_MIN_FIRSTI1_INT64,
7718     GxB_MAX_FIRSTI1_INT32,    GxB_MAX_FIRSTI1_INT64,
7719     GxB_ANY_FIRSTI1_INT32,    GxB_ANY_FIRSTI1_INT64,
7720     GxB_PLUS_FIRSTI1_INT32,   GxB_PLUS_FIRSTI1_INT64,
7721     GxB_TIMES_FIRSTI1_INT32,  GxB_TIMES_FIRSTI1_INT64,
7722 
7723     GxB_MIN_FIRSTJ_INT32,     GxB_MIN_FIRSTJ_INT64,
7724     GxB_MAX_FIRSTJ_INT32,     GxB_MAX_FIRSTJ_INT64,
7725     GxB_ANY_FIRSTJ_INT32,     GxB_ANY_FIRSTJ_INT64,
7726     GxB_PLUS_FIRSTJ_INT32,    GxB_PLUS_FIRSTJ_INT64,
7727     GxB_TIMES_FIRSTJ_INT32,   GxB_TIMES_FIRSTJ_INT64,
7728 
7729     GxB_MIN_FIRSTJ1_INT32,    GxB_MIN_FIRSTJ1_INT64,
7730     GxB_MAX_FIRSTJ1_INT32,    GxB_MAX_FIRSTJ1_INT64,
7731     GxB_ANY_FIRSTJ1_INT32,    GxB_ANY_FIRSTJ1_INT64,
7732     GxB_PLUS_FIRSTJ1_INT32,   GxB_PLUS_FIRSTJ1_INT64,
7733     GxB_TIMES_FIRSTJ1_INT32,  GxB_TIMES_FIRSTJ1_INT64,
7734 
7735     GxB_MIN_SECONDI_INT32,    GxB_MIN_SECONDI_INT64,
7736     GxB_MAX_SECONDI_INT32,    GxB_MAX_SECONDI_INT64,
7737     GxB_ANY_SECONDI_INT32,    GxB_ANY_SECONDI_INT64,
7738     GxB_PLUS_SECONDI_INT32,   GxB_PLUS_SECONDI_INT64,
7739     GxB_TIMES_SECONDI_INT32,  GxB_TIMES_SECONDI_INT64,
7740 
7741     GxB_MIN_SECONDI1_INT32,   GxB_MIN_SECONDI1_INT64,
7742     GxB_MAX_SECONDI1_INT32,   GxB_MAX_SECONDI1_INT64,
7743     GxB_ANY_SECONDI1_INT32,   GxB_ANY_SECONDI1_INT64,
7744     GxB_PLUS_SECONDI1_INT32,  GxB_PLUS_SECONDI1_INT64,
7745     GxB_TIMES_SECONDI1_INT32, GxB_TIMES_SECONDI1_INT64,
7746 
7747     GxB_MIN_SECONDJ_INT32,    GxB_MIN_SECONDJ_INT64,
7748     GxB_MAX_SECONDJ_INT32,    GxB_MAX_SECONDJ_INT64,
7749     GxB_ANY_SECONDJ_INT32,    GxB_ANY_SECONDJ_INT64,
7750     GxB_PLUS_SECONDJ_INT32,   GxB_PLUS_SECONDJ_INT64,
7751     GxB_TIMES_SECONDJ_INT32,  GxB_TIMES_SECONDJ_INT64,
7752 
7753     GxB_MIN_SECONDJ1_INT32,   GxB_MIN_SECONDJ1_INT64,
7754     GxB_MAX_SECONDJ1_INT32,   GxB_MAX_SECONDJ1_INT64,
7755     GxB_ANY_SECONDJ1_INT32,   GxB_ANY_SECONDJ1_INT64,
7756     GxB_PLUS_SECONDJ1_INT32,  GxB_PLUS_SECONDJ1_INT64,
7757     GxB_TIMES_SECONDJ1_INT32, GxB_TIMES_SECONDJ1_INT64 ;
7758 
7759 //------------------------------------------------------------------------------
7760 // GrB_* semirings
7761 //------------------------------------------------------------------------------
7762 
7763 // The v1.3 C API for GraphBLAS adds the following 124 predefined semirings,
7764 // with GrB_* names.  They are identical to 124 GxB_* semirings defined above,
7765 // with the same name, except that GrB_LXNOR_LOR_SEMIRING_BOOL is identical to
7766 // GxB_EQ_LOR_BOOL (since GrB_EQ_BOOL == GrB_LXNOR).  The old names are listed
7767 // below alongside each new name; the new GrB_* names are preferred.
7768 
7769 // 12 kinds of GrB_* semirings are available for all 10 real non-boolean types:
7770 
7771     // PLUS_TIMES, PLUS_MIN,
7772     // MIN_PLUS, MIN_TIMES, MIN_FIRST, MIN_SECOND, MIN_MAX,
7773     // MAX_PLUS, MAX_TIMES, MAX_FIRST, MAX_SECOND, MAX_MIN
7774 
7775 // and 4 semirings for boolean only:
7776 
7777     // LOR_LAND, LAND_LOR, LXOR_LAND, LXNOR_LOR.
7778 
7779 // GxB_* semirings corresponding to the equivalent GrB_* semiring are
7780 // historical.
7781 
7782 GB_PUBLIC GrB_Semiring
7783 
7784     //--------------------------------------------------------------------------
7785     // 20 semirings with PLUS monoids
7786     //--------------------------------------------------------------------------
7787 
7788     // PLUS_TIMES semirings for all 10 real, non-boolean types:
7789     GrB_PLUS_TIMES_SEMIRING_INT8,       // GxB_PLUS_TIMES_INT8
7790     GrB_PLUS_TIMES_SEMIRING_INT16,      // GxB_PLUS_TIMES_INT16
7791     GrB_PLUS_TIMES_SEMIRING_INT32,      // GxB_PLUS_TIMES_INT32
7792     GrB_PLUS_TIMES_SEMIRING_INT64,      // GxB_PLUS_TIMES_INT64
7793     GrB_PLUS_TIMES_SEMIRING_UINT8,      // GxB_PLUS_TIMES_UINT8
7794     GrB_PLUS_TIMES_SEMIRING_UINT16,     // GxB_PLUS_TIMES_UINT16
7795     GrB_PLUS_TIMES_SEMIRING_UINT32,     // GxB_PLUS_TIMES_UINT32
7796     GrB_PLUS_TIMES_SEMIRING_UINT64,     // GxB_PLUS_TIMES_UINT64
7797     GrB_PLUS_TIMES_SEMIRING_FP32,       // GxB_PLUS_TIMES_FP32
7798     GrB_PLUS_TIMES_SEMIRING_FP64,       // GxB_PLUS_TIMES_FP64
7799 
7800     // PLUS_MIN semirings for all 10 real, non-boolean types:
7801     GrB_PLUS_MIN_SEMIRING_INT8,         // GxB_PLUS_MIN_INT8
7802     GrB_PLUS_MIN_SEMIRING_INT16,        // GxB_PLUS_MIN_INT16
7803     GrB_PLUS_MIN_SEMIRING_INT32,        // GxB_PLUS_MIN_INT32
7804     GrB_PLUS_MIN_SEMIRING_INT64,        // GxB_PLUS_MIN_INT64
7805     GrB_PLUS_MIN_SEMIRING_UINT8,        // GxB_PLUS_MIN_UINT8
7806     GrB_PLUS_MIN_SEMIRING_UINT16,       // GxB_PLUS_MIN_UINT16
7807     GrB_PLUS_MIN_SEMIRING_UINT32,       // GxB_PLUS_MIN_UINT32
7808     GrB_PLUS_MIN_SEMIRING_UINT64,       // GxB_PLUS_MIN_UINT64
7809     GrB_PLUS_MIN_SEMIRING_FP32,         // GxB_PLUS_MIN_FP32
7810     GrB_PLUS_MIN_SEMIRING_FP64,         // GxB_PLUS_MIN_FP64
7811 
7812     //--------------------------------------------------------------------------
7813     // 50 semirings with MIN monoids
7814     //--------------------------------------------------------------------------
7815 
7816     // MIN_PLUS semirings for all 10 real, non-boolean types:
7817     GrB_MIN_PLUS_SEMIRING_INT8,         // GxB_MIN_PLUS_INT8
7818     GrB_MIN_PLUS_SEMIRING_INT16,        // GxB_MIN_PLUS_INT16
7819     GrB_MIN_PLUS_SEMIRING_INT32,        // GxB_MIN_PLUS_INT32
7820     GrB_MIN_PLUS_SEMIRING_INT64,        // GxB_MIN_PLUS_INT64
7821     GrB_MIN_PLUS_SEMIRING_UINT8,        // GxB_MIN_PLUS_UINT8
7822     GrB_MIN_PLUS_SEMIRING_UINT16,       // GxB_MIN_PLUS_UINT16
7823     GrB_MIN_PLUS_SEMIRING_UINT32,       // GxB_MIN_PLUS_UINT32
7824     GrB_MIN_PLUS_SEMIRING_UINT64,       // GxB_MIN_PLUS_UINT64
7825     GrB_MIN_PLUS_SEMIRING_FP32,         // GxB_MIN_PLUS_FP32
7826     GrB_MIN_PLUS_SEMIRING_FP64,         // GxB_MIN_PLUS_FP64
7827 
7828     // MIN_TIMES semirings for all 10 real, non-boolean types:
7829     GrB_MIN_TIMES_SEMIRING_INT8,        // GxB_MIN_TIMES_INT8
7830     GrB_MIN_TIMES_SEMIRING_INT16,       // GxB_MIN_TIMES_INT16
7831     GrB_MIN_TIMES_SEMIRING_INT32,       // GxB_MIN_TIMES_INT32
7832     GrB_MIN_TIMES_SEMIRING_INT64,       // GxB_MIN_TIMES_INT64
7833     GrB_MIN_TIMES_SEMIRING_UINT8,       // GxB_MIN_TIMES_UINT8
7834     GrB_MIN_TIMES_SEMIRING_UINT16,      // GxB_MIN_TIMES_UINT16
7835     GrB_MIN_TIMES_SEMIRING_UINT32,      // GxB_MIN_TIMES_UINT32
7836     GrB_MIN_TIMES_SEMIRING_UINT64,      // GxB_MIN_TIMES_UINT64
7837     GrB_MIN_TIMES_SEMIRING_FP32,        // GxB_MIN_TIMES_FP32
7838     GrB_MIN_TIMES_SEMIRING_FP64,        // GxB_MIN_TIMES_FP64
7839 
7840     // MIN_FIRST semirings for all 10 real, non-boolean types:
7841     GrB_MIN_FIRST_SEMIRING_INT8,        // GxB_MIN_FIRST_INT8
7842     GrB_MIN_FIRST_SEMIRING_INT16,       // GxB_MIN_FIRST_INT16
7843     GrB_MIN_FIRST_SEMIRING_INT32,       // GxB_MIN_FIRST_INT32
7844     GrB_MIN_FIRST_SEMIRING_INT64,       // GxB_MIN_FIRST_INT64
7845     GrB_MIN_FIRST_SEMIRING_UINT8,       // GxB_MIN_FIRST_UINT8
7846     GrB_MIN_FIRST_SEMIRING_UINT16,      // GxB_MIN_FIRST_UINT16
7847     GrB_MIN_FIRST_SEMIRING_UINT32,      // GxB_MIN_FIRST_UINT32
7848     GrB_MIN_FIRST_SEMIRING_UINT64,      // GxB_MIN_FIRST_UINT64
7849     GrB_MIN_FIRST_SEMIRING_FP32,        // GxB_MIN_FIRST_FP32
7850     GrB_MIN_FIRST_SEMIRING_FP64,        // GxB_MIN_FIRST_FP64
7851 
7852     // MIN_SECOND semirings for all 10 real, non-boolean types:
7853     GrB_MIN_SECOND_SEMIRING_INT8,       // GxB_MIN_SECOND_INT8
7854     GrB_MIN_SECOND_SEMIRING_INT16,      // GxB_MIN_SECOND_INT16
7855     GrB_MIN_SECOND_SEMIRING_INT32,      // GxB_MIN_SECOND_INT32
7856     GrB_MIN_SECOND_SEMIRING_INT64,      // GxB_MIN_SECOND_INT64
7857     GrB_MIN_SECOND_SEMIRING_UINT8,      // GxB_MIN_SECOND_UINT8
7858     GrB_MIN_SECOND_SEMIRING_UINT16,     // GxB_MIN_SECOND_UINT16
7859     GrB_MIN_SECOND_SEMIRING_UINT32,     // GxB_MIN_SECOND_UINT32
7860     GrB_MIN_SECOND_SEMIRING_UINT64,     // GxB_MIN_SECOND_UINT64
7861     GrB_MIN_SECOND_SEMIRING_FP32,       // GxB_MIN_SECOND_FP32
7862     GrB_MIN_SECOND_SEMIRING_FP64,       // GxB_MIN_SECOND_FP64
7863 
7864     // MIN_MAX semirings for all 10 real, non-boolean types:
7865     GrB_MIN_MAX_SEMIRING_INT8,          // GxB_MIN_MAX_INT8
7866     GrB_MIN_MAX_SEMIRING_INT16,         // GxB_MIN_MAX_INT16
7867     GrB_MIN_MAX_SEMIRING_INT32,         // GxB_MIN_MAX_INT32
7868     GrB_MIN_MAX_SEMIRING_INT64,         // GxB_MIN_MAX_INT64
7869     GrB_MIN_MAX_SEMIRING_UINT8,         // GxB_MIN_MAX_UINT8
7870     GrB_MIN_MAX_SEMIRING_UINT16,        // GxB_MIN_MAX_UINT16
7871     GrB_MIN_MAX_SEMIRING_UINT32,        // GxB_MIN_MAX_UINT32
7872     GrB_MIN_MAX_SEMIRING_UINT64,        // GxB_MIN_MAX_UINT64
7873     GrB_MIN_MAX_SEMIRING_FP32,          // GxB_MIN_MAX_FP32
7874     GrB_MIN_MAX_SEMIRING_FP64,          // GxB_MIN_MAX_FP64
7875 
7876     //--------------------------------------------------------------------------
7877     // 50 semirings with MAX monoids
7878     //--------------------------------------------------------------------------
7879 
7880     // MAX_PLUS semirings for all 10 real, non-boolean types
7881     GrB_MAX_PLUS_SEMIRING_INT8,         // GxB_MAX_PLUS_INT8
7882     GrB_MAX_PLUS_SEMIRING_INT16,        // GxB_MAX_PLUS_INT16
7883     GrB_MAX_PLUS_SEMIRING_INT32,        // GxB_MAX_PLUS_INT32
7884     GrB_MAX_PLUS_SEMIRING_INT64,        // GxB_MAX_PLUS_INT64
7885     GrB_MAX_PLUS_SEMIRING_UINT8,        // GxB_MAX_PLUS_UINT8
7886     GrB_MAX_PLUS_SEMIRING_UINT16,       // GxB_MAX_PLUS_UINT16
7887     GrB_MAX_PLUS_SEMIRING_UINT32,       // GxB_MAX_PLUS_UINT32
7888     GrB_MAX_PLUS_SEMIRING_UINT64,       // GxB_MAX_PLUS_UINT64
7889     GrB_MAX_PLUS_SEMIRING_FP32,         // GxB_MAX_PLUS_FP32
7890     GrB_MAX_PLUS_SEMIRING_FP64,         // GxB_MAX_PLUS_FP64
7891 
7892     // MAX_TIMES semirings for all 10 real, non-boolean types:
7893     GrB_MAX_TIMES_SEMIRING_INT8,        // GxB_MAX_TIMES_INT8
7894     GrB_MAX_TIMES_SEMIRING_INT16,       // GxB_MAX_TIMES_INT16
7895     GrB_MAX_TIMES_SEMIRING_INT32,       // GxB_MAX_TIMES_INT32
7896     GrB_MAX_TIMES_SEMIRING_INT64,       // GxB_MAX_TIMES_INT64
7897     GrB_MAX_TIMES_SEMIRING_UINT8,       // GxB_MAX_TIMES_UINT8
7898     GrB_MAX_TIMES_SEMIRING_UINT16,      // GxB_MAX_TIMES_UINT16
7899     GrB_MAX_TIMES_SEMIRING_UINT32,      // GxB_MAX_TIMES_UINT32
7900     GrB_MAX_TIMES_SEMIRING_UINT64,      // GxB_MAX_TIMES_UINT64
7901     GrB_MAX_TIMES_SEMIRING_FP32,        // GxB_MAX_TIMES_FP32
7902     GrB_MAX_TIMES_SEMIRING_FP64,        // GxB_MAX_TIMES_FP64
7903 
7904     // MAX_FIRST semirings for all 10 real, non-boolean types:
7905     GrB_MAX_FIRST_SEMIRING_INT8,        // GxB_MAX_FIRST_INT8
7906     GrB_MAX_FIRST_SEMIRING_INT16,       // GxB_MAX_FIRST_INT16
7907     GrB_MAX_FIRST_SEMIRING_INT32,       // GxB_MAX_FIRST_INT32
7908     GrB_MAX_FIRST_SEMIRING_INT64,       // GxB_MAX_FIRST_INT64
7909     GrB_MAX_FIRST_SEMIRING_UINT8,       // GxB_MAX_FIRST_UINT8
7910     GrB_MAX_FIRST_SEMIRING_UINT16,      // GxB_MAX_FIRST_UINT16
7911     GrB_MAX_FIRST_SEMIRING_UINT32,      // GxB_MAX_FIRST_UINT32
7912     GrB_MAX_FIRST_SEMIRING_UINT64,      // GxB_MAX_FIRST_UINT64
7913     GrB_MAX_FIRST_SEMIRING_FP32,        // GxB_MAX_FIRST_FP32
7914     GrB_MAX_FIRST_SEMIRING_FP64,        // GxB_MAX_FIRST_FP64
7915 
7916     // MAX_SECOND semirings for all 10 real, non-boolean types:
7917     GrB_MAX_SECOND_SEMIRING_INT8,       // GxB_MAX_SECOND_INT8
7918     GrB_MAX_SECOND_SEMIRING_INT16,      // GxB_MAX_SECOND_INT16
7919     GrB_MAX_SECOND_SEMIRING_INT32,      // GxB_MAX_SECOND_INT32
7920     GrB_MAX_SECOND_SEMIRING_INT64,      // GxB_MAX_SECOND_INT64
7921     GrB_MAX_SECOND_SEMIRING_UINT8,      // GxB_MAX_SECOND_UINT8
7922     GrB_MAX_SECOND_SEMIRING_UINT16,     // GxB_MAX_SECOND_UINT16
7923     GrB_MAX_SECOND_SEMIRING_UINT32,     // GxB_MAX_SECOND_UINT32
7924     GrB_MAX_SECOND_SEMIRING_UINT64,     // GxB_MAX_SECOND_UINT64
7925     GrB_MAX_SECOND_SEMIRING_FP32,       // GxB_MAX_SECOND_FP32
7926     GrB_MAX_SECOND_SEMIRING_FP64,       // GxB_MAX_SECOND_FP64
7927 
7928     // MAX_MIN semirings for all 10 real, non-boolean types:
7929     GrB_MAX_MIN_SEMIRING_INT8,          // GxB_MAX_MIN_INT8
7930     GrB_MAX_MIN_SEMIRING_INT16,         // GxB_MAX_MIN_INT16
7931     GrB_MAX_MIN_SEMIRING_INT32,         // GxB_MAX_MIN_INT32
7932     GrB_MAX_MIN_SEMIRING_INT64,         // GxB_MAX_MIN_INT64
7933     GrB_MAX_MIN_SEMIRING_UINT8,         // GxB_MAX_MIN_UINT8
7934     GrB_MAX_MIN_SEMIRING_UINT16,        // GxB_MAX_MIN_UINT16
7935     GrB_MAX_MIN_SEMIRING_UINT32,        // GxB_MAX_MIN_UINT32
7936     GrB_MAX_MIN_SEMIRING_UINT64,        // GxB_MAX_MIN_UINT64
7937     GrB_MAX_MIN_SEMIRING_FP32,          // GxB_MAX_MIN_FP32
7938     GrB_MAX_MIN_SEMIRING_FP64,          // GxB_MAX_MIN_FP64
7939 
7940     //--------------------------------------------------------------------------
7941     // 4 boolean semirings:
7942     //--------------------------------------------------------------------------
7943 
7944     GrB_LOR_LAND_SEMIRING_BOOL,         // GxB_LOR_LAND_BOOL
7945     GrB_LAND_LOR_SEMIRING_BOOL,         // GxB_LAND_LOR_BOOL
7946     GrB_LXOR_LAND_SEMIRING_BOOL,        // GxB_LXOR_LAND_BOOL
7947     GrB_LXNOR_LOR_SEMIRING_BOOL ;       // GxB_EQ_LOR_BOOL (note EQ == LXNOR)
7948 
7949 //==============================================================================
7950 // GrB_*_resize:  change the size of a matrix or vector
7951 //==============================================================================
7952 
7953 // If the dimensions decrease, entries that fall outside the resized matrix or
7954 // vector are deleted.
7955 
7956 GB_PUBLIC
7957 GrB_Info GrB_Matrix_resize      // change the size of a matrix
7958 (
7959     GrB_Matrix C,               // matrix to modify
7960     GrB_Index nrows_new,        // new number of rows in matrix
7961     GrB_Index ncols_new         // new number of columns in matrix
7962 ) ;
7963 
7964 GB_PUBLIC
7965 GrB_Info GrB_Vector_resize      // change the size of a vector
7966 (
7967     GrB_Vector w,               // vector to modify
7968     GrB_Index nrows_new         // new number of rows in vector
7969 ) ;
7970 
7971 // GxB_*_resize are identical to the GrB_*resize methods above
7972 GB_PUBLIC
7973 GrB_Info GxB_Matrix_resize      // change the size of a matrix (historical)
7974 (
7975     GrB_Matrix C,               // matrix to modify
7976     GrB_Index nrows_new,        // new number of rows in matrix
7977     GrB_Index ncols_new         // new number of columns in matrix
7978 ) ;
7979 
7980 GB_PUBLIC
7981 GrB_Info GxB_Vector_resize      // change the size of a vector (historical)
7982 (
7983     GrB_Vector w,               // vector to modify
7984     GrB_Index nrows_new         // new number of rows in vector
7985 ) ;
7986 
7987 // GxB_resize is a generic function for resizing a matrix or vector:
7988 
7989 // GrB_Vector_resize (u,nrows_new)
7990 // GrB_Matrix_resize (A,nrows_new,ncols_new)
7991 
7992 #if GxB_STDC_VERSION >= 201112L
7993 #define GxB_resize(arg1,...)                                \
7994     _Generic                                                \
7995     (                                                       \
7996         (arg1),                                             \
7997               GrB_Vector : GrB_Vector_resize ,              \
7998               GrB_Matrix : GrB_Matrix_resize                \
7999     )                                                       \
8000     (arg1, __VA_ARGS__)
8001 #endif
8002 
8003 //==============================================================================
8004 // GxB_fprint and GxB_print: print the contents of a GraphBLAS object
8005 //==============================================================================
8006 
8007 // GxB_fprint (object, GxB_Print_Level pr, FILE *f) prints the contents of any
8008 // of the 9 GraphBLAS objects to the file f, and also does an extensive test on
8009 // the object to determine if it is valid.  It returns one of the following
8010 // error conditions:
8011 //
8012 //      GrB_SUCCESS               object is valid
8013 //      GrB_UNINITIALIZED_OBJECT  object is not initialized
8014 //      GrB_INVALID_OBJECT        object is not valid
8015 //      GrB_NULL_POINTER          object is a NULL pointer
8016 //      GrB_INVALID_VALUE         fprintf returned an I/O error; see the ANSI C
8017 //                                errno or GrB_error( )for details.
8018 //
8019 // GxB_fprint does not modify the status of any object.  If a matrix or vector
8020 // has not been completed, the pending computations are guaranteed to *not* be
8021 // performed by GxB_fprint.  The reason is simple.  It is possible for a bug in
8022 // the user application (such as accessing memory outside the bounds of an
8023 // array) to mangle the internal content of a GraphBLAS object, and GxB_fprint
8024 // can be a helpful tool to track down this bug.  If GxB_fprint attempted to
8025 // complete any computations prior to printing or checking the contents of the
8026 // matrix or vector, then further errors could occur, including a segfault.
8027 //
8028 // The type-specific functions include an additional argument, the name string.
8029 // The name is printed at the beginning of the display (assuming pr is not
8030 // GxB_SILENT) so that the object can be more easily identified in the output.
8031 // For the type-generic methods GxB_fprint and GxB_print, the name string is
8032 // the variable name of the object itself.
8033 //
8034 // If f is NULL, nothing is printed (pr is effectively GxB_SILENT); this is not
8035 // an error condition.  If pr is outside the bounds 0 to 3, negative values are
8036 // treated as GxB_SILENT, and values > 3 are treated as GxB_COMPLETE.  If name
8037 // is NULL, it is treated as the empty string.
8038 //
8039 // GxB_print (object, GxB_Print_Level pr) is the same as GxB_fprint, except
8040 // that it prints the contents with printf instead of fprintf to a file f.
8041 //
8042 // The exact content and format of what is printed is implementation-dependent,
8043 // and will change from version to version of SuiteSparse:GraphBLAS.  Do not
8044 // attempt to rely on the exact content or format by trying to parse the
8045 // resulting output via another program.  The intent of these functions is to
8046 // produce a report of the object for visual inspection.
8047 
8048 typedef enum
8049 {
8050     GxB_SILENT = 0,     // nothing is printed, just check the object
8051     GxB_SUMMARY = 1,    // print a terse summary
8052     GxB_SHORT = 2,      // short description, about 30 entries of a matrix
8053     GxB_COMPLETE = 3,   // print the entire contents of the object
8054     GxB_SHORT_VERBOSE = 4,    // GxB_SHORT but with "%.15g" for doubles
8055     GxB_COMPLETE_VERBOSE = 5  // GxB_COMPLETE but with "%.15g" for doubles
8056 }
8057 GxB_Print_Level ;
8058 
8059 GB_PUBLIC
8060 GrB_Info GxB_Type_fprint            // print and check a GrB_Type
8061 (
8062     GrB_Type type,                  // object to print and check
8063     const char *name,               // name of the object
8064     GxB_Print_Level pr,             // print level
8065     FILE *f                         // file for output
8066 ) ;
8067 
8068 GB_PUBLIC
8069 GrB_Info GxB_UnaryOp_fprint         // print and check a GrB_UnaryOp
8070 (
8071     GrB_UnaryOp unaryop,            // object to print and check
8072     const char *name,               // name of the object
8073     GxB_Print_Level pr,             // print level
8074     FILE *f                         // file for output
8075 ) ;
8076 
8077 GB_PUBLIC
8078 GrB_Info GxB_BinaryOp_fprint        // print and check a GrB_BinaryOp
8079 (
8080     GrB_BinaryOp binaryop,          // object to print and check
8081     const char *name,               // name of the object
8082     GxB_Print_Level pr,             // print level
8083     FILE *f                         // file for output
8084 ) ;
8085 
8086 GB_PUBLIC
8087 GrB_Info GxB_SelectOp_fprint        // print and check a GxB_SelectOp
8088 (
8089     GxB_SelectOp selectop,          // object to print and check
8090     const char *name,               // name of the object
8091     GxB_Print_Level pr,             // print level
8092     FILE *f                         // file for output
8093 ) ;
8094 
8095 GB_PUBLIC
8096 GrB_Info GxB_Monoid_fprint          // print and check a GrB_Monoid
8097 (
8098     GrB_Monoid monoid,              // object to print and check
8099     const char *name,               // name of the object
8100     GxB_Print_Level pr,             // print level
8101     FILE *f                         // file for output
8102 ) ;
8103 
8104 GB_PUBLIC
8105 GrB_Info GxB_Semiring_fprint        // print and check a GrB_Semiring
8106 (
8107     GrB_Semiring semiring,          // object to print and check
8108     const char *name,               // name of the object
8109     GxB_Print_Level pr,             // print level
8110     FILE *f                         // file for output
8111 ) ;
8112 
8113 GB_PUBLIC
8114 GrB_Info GxB_Descriptor_fprint      // print and check a GrB_Descriptor
8115 (
8116     GrB_Descriptor descriptor,      // object to print and check
8117     const char *name,               // name of the object
8118     GxB_Print_Level pr,             // print level
8119     FILE *f                         // file for output
8120 ) ;
8121 
8122 GB_PUBLIC
8123 GrB_Info GxB_Matrix_fprint          // print and check a GrB_Matrix
8124 (
8125     GrB_Matrix A,                   // object to print and check
8126     const char *name,               // name of the object
8127     GxB_Print_Level pr,             // print level
8128     FILE *f                         // file for output
8129 ) ;
8130 
8131 GB_PUBLIC
8132 GrB_Info GxB_Vector_fprint          // print and check a GrB_Vector
8133 (
8134     GrB_Vector v,                   // object to print and check
8135     const char *name,               // name of the object
8136     GxB_Print_Level pr,             // print level
8137     FILE *f                         // file for output
8138 ) ;
8139 
8140 GB_PUBLIC
8141 GrB_Info GxB_Scalar_fprint          // print and check a GxB_Scalar
8142 (
8143     GxB_Scalar s,                   // object to print and check
8144     const char *name,               // name of the object
8145     GxB_Print_Level pr,             // print level
8146     FILE *f                         // file for output
8147 ) ;
8148 
8149 #if GxB_STDC_VERSION >= 201112L
8150 #define GxB_fprint(object,pr,f)                         \
8151     _Generic                                            \
8152     (                                                   \
8153         (object),                                       \
8154         const GrB_Type       : GxB_Type_fprint       ,  \
8155               GrB_Type       : GxB_Type_fprint       ,  \
8156         const GrB_UnaryOp    : GxB_UnaryOp_fprint    ,  \
8157               GrB_UnaryOp    : GxB_UnaryOp_fprint    ,  \
8158         const GrB_BinaryOp   : GxB_BinaryOp_fprint   ,  \
8159               GrB_BinaryOp   : GxB_BinaryOp_fprint   ,  \
8160         const GxB_SelectOp   : GxB_SelectOp_fprint   ,  \
8161               GxB_SelectOp   : GxB_SelectOp_fprint   ,  \
8162         const GrB_Monoid     : GxB_Monoid_fprint     ,  \
8163               GrB_Monoid     : GxB_Monoid_fprint     ,  \
8164         const GrB_Semiring   : GxB_Semiring_fprint   ,  \
8165               GrB_Semiring   : GxB_Semiring_fprint   ,  \
8166         const GxB_Scalar     : GxB_Scalar_fprint     ,  \
8167               GxB_Scalar     : GxB_Scalar_fprint     ,  \
8168         const GrB_Vector     : GxB_Vector_fprint     ,  \
8169               GrB_Vector     : GxB_Vector_fprint     ,  \
8170         const GrB_Matrix     : GxB_Matrix_fprint     ,  \
8171               GrB_Matrix     : GxB_Matrix_fprint     ,  \
8172         const GrB_Descriptor : GxB_Descriptor_fprint ,  \
8173               GrB_Descriptor : GxB_Descriptor_fprint    \
8174     )                                                   \
8175     (object, GB_STR(object), pr, f)
8176 #endif
8177 
8178 #if GxB_STDC_VERSION >= 201112L
8179 #define GxB_print(object,pr) GxB_fprint(object,pr,NULL)
8180 #endif
8181 
8182 //==============================================================================
8183 // GxB_import* and GxB_export*: Matrix and vector import/export
8184 //==============================================================================
8185 
8186 // The import/export functions allow the user application to create a
8187 // GrB_Matrix or GrB_Vector object, and to extract its contents, faster and
8188 // with less memory overhead than the GrB_*_build and GrB_*_extractTuples
8189 // functions.
8190 
8191 // The semantics of import/export are the same as the "move constructor" in
8192 // C++.  On import, the user provides a set of arrays that have been previously
8193 // allocated via the ANSI C malloc function.  The arrays define the content of
8194 // the matrix or vector.  Unlike GrB_*_build, the GraphBLAS library then takes
8195 // ownership of the user's input arrays and may either (a) incorporate them
8196 // into its internal data structure for the new GrB_Matrix or GrB_Vector,
8197 // potentially creating the GrB_Matrix or GrB_Vector in constant time with no
8198 // memory copying performed, or (b) if the library does not support the import
8199 // format directly, then it may convert the input to its internal format, and
8200 // then free the user's input arrays.  GraphBLAS may also choose to use a mix
8201 // of the two strategies.  In either case, the input arrays are no longer
8202 // "owned" by the user application.  If A is a GrB_Matrix created by an import,
8203 // the user input arrays are freed no later than GrB_free (&A), and may be
8204 // freed earlier, at the discretion of the GraphBLAS library.  The data
8205 // structure of the GrB_Matrix and GrB_Vector remain opaque.
8206 
8207 // The export of a GrB_Matrix or GrB_Vector is symmetric with the import
8208 // operation.  It is a destructive export, where the GrB_Matrix or GrB_Vector
8209 // no longer exists when the export completes, and instead the user is returned
8210 // several arrays that contain the matrix or vector in the requested format.
8211 // Ownership of these arrays is given to the user application, which is then
8212 // responsible for freeing them via the ANSI C free function.  If the output
8213 // format is supported by the GraphBLAS library, then these arrays may be
8214 // returned to the user application in O(1) time and with no memory copying
8215 // performed.  Otherwise, the GraphBLAS library will create the output arrays
8216 // for the user (via the ANSI C malloc function), fill them with the GrB_Matrix
8217 // or GrB_Vector data, and then return the newly allocated arrays to the user.
8218 
8219 // Eight different formats are provided for import/export.  For each format,
8220 // the Ax array has a C-type <type> corresponding to one of the 13 built-in
8221 // types in GraphBLAS (bool, int*_t, uint*_t, float, double, float complex, or
8222 // double complex), or a user-defined type.
8223 
8224 // On import, the required user arrays Ah, Ap, Ab, Ai, Aj, and/or Ax must be
8225 // non-NULL pointers to memory space allocated by the ANSI C malloc (or calloc,
8226 // or realloc), unless nzmax is zero (in which case the Ab, Ai, Aj, Ax, vb, vi,
8227 // and vx arrays may all be NULL).  Just like GrB_*_new, the GrB_Matrix A (or
8228 // GrB_Vector v) is undefined on input.  If the import is successful, the
8229 // GrB_Matrix A or GrB_Vector v is created, and the pointers to the user input
8230 // arrays have been set to NULL.  These user arrays have either been
8231 // incorporated directly into the GrB_Matrix A or GrB_Vector v, in which case
8232 // the user input arrays will eventually be freed by GrB_free (&A), or their
8233 // contents have been copied and the arrays freed.  This decision is made by
8234 // the GraphBLAS library itself, and the user application has no control over
8235 // this decision.
8236 
8237 // If any of the arrays Ab, Aj, Ai, Ax, vb, vi, or vx have zero size (with
8238 // nzmax of zero), they are allowed to be be NULL pointers on input.
8239 
8240 // No error checking is performed on the content of the user input arrays.  If
8241 // the user input arrays do not conform to the precise specifications above,
8242 // results are undefined.  No typecasting of the values of the matrix or vector
8243 // entries is performed on import or export.
8244 
8245 // SuiteSparse:GraphBLAS supports all eight formats natively (CSR, CSC,
8246 // HyperCSR, and HyperCSC, BitmapR, BitmapC, FullR, FullC).  For vectors, only
8247 // CSC, BitmapC, and FullC formats are used.  On import, the all eight formats
8248 // take O(1) time and memory to import.  On export, if the GrB_Matrix or
8249 // GrB_Vector is already in this particular format, then the export takes O(1)
8250 // time and no memory copying is performed.
8251 
8252 // If the import is not successful, the GxB_Matrix_import_* functions return A
8253 // as NULL, GxB_Vector_import returns v as NULL, and the user input arrays are
8254 // neither modified nor freed.  They are still owned by the user application.
8255 
8256 //------------------------------------------------------------------------------
8257 // GxB_Matrix_import_CSR: import a CSR matrix
8258 //------------------------------------------------------------------------------
8259 
8260 GB_PUBLIC
8261 GrB_Info GxB_Matrix_import_CSR      // import a CSR matrix
8262 (
8263     GrB_Matrix *A,      // handle of matrix to create
8264     GrB_Type type,      // type of matrix to create
8265     GrB_Index nrows,    // number of rows of the matrix
8266     GrB_Index ncols,    // number of columns of the matrix
8267     GrB_Index **Ap,     // row "pointers", Ap_size >= (nrows+1)* sizeof(int64_t)
8268     GrB_Index **Aj,     // column indices, Aj_size >= nvals(A) * sizeof(int64_t)
8269     void **Ax,          // values, Ax_size >= nvals(A) * (type size)
8270     GrB_Index Ap_size,  // size of Ap in bytes
8271     GrB_Index Aj_size,  // size of Aj in bytes
8272     GrB_Index Ax_size,  // size of Ax in bytes
8273     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8274     bool jumbled,       // if true, indices in each row may be unsorted
8275     const GrB_Descriptor desc
8276 ) ;
8277 
8278     // CSR:  an nrows-by-ncols matrix with nvals entries in CSR format consists
8279     // of 3 arrays, where nvals = Ap [nrows]:
8280     //
8281     //          GrB_Index Ap [nrows+1], Aj [nvals] ; <type> Ax [nvals] ;
8282     //
8283     //      The column indices of entries in the ith row of the matrix are held
8284     //      in Aj [Ap [i] ... Ap[i+1]], and the corresponding values are held
8285     //      in the same positions in Ax.  Column indices must be in the range 0
8286     //      to ncols-1.  If jumbled is false, the column indices must appear in
8287     //      sorted order within each row.  No duplicate column indices may
8288     //      appear in any row.  Ap [0] must equal zero, and Ap [nrows] must
8289     //      equal nvals.  The Ap array must be of size nrows+1 (or larger), and
8290     //      the Aj and Ax arrays must have size at least nvals.  If nvals is
8291     //      zero, then the Aj and Ax arrays need not be present and can be
8292     //      NULL.
8293 
8294 //------------------------------------------------------------------------------
8295 // GxB_Matrix_import_CSC: import a CSC matrix
8296 //------------------------------------------------------------------------------
8297 
8298 GB_PUBLIC
8299 GrB_Info GxB_Matrix_import_CSC      // import a CSC matrix
8300 (
8301     GrB_Matrix *A,      // handle of matrix to create
8302     GrB_Type type,      // type of matrix to create
8303     GrB_Index nrows,    // number of rows of the matrix
8304     GrB_Index ncols,    // number of columns of the matrix
8305     GrB_Index **Ap,     // col "pointers", Ap_size >= (ncols+1)*sizeof(int64_t)
8306     GrB_Index **Ai,     // row indices, Ai_size >= nvals(A)*sizeof(int64_t)
8307     void **Ax,          // values, Ax_size >= nvals(A) * (type size)
8308     GrB_Index Ap_size,  // size of Ap in bytes
8309     GrB_Index Ai_size,  // size of Ai in bytes
8310     GrB_Index Ax_size,  // size of Ax in bytes
8311     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8312     bool jumbled,       // if true, indices in each column may be unsorted
8313     const GrB_Descriptor desc
8314 ) ;
8315 
8316     // CSC:  an nrows-by-ncols matrix with nvals entries in CSC format consists
8317     // of 3 arrays, where nvals = Ap [ncols]:
8318     //
8319     //          GrB_Index Ap [ncols+1], Ai [nvals] ; <type> Ax [nvals] ;
8320     //
8321     //      The row indices of entries in the jth column of the matrix are held
8322     //      in Ai [Ap [j] ... Ap[j+1]], and the corresponding values are held
8323     //      in the same positions in Ax.  Row indices must be in the range 0 to
8324     //      nrows-1.  If jumbled is false, the row indices must appear in
8325     //      sorted order within each column.  No duplicate row indices may
8326     //      appear in any column.  Ap [0] must equal zero, and Ap [ncols] must
8327     //      equal nvals.  The Ap array must be of size ncols+1 (or larger), and
8328     //      the Ai and Ax arrays must have size at least nvals.  If nvals is
8329     //      zero, then the Ai and Ax arrays need not be present and can be
8330     //      NULL.
8331 
8332 //------------------------------------------------------------------------------
8333 // GxB_Matrix_import_HyperCSR: import a hypersparse CSR matrix
8334 //------------------------------------------------------------------------------
8335 
8336 GB_PUBLIC
8337 GrB_Info GxB_Matrix_import_HyperCSR      // import a hypersparse CSR matrix
8338 (
8339     GrB_Matrix *A,      // handle of matrix to create
8340     GrB_Type type,      // type of matrix to create
8341     GrB_Index nrows,    // number of rows of the matrix
8342     GrB_Index ncols,    // number of columns of the matrix
8343     GrB_Index **Ap,     // row "pointers", Ap_size >= (nvec+1)*sizeof(int64_t)
8344     GrB_Index **Ah,     // row indices, Ah_size >= nvec*sizeof(int64_t)
8345     GrB_Index **Aj,     // column indices, Aj_size >= nvals(A)*sizeof(int64_t)
8346     void **Ax,          // values, Ax_size >= nvals(A) * (type size)
8347     GrB_Index Ap_size,  // size of Ap in bytes
8348     GrB_Index Ah_size,  // size of Ah in bytes
8349     GrB_Index Aj_size,  // size of Aj in bytes
8350     GrB_Index Ax_size,  // size of Ax in bytes
8351     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8352     GrB_Index nvec,     // number of rows that appear in Ah
8353     bool jumbled,       // if true, indices in each row may be unsorted
8354     const GrB_Descriptor desc
8355 ) ;
8356 
8357     // HyperCSR: an nrows-by-ncols matrix with nvals entries and nvec
8358     // rows that may have entries in HyperCSR format consists of 4 arrays,
8359     // where nvals = Ap [nvec]:
8360     //
8361     //          GrB_Index Ah [nvec], Ap [nvec+1], Aj [nvals] ;
8362     //          <type> Ax [nvals] ;
8363     //
8364     //      The Aj and Ax arrays are the same for a matrix in CSR or HyperCSR
8365     //      format.  Only Ap and Ah differ.
8366     //
8367     //      The Ah array is a list of the row indices of rows that appear in
8368     //      the matrix.  It
8369     //      must appear in sorted order, and no duplicates may appear.  If i =
8370     //      Ah [k] is the kth row, then the column indices of the ith
8371     //      row appear in Aj [Ap [k] ... Ap [k+1]], and the corresponding
8372     //      values appear in the same locations in Ax.  Column indices must be
8373     //      in the range 0 to ncols-1, and must appear in sorted order within
8374     //      each row.  No duplicate column indices may appear in any row.  nvec
8375     //      may be zero, to denote an array with no entries.  The Ah array must
8376     //      be of size at least nvec, Ap must be of size at least nvec+1, and
8377     //      Aj and Ax must be at least of size nvals.  If nvals is zero, then
8378     //      the Aj and Ax arrays need not be present and can be NULL.
8379 
8380 //------------------------------------------------------------------------------
8381 // GxB_Matrix_import_HyperCSC: import a hypersparse CSC matrix
8382 //------------------------------------------------------------------------------
8383 
8384 GB_PUBLIC
8385 GrB_Info GxB_Matrix_import_HyperCSC      // import a hypersparse CSC matrix
8386 (
8387     GrB_Matrix *A,      // handle of matrix to create
8388     GrB_Type type,      // type of matrix to create
8389     GrB_Index nrows,    // number of rows of the matrix
8390     GrB_Index ncols,    // number of columns of the matrix
8391     GrB_Index **Ap,     // col "pointers", Ap_size >= (nvec+1)*sizeof(int64_t)
8392     GrB_Index **Ah,     // column indices, Ah_size >= nvec*sizeof(int64_t)
8393     GrB_Index **Ai,     // row indices, Ai_size >= nvals(A)*sizeof(int64_t)
8394     void **Ax,          // values, Ax_size >= nvals(A)*(type size)
8395     GrB_Index Ap_size,  // size of Ap in bytes
8396     GrB_Index Ah_size,  // size of Ah in bytes
8397     GrB_Index Ai_size,  // size of Ai in bytes
8398     GrB_Index Ax_size,  // size of Ax in bytes
8399     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8400     GrB_Index nvec,     // number of columns that appear in Ah
8401     bool jumbled,       // if true, indices in each column may be unsorted
8402     const GrB_Descriptor desc
8403 ) ;
8404 
8405     // HyperCSC: an nrows-by-ncols matrix with nvals entries and nvec
8406     // columns that may have entries in HyperCSC format consists of 4 arrays,
8407     // where nvals = Ap [nvec]:
8408     //
8409     //
8410     //          GrB_Index Ah [nvec], Ap [nvec+1], Ai [nvals] ;
8411     //          <type> Ax [nvals] ;
8412     //
8413     //      The Ai and Ax arrays are the same for a matrix in CSC or HyperCSC
8414     //      format.  Only Ap and Ah differ.
8415     //
8416     //      The Ah array is a list of the column indices of non-empty columns.
8417     //      It must appear in sorted order, and no duplicates may appear.  If j
8418     //      = Ah [k] is the kth non-empty column, then the row indices of the
8419     //      jth column appear in Ai [Ap [k] ... Ap [k+1]], and the
8420     //      corresponding values appear in the same locations in Ax.  Row
8421     //      indices must be in the range 0 to nrows-1, and must appear in
8422     //      sorted order within each column.  No duplicate row indices may
8423     //      appear in any column.  nvec may be zero, to denote an array with no
8424     //      entries.  The Ah array must be of size at least nvec, Ap must be of
8425     //      size at least nvec+1, and Ai and Ax must be at least of size nvals.
8426     //      If nvals is zero, then the Ai and Ax arrays need not be present and
8427     //      can be NULL.
8428 
8429 //------------------------------------------------------------------------------
8430 // GxB_Matrix_import_BitmapR: import a bitmap matrix, held by row
8431 //------------------------------------------------------------------------------
8432 
8433 GB_PUBLIC
8434 GrB_Info GxB_Matrix_import_BitmapR  // import a bitmap matrix, held by row
8435 (
8436     GrB_Matrix *A,      // handle of matrix to create
8437     GrB_Type type,      // type of matrix to create
8438     GrB_Index nrows,    // number of rows of the matrix
8439     GrB_Index ncols,    // number of columns of the matrix
8440     int8_t **Ab,        // bitmap, Ab_size >= nrows*ncols
8441     void **Ax,          // values, Ax_size >= nrows*ncols * (type size)
8442     GrB_Index Ab_size,  // size of Ab in bytes
8443     GrB_Index Ax_size,  // size of Ax in bytes
8444     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8445     GrB_Index nvals,    // # of entries in bitmap
8446     const GrB_Descriptor desc
8447 ) ;
8448 
8449     // BitmapR: a dense format, but able to represent sparsity structure of A.
8450     //
8451     //          int8_t Ab [nrows*ncols] ;
8452     //          <type> Ax [nrows*ncols] ;
8453     //
8454     //      Ab and Ax are both of size nrows*ncols.  Ab [i*ncols+j] = 1 if the
8455     //      A(i,j) entry is present with value Ax [i*ncols+j], or 0 if A(i,j)
8456     //      is not present.  nvals must equal the number of 1's in the Ab
8457     //      array.
8458 
8459 //------------------------------------------------------------------------------
8460 // GxB_Matrix_import_BitmapC: import a bitmap matrix, held by column
8461 //------------------------------------------------------------------------------
8462 
8463 GB_PUBLIC
8464 GrB_Info GxB_Matrix_import_BitmapC  // import a bitmap matrix, held by column
8465 (
8466     GrB_Matrix *A,      // handle of matrix to create
8467     GrB_Type type,      // type of matrix to create
8468     GrB_Index nrows,    // number of rows of the matrix
8469     GrB_Index ncols,    // number of columns of the matrix
8470     int8_t **Ab,        // bitmap, Ab_size >= nrows*ncols
8471     void **Ax,          // values, Ax_size >= nrows*ncols * (type size)
8472     GrB_Index Ab_size,  // size of Ab in bytes
8473     GrB_Index Ax_size,  // size of Ax in bytes
8474     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8475     GrB_Index nvals,    // # of entries in bitmap
8476     const GrB_Descriptor desc
8477 ) ;
8478 
8479     // BitmapC: a dense format, but able to represent sparsity structure of A.
8480     //
8481     //          int8_t Ab [nrows*ncols] ;
8482     //          <type> Ax [nrows*ncols] ;
8483     //
8484     //      Ab and Ax are both of size nrows*ncols.  Ab [i+j*nrows] = 1 if the
8485     //      A(i,j) entry is present with value Ax [i+j*nrows], or 0 if A(i,j)
8486     //      is not present.  nvals must equal the number of 1's in the Ab
8487     //      array.
8488 
8489 //------------------------------------------------------------------------------
8490 // GxB_Matrix_import_FullR:  import a full matrix, held by row
8491 //------------------------------------------------------------------------------
8492 
8493 GB_PUBLIC
8494 GrB_Info GxB_Matrix_import_FullR  // import a full matrix, held by row
8495 (
8496     GrB_Matrix *A,      // handle of matrix to create
8497     GrB_Type type,      // type of matrix to create
8498     GrB_Index nrows,    // number of rows of the matrix
8499     GrB_Index ncols,    // number of columns of the matrix
8500     void **Ax,          // values, Ax_size >= nrows*ncols * (type size)
8501     GrB_Index Ax_size,  // size of Ax in bytes
8502     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8503     const GrB_Descriptor desc
8504 ) ;
8505 
8506     // FullR: an nrows-by-ncols full matrix held in row-major order:
8507     //
8508     //  <type> Ax [nrows*ncols] ;
8509     //
8510     //      Ax is an array of size nrows*ncols, where A(i,j) is held in
8511     //      Ax [i*ncols+j].  All entries in A are present.
8512 
8513 //------------------------------------------------------------------------------
8514 // GxB_Matrix_import_FullC: import a full matrix, held by column
8515 //------------------------------------------------------------------------------
8516 
8517 GB_PUBLIC
8518 GrB_Info GxB_Matrix_import_FullC  // import a full matrix, held by column
8519 (
8520     GrB_Matrix *A,      // handle of matrix to create
8521     GrB_Type type,      // type of matrix to create
8522     GrB_Index nrows,    // number of rows of the matrix
8523     GrB_Index ncols,    // number of columns of the matrix
8524     void **Ax,          // values, Ax_size >= nrows*ncols * (type size)
8525     GrB_Index Ax_size,  // size of Ax in bytes
8526     bool is_uniform,    // if true, A has uniform values (TODO:::unsupported)
8527     const GrB_Descriptor desc
8528 ) ;
8529 
8530     // FullC: an nrows-by-ncols full matrix held in column-major order:
8531     //
8532     //  <type> Ax [nrows*ncols] ;
8533     //
8534     //      Ax is an array of size nrows*ncols, where A(i,j) is held in
8535     //      Ax [i+j*nrows].  All entries in A are present.
8536 
8537 //------------------------------------------------------------------------------
8538 // GxB_Vector_import_CSC: import a vector in CSC format
8539 //------------------------------------------------------------------------------
8540 
8541 GB_PUBLIC
8542 GrB_Info GxB_Vector_import_CSC  // import a vector in CSC format
8543 (
8544     GrB_Vector *v,      // handle of vector to create
8545     GrB_Type type,      // type of vector to create
8546     GrB_Index n,        // vector length
8547     GrB_Index **vi,     // indices, vi_size >= nvals(v) * sizeof(int64_t)
8548     void **vx,          // values, vx_size >= nvals(v) * (type size)
8549     GrB_Index vi_size,  // size of vi in bytes
8550     GrB_Index vx_size,  // size of vx in bytes
8551     bool is_uniform,    // if true, v has uniform values (TODO:::unsupported)
8552     GrB_Index nvals,    // # of entries in vector
8553     bool jumbled,       // if true, indices may be unsorted
8554     const GrB_Descriptor desc
8555 ) ;
8556 
8557     // The GrB_Vector is treated as if it was a single column of an n-by-1
8558     // matrix in CSC format, except that no vp array is required.  If nvals is
8559     // zero, then the vi and vx arrays need not be present and can be NULL.
8560 
8561 //------------------------------------------------------------------------------
8562 // GxB_Vector_import_Bitmap: import a vector in bitmap format
8563 //------------------------------------------------------------------------------
8564 
8565 GB_PUBLIC
8566 GrB_Info GxB_Vector_import_Bitmap // import a bitmap vector
8567 (
8568     GrB_Vector *v,      // handle of vector to create
8569     GrB_Type type,      // type of vector to create
8570     GrB_Index n,        // vector length
8571     int8_t **vb,        // bitmap, vb_size >= n
8572     void **vx,          // values, vx_size >= n * (type size)
8573     GrB_Index vb_size,  // size of vb in bytes
8574     GrB_Index vx_size,  // size of vx in bytes
8575     bool is_uniform,    // if true, v has uniform values (TODO:::unsupported)
8576     GrB_Index nvals,    // # of entries in bitmap
8577     const GrB_Descriptor desc
8578 ) ;
8579 
8580     // The GrB_Vector is treated as if it was a single column of an n-by-1
8581     // matrix in BitmapC format.
8582 
8583 //------------------------------------------------------------------------------
8584 // GxB_Vector_import_Full: import a vector in full format
8585 //------------------------------------------------------------------------------
8586 
8587 GB_PUBLIC
8588 GrB_Info GxB_Vector_import_Full // import a full vector
8589 (
8590     GrB_Vector *v,      // handle of vector to create
8591     GrB_Type type,      // type of vector to create
8592     GrB_Index n,        // vector length
8593     void **vx,          // values, vx_size >= nvals(v) * (type size)
8594     GrB_Index vx_size,  // size of vx in bytes
8595     bool is_uniform,    // if true, v has uniform values (TODO:::unsupported)
8596     const GrB_Descriptor desc
8597 ) ;
8598 
8599     // The GrB_Vector is treated as if it was a single column of an n-by-1
8600     // matrix in FullC format.
8601 
8602 //------------------------------------------------------------------------------
8603 
8604 // The GxB_*_export functions are symmetric with the GxB_*_import functions.
8605 // GxB_*export* functions force completion of any pending operations, prior to
8606 // the export, except if the only pending operation is to unjumble the matrix.
8607 //
8608 // If there are no entries in the matrix or vector, then the index arrays
8609 // (Ai, Aj, or vi) and value arrays (Ax or vx) are returned as NULL.  This is
8610 // not an error condition.
8611 //
8612 // GxB_Matrix_export:
8613 //
8614 //      A GrB_Matrix may be exported in any one of four different formats.  On
8615 //      successful export, the input GrB_Matrix A is freed, and the output
8616 //      arrays Ah, Ap, Ai, Aj, and/or Ax are returned to the user application
8617 //      as arrays allocated by the ANSI C malloc function.  The four formats
8618 //      are the same as the import formats for GrB_Matrix_import_*.
8619 //
8620 //      If jumbled is NULL on input, this indicates to GxB_*export* that the
8621 //      exported matrix cannot be returned in a jumbled format.  In this case,
8622 //      if the matrix is jumbled, it is sorted before exporting it to the
8623 //      caller.
8624 
8625 GB_PUBLIC
8626 GrB_Info GxB_Matrix_export_CSR  // export and free a CSR matrix
8627 (
8628     GrB_Matrix *A,      // handle of matrix to export and free
8629     GrB_Type *type,     // type of matrix exported
8630     GrB_Index *nrows,   // number of rows of the matrix
8631     GrB_Index *ncols,   // number of columns of the matrix
8632     GrB_Index **Ap,     // row "pointers"
8633     GrB_Index **Aj,     // column indices
8634     void **Ax,          // values
8635     GrB_Index *Ap_size, // size of Ap in bytes
8636     GrB_Index *Aj_size, // size of Aj in bytes
8637     GrB_Index *Ax_size, // size of Ax in bytes
8638     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8639     bool *jumbled,      // if true, indices in each row may be unsorted
8640     const GrB_Descriptor desc
8641 ) ;
8642 
8643 GB_PUBLIC
8644 GrB_Info GxB_Matrix_export_CSC  // export and free a CSC matrix
8645 (
8646     GrB_Matrix *A,      // handle of matrix to export and free
8647     GrB_Type *type,     // type of matrix exported
8648     GrB_Index *nrows,   // number of rows of the matrix
8649     GrB_Index *ncols,   // number of columns of the matrix
8650     GrB_Index **Ap,     // column "pointers"
8651     GrB_Index **Ai,     // row indices
8652     void **Ax,          // values
8653     GrB_Index *Ap_size, // size of Ap in bytes
8654     GrB_Index *Ai_size, // size of Ai in bytes
8655     GrB_Index *Ax_size, // size of Ax in bytes
8656     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8657     bool *jumbled,      // if true, indices in each column may be unsorted
8658     const GrB_Descriptor desc
8659 ) ;
8660 
8661 GB_PUBLIC
8662 GrB_Info GxB_Matrix_export_HyperCSR  // export and free a hypersparse CSR matrix
8663 (
8664     GrB_Matrix *A,      // handle of matrix to export and free
8665     GrB_Type *type,     // type of matrix exported
8666     GrB_Index *nrows,   // number of rows of the matrix
8667     GrB_Index *ncols,   // number of columns of the matrix
8668     GrB_Index **Ap,     // row "pointers"
8669     GrB_Index **Ah,     // row indices
8670     GrB_Index **Aj,     // column indices
8671     void **Ax,          // values
8672     GrB_Index *Ap_size, // size of Ap in bytes
8673     GrB_Index *Ah_size, // size of Ah in bytes
8674     GrB_Index *Aj_size, // size of Aj in bytes
8675     GrB_Index *Ax_size, // size of Ax in bytes
8676     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8677     GrB_Index *nvec,    // number of rows that appear in Ah
8678     bool *jumbled,      // if true, indices in each row may be unsorted
8679     const GrB_Descriptor desc
8680 ) ;
8681 
8682 GB_PUBLIC
8683 GrB_Info GxB_Matrix_export_HyperCSC  // export and free a hypersparse CSC matrix
8684 (
8685     GrB_Matrix *A,      // handle of matrix to export and free
8686     GrB_Type *type,     // type of matrix exported
8687     GrB_Index *nrows,   // number of rows of the matrix
8688     GrB_Index *ncols,   // number of columns of the matrix
8689     GrB_Index **Ap,     // column "pointers"
8690     GrB_Index **Ah,     // column indices
8691     GrB_Index **Ai,     // row indices
8692     void **Ax,          // values
8693     GrB_Index *Ap_size, // size of Ap in bytes
8694     GrB_Index *Ah_size, // size of Ah in bytes
8695     GrB_Index *Ai_size, // size of Ai in bytes
8696     GrB_Index *Ax_size, // size of Ax in bytes
8697     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8698     GrB_Index *nvec,    // number of columns that appear in Ah
8699     bool *jumbled,      // if true, indices in each column may be unsorted
8700     const GrB_Descriptor desc
8701 ) ;
8702 
8703 GB_PUBLIC
8704 GrB_Info GxB_Matrix_export_BitmapR  // export and free a bitmap matrix, by row
8705 (
8706     GrB_Matrix *A,      // handle of matrix to export and free
8707     GrB_Type *type,     // type of matrix exported
8708     GrB_Index *nrows,   // number of rows of the matrix
8709     GrB_Index *ncols,   // number of columns of the matrix
8710     int8_t **Ab,        // bitmap
8711     void **Ax,          // values
8712     GrB_Index *Ab_size, // size of Ab in bytes
8713     GrB_Index *Ax_size, // size of Ax in bytes
8714     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8715     GrB_Index *nvals,   // # of entries in bitmap
8716     const GrB_Descriptor desc
8717 ) ;
8718 
8719 GB_PUBLIC
8720 GrB_Info GxB_Matrix_export_BitmapC  // export and free a bitmap matrix, by col
8721 (
8722     GrB_Matrix *A,      // handle of matrix to export and free
8723     GrB_Type *type,     // type of matrix exported
8724     GrB_Index *nrows,   // number of rows of the matrix
8725     GrB_Index *ncols,   // number of columns of the matrix
8726     int8_t **Ab,        // bitmap
8727     void **Ax,          // values
8728     GrB_Index *Ab_size, // size of Ab in bytes
8729     GrB_Index *Ax_size, // size of Ax in bytes
8730     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8731     GrB_Index *nvals,   // # of entries in bitmap
8732     const GrB_Descriptor desc
8733 ) ;
8734 
8735 GB_PUBLIC
8736 GrB_Info GxB_Matrix_export_FullR  // export and free a full matrix, by row
8737 (
8738     GrB_Matrix *A,      // handle of matrix to export and free
8739     GrB_Type *type,     // type of matrix exported
8740     GrB_Index *nrows,   // number of rows of the matrix
8741     GrB_Index *ncols,   // number of columns of the matrix
8742     void **Ax,          // values
8743     GrB_Index *Ax_size, // size of Ax in bytes
8744     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8745     const GrB_Descriptor desc
8746 ) ;
8747 
8748 GB_PUBLIC
8749 GrB_Info GxB_Matrix_export_FullC  // export and free a full matrix, by column
8750 (
8751     GrB_Matrix *A,      // handle of matrix to export and free
8752     GrB_Type *type,     // type of matrix exported
8753     GrB_Index *nrows,   // number of rows of the matrix
8754     GrB_Index *ncols,   // number of columns of the matrix
8755     void **Ax,          // values
8756     GrB_Index *Ax_size, // size of Ax in bytes
8757     bool *is_uniform,   // if true, A has uniform values (TODO:::unsupported)
8758     const GrB_Descriptor desc
8759 ) ;
8760 
8761     // For GxB_Matrix_export_Full*, all entries in A must be present.  That is,
8762     // GrB_Matrix_nvals must report nvals equal to nrows*ncols.  If this
8763     // condition does not hold, the matrix is not exported, and
8764     // GrB_INVALID_VALUE is returned.
8765 
8766 GB_PUBLIC
8767 GrB_Info GxB_Vector_export_CSC  // export and free a CSC vector
8768 (
8769     GrB_Vector *v,      // handle of vector to export and free
8770     GrB_Type *type,     // type of vector exported
8771     GrB_Index *n,       // length of the vector
8772     GrB_Index **vi,     // indices
8773     void **vx,          // values
8774     GrB_Index *vi_size, // size of vi in bytes
8775     GrB_Index *vx_size, // size of vx in bytes
8776     bool *is_uniform,   // if true, v has uniform values (TODO:::unsupported)
8777     GrB_Index *nvals,   // # of entries in vector
8778     bool *jumbled,      // if true, indices may be unsorted
8779     const GrB_Descriptor desc
8780 ) ;
8781 
8782 GB_PUBLIC
8783 GrB_Info GxB_Vector_export_Bitmap   // export and free a bitmap vector
8784 (
8785     GrB_Vector *v,      // handle of vector to export and free
8786     GrB_Type *type,     // type of vector exported
8787     GrB_Index *n,       // length of the vector
8788     int8_t **vb,        // bitmap
8789     void **vx,          // values
8790     GrB_Index *vb_size, // size of vb in bytes
8791     GrB_Index *vx_size, // size of vx in bytes
8792     bool *is_uniform,   // if true, v has uniform values (TODO:::unsupported)
8793     GrB_Index *nvals,    // # of entries in bitmap
8794     const GrB_Descriptor desc
8795 ) ;
8796 
8797 GB_PUBLIC
8798 GrB_Info GxB_Vector_export_Full   // export and free a full vector
8799 (
8800     GrB_Vector *v,      // handle of vector to export and free
8801     GrB_Type *type,     // type of vector exported
8802     GrB_Index *n,       // length of the vector
8803     void **vx,          // values
8804     GrB_Index *vx_size, // size of vx in bytes
8805     bool *is_uniform,   // if true, v has uniform values (TODO:::unsupported)
8806     const GrB_Descriptor desc
8807 ) ;
8808 
8809 // If the export is not successful, the GxB_Matrix_export_* functions do not
8810 // modify A, the GxB_Vector_export does not modify v, and the user arrays are
8811 // returned as NULL.
8812 
8813 //==============================================================================
8814 // CUDA memory management (DRAFT: in progress, do not use)
8815 //==============================================================================
8816 
8817 // These functions are made available to the user application, since the
8818 // GxB_import/export functions require the user application and the GraphBLAS
8819 // library to rely on the same malloc/calloc/realloc/free functions.  If
8820 // GraphBLAS is using CUDA Unified Memory Management and GxB_cuda_init is used
8821 // to initialize GraphBLAS, then all of its memory allocations rely on these
8822 // functions.
8823 
8824 // If GraphBLAS is compiled with CUDA enabled, these functions map to
8825 // cudaMallocManaged and cudaFree.  Otherwise, they map to the ANSI C malloc,
8826 // calloc, and free functions.
8827 
8828 // Note that there is no cudaReallocManaged function, and in this case
8829 // GraphBLAS makes do without it.  As a result, the user application cannot use
8830 // realloc either, for memory blocks passed to/from GraphBLAS via
8831 // import/export.
8832 
8833 void *GxB_cuda_malloc (size_t size) ;           // standard malloc signature
8834 void *GxB_cuda_calloc (size_t n, size_t size) ; // standard calloc signature
8835 void  GxB_cuda_free (void *p) ;                 // standard free signature
8836 
8837 #endif
8838 
8839