1 //------------------------------------------------------------------------------
2 // GB_mex_errors: test error handling
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 // This mexFunction intentionally creates many errors for GraphBLAS, to test
11 // error-handling. Many error messages are printed. If the test ends with
12 // "All tests passed" then all errors were expected. The test fails if
13 // GraphBLAS does not catch the error with the right error code, or if it
14 // generates an unexpected error.
15
16 #include "GB_mex.h"
17
18 #define USAGE "GB_mex_errors"
19
20 #define FREE_ALL \
21 { \
22 GrB_Matrix_free_(&Empty1) ; CHECK (Empty1 == NULL) ; \
23 GrB_Matrix_free_(&A) ; CHECK (A == NULL) ; \
24 GrB_Matrix_free_(&B) ; CHECK (B == NULL) ; \
25 GrB_Matrix_free_(&C) ; CHECK (C == NULL) ; \
26 GrB_Matrix_free_(&Z) ; CHECK (Z == NULL) ; \
27 GrB_Matrix_free_(&E) ; CHECK (E == NULL) ; \
28 GrB_Matrix_free_(&F) ; CHECK (F == NULL) ; \
29 GrB_Matrix_free_(&H) ; CHECK (H == NULL) ; \
30 GrB_Matrix_free_(&Agunk) ; CHECK (Agunk == NULL) ; \
31 GrB_Matrix_free_(&Aempty) ; CHECK (Aempty == NULL) ; \
32 GrB_Type_free_(&T) ; CHECK (T == NULL) ; \
33 GrB_Type_free_(&Tgunk) ; CHECK (Tgunk == NULL) ; \
34 GrB_UnaryOp_free_(&op1) ; CHECK (op1 == NULL) ; \
35 GrB_UnaryOp_free_(&op1gunk) ; CHECK (op1gunk == NULL) ; \
36 GrB_BinaryOp_free_(&op2) ; CHECK (op2 == NULL) ; \
37 GrB_BinaryOp_free_(&op3) ; CHECK (op3 == NULL) ; \
38 GrB_UnaryOp_free_(&op1b) ; CHECK (op1b == NULL) ; \
39 GrB_BinaryOp_free_(&op2b) ; CHECK (op2b == NULL) ; \
40 GrB_Monoid_free_(&monoidb) ; CHECK (monoidb == NULL) ; \
41 GrB_Semiring_free_(&semiring2) ; CHECK (semiring2 == NULL) ; \
42 GrB_Descriptor_free_(&descb) ; CHECK (descb == NULL) ; \
43 GrB_Vector_free_(&vb) ; CHECK (vb == NULL) ; \
44 GrB_BinaryOp_free_(&op2gunk) ; CHECK (op2gunk == NULL) ; \
45 GrB_Monoid_free_(&monoid) ; CHECK (monoid == NULL) ; \
46 GrB_Monoid_free_(&monoid_gunk) ; CHECK (monoid_gunk == NULL) ; \
47 GrB_Semiring_free_(&semiring) ; CHECK (semiring == NULL) ; \
48 GrB_Semiring_free_(&semigunk) ; CHECK (semigunk == NULL) ; \
49 GrB_Vector_free_(&v) ; CHECK (v == NULL) ; \
50 GrB_Vector_free_(&w) ; CHECK (w == NULL) ; \
51 GrB_Vector_free_(&u) ; CHECK (u == NULL) ; \
52 GrB_Vector_free_(&z) ; CHECK (z == NULL) ; \
53 GrB_Vector_free_(&h) ; CHECK (h == NULL) ; \
54 GrB_Vector_free_(&vgunk) ; CHECK (vgunk == NULL) ; \
55 GrB_Vector_free_(&vempty) ; CHECK (vempty == NULL) ; \
56 GrB_Descriptor_free_(&desc) ; CHECK (desc == NULL) ; \
57 GrB_Descriptor_free_(&dtn) ; CHECK (dtn == NULL) ; \
58 GrB_Descriptor_free_(&dnt) ; CHECK (dnt == NULL) ; \
59 GrB_Descriptor_free_(&dtt) ; CHECK (dtt == NULL) ; \
60 GrB_Descriptor_free_(&dgunk) ; CHECK (dgunk == NULL) ; \
61 GxB_SelectOp_free_(&selectop) ; CHECK (selectop == NULL) ; \
62 GxB_SelectOp_free_(&selectopgunk) ; CHECK (selectopgunk == NULL) ; \
63 GxB_Scalar_free_(&a_scalar) ; \
64 GB_mx_put_global (true) ; \
65 }
66
67 #include "GB_mex_errors.h"
68
69 #define G3 GxB_COMPLETE
70 #define G2 GxB_SHORT
71 #define G1 GxB_SUMMARY
72 #define G0 GxB_SILENT
73
74 void f1 (double *z, const uint32_t *x) ;
75 void f2 (int32_t *z, const uint8_t *x, const int16_t *y) ;
76 bool fselect (GrB_Index i, GrB_Index j, const double *x, const double *k) ;
77
f1(double * z,const uint32_t * x)78 void f1 (double *z, const uint32_t *x)
79 {
80 (*z) = (*x) + 1 ;
81 }
82
f2(int32_t * z,const uint8_t * x,const int16_t * y)83 void f2 (int32_t *z, const uint8_t *x, const int16_t *y)
84 {
85 (*z) = (*x) + (*y) + 1 ;
86 }
87
88 void f3 (GxB_FC64_t *z, const GxB_FC64_t *x, const double *y) ;
f3(GxB_FC64_t * z,const GxB_FC64_t * x,const double * y)89 void f3 (GxB_FC64_t *z, const GxB_FC64_t *x, const double *y)
90 {
91 (*z) = GB_FC64_add ((*x), GxB_CMPLX (0,(*y))) ;
92 }
93
fselect(GrB_Index i,GrB_Index j,const double * x,const double * k)94 bool fselect (GrB_Index i, GrB_Index j, const double *x, const double *k)
95 {
96 // select entries in triu(A) that are greater than k
97 int64_t i2 = (int64_t) i ;
98 int64_t j2 = (int64_t) j ;
99 return (x > k && (j2-i2) > 0) ;
100 }
101
102
mexFunction(int nargout,mxArray * pargout[],int nargin,const mxArray * pargin[])103 void mexFunction
104 (
105 int nargout,
106 mxArray *pargout [ ],
107 int nargin,
108 const mxArray *pargin [ ]
109 )
110 {
111
112 FILE *f = fopen ("errlog.txt", "w") ;
113 FILE *ff = fopen ("fprint.txt", "w") ;
114
115 GrB_Info info, expected ;
116
117 GB_Global_GrB_init_called_set (false) ;
118 OK (GrB_init (GrB_NONBLOCKING)) ;
119 OK (GrB_finalize ( )) ;
120
121 GB_Global_GrB_init_called_set (false) ;
122 OK (GxB_init (GrB_NONBLOCKING, mxMalloc, NULL, NULL, mxFree, false)) ;
123 GB_Global_abort_function_set (GB_mx_abort) ;
124 GB_Global_malloc_tracking_set (true) ;
125
126 fprintf (f,"\n========================================================\n") ;
127 fprintf (f,"=== GB_mex_errors : testing error handling =============\n") ;
128 fprintf (f,"========================================================\n") ;
129 fprintf (f,"many errors are expected\n") ;
130
131 OK (GxB_Type_fprint_(GrB_BOOL, G3, ff)) ;
132 expected = GrB_INVALID_VALUE ;
133 ERR (GxB_Type_fprint_(GrB_BOOL, G3, stdin)) ;
134
135 int64_t nmalloc ;
136 nmalloc = GB_Global_nmalloc_get ( ) ;
137
138 printf ("nmalloc %d at start\n", nmalloc) ;
139 bool malloc_debug = GB_mx_get_global (true) ;
140 nmalloc = GB_Global_nmalloc_get ( ) ;
141 printf ("nmalloc %d after complex init\n", nmalloc) ;
142
143 GrB_Matrix A = NULL, B = NULL, C = NULL, Z = NULL, Agunk = NULL,
144 Aempty = NULL, E = NULL, F = NULL, A0 = NULL, H = NULL,
145 Empty1 = NULL, A4 = NULL, C4 = NULL ;
146 GrB_Vector v = NULL, vgunk = NULL, vempty = NULL, w = NULL, u = NULL,
147 v0 = NULL, v2 = NULL, z = NULL, h = NULL, vb = NULL ;
148 GrB_Type T = NULL, Tgunk ;
149 GrB_UnaryOp op1 = NULL, op1gunk = NULL, o1 = NULL, op1b = NULL ;
150 GrB_BinaryOp op2 = NULL, op2gunk = NULL, o2 = NULL, op0 = NULL, op3 = NULL,
151 op2b = NULL ;
152 GrB_Monoid monoid = NULL, monoid_gunk = NULL, m2 = NULL, m0 = NULL,
153 monoidb = NULL ;
154 GrB_Semiring semiring = NULL, semigunk = NULL, s2 = NULL, s0 = NULL,
155 semiring2 = NULL ;
156 GrB_Descriptor desc = NULL, dgunk = NULL, d0 = NULL,
157 dnt = NULL, dtn = NULL, dtt = NULL, descb = NULL ;
158 GrB_Desc_Value dval ;
159 GrB_Index n = 0, nvals = 0, n2 = 0, i = 0, j = 0, a, b, uvals = 0 ;
160 GrB_Index *I0 = NULL, *J0 = NULL ;
161 #define LEN 100
162 GrB_Index I [5] = { 0, 7, 8, 3, 2 }, I2 [LEN] ;
163 GrB_Index J [5] = { 4, 1, 2, 2, 1 }, J2 [LEN] ;
164 double X [5] = { 4.5, 8.2, 9.1, -1.2, 3.14159 }, X2 [LEN] ;
165 GB_Pending AP = NULL ;
166
167 size_t s ;
168 bool x_bool, ok ;
169 int8_t x_int8 ;
170 int16_t x_int16 ;
171 uint16_t x_uint16 ;
172 int32_t x_int32 ;
173 uint32_t x_uint32 ;
174 int64_t x_int64 ;
175 uint64_t x_uint64 ;
176 float x_float ;
177 double x_double, x = 0 ;
178 GxB_FC64_t c ;
179
180 GB_void *pp = NULL ;
181
182 GxB_SelectOp selectop = NULL, selectopgunk = NULL, sel0 ;
183 GxB_Scalar a_scalar = NULL ;
184
185 char *err ;
186
187 //--------------------------------------------------------------------------
188 // check inputs
189 //--------------------------------------------------------------------------
190
191 GB_CONTEXT (USAGE) ;
192 if (nargout > 0 || nargin > 0)
193 {
194 mexErrMsgTxt ("Usage: " USAGE) ;
195 }
196
197 //--------------------------------------------------------------------------
198 // initialize simple_rand
199 //--------------------------------------------------------------------------
200
201 printf ("rand seed----------------------------------------------------\n") ;
202 fprintf (f, "random seed is %g\n", (double) simple_rand_getseed ( )) ;
203 simple_rand_seed (1) ;
204 fprintf (f, "random seed is now %g\n", (double) simple_rand_getseed ( )) ;
205
206 //--------------------------------------------------------------------------
207 // init
208 //--------------------------------------------------------------------------
209
210 printf ("GrB_init-----------------------------------------------------\n") ;
211
212 // can't call it twice
213 expected = GrB_INVALID_VALUE ;
214 ERR (GxB_init (GrB_NONBLOCKING, mxMalloc, NULL, NULL, mxFree, false)) ;
215 GB_Global_GrB_init_called_set (false) ;
216
217 // invalid mode
218 expected = GrB_INVALID_VALUE ;
219 ERR (GxB_init (42, mxMalloc, NULL, NULL, mxFree, false)) ;
220 /*
221 OK (GrB_finalize ( )) ;
222 GB_Global_GrB_init_called_set (false) ;
223 OK (GrB_init (GrB_NONBLOCKING)) ;
224 */
225
226 expected = GrB_NULL_POINTER ;
227 ERR (GxB_init (42, NULL , NULL, NULL, mxFree, false)) ;
228 ERR (GxB_init (42, mxMalloc, NULL, NULL, NULL , false)) ;
229
230 //--------------------------------------------------------------------------
231 // Type
232 //--------------------------------------------------------------------------
233
234 printf ("GrB_Type-----------------------------------------------------\n") ;
235 expected = GrB_NULL_POINTER ;
236
237 ERR (GrB_Type_new (NULL, sizeof (int))) ;
238 ERR (GxB_Type_size (NULL, NULL)) ;
239 ERR (GxB_Type_size (&s, NULL)) ;
240
241 OK (GrB_Type_new (&T, sizeof (int))) ;
242 CHECK (T != NULL) ;
243
244 expected = GrB_UNINITIALIZED_OBJECT ;
245
246 Tgunk = T ;
247 T = NULL ;
248 Tgunk->magic = 42 ;
249 ERR (GxB_Type_size (&s, Tgunk)) ;
250
251 T = GrB_INT32 ;
252 OK (GrB_Type_free_(&GrB_INT32)) ;
253 CHECK (GrB_INT32 == T) ;
254 T = NULL ;
255
256 OK (GrB_Type_new (&T, sizeof (int))) ;
257 CHECK (T != NULL) ;
258
259 OK (GxB_Type_size (&s, T)) ;
260 CHECK (s == sizeof (int)) ;
261 s = 0 ;
262
263 OK (GrB_Type_free_(&T)) ;
264 CHECK (T == NULL) ;
265
266 OK (GrB_Type_free_(&T)) ;
267 CHECK (T == NULL) ;
268
269 s = GB_code_size (-1,1) ;
270 CHECK (s == 0) ;
271
272 #define FREE_DEEP_COPY ;
273 #define GET_DEEP_COPY ;
274
275 METHOD (GrB_Type_new (&T, sizeof (int))) ;
276 OK (GB_Type_check (T, "new type", G3, NULL)) ;
277 OK (GxB_Type_fprint (T, "new type", G3, ff)) ;
278 OK (GrB_Type_free_(&T)) ;
279 CHECK (T == NULL) ;
280
281 #undef FREE_DEEP_COPY
282 #undef GET_DEEP_COPY
283
284 for (GB_Type_code tcode = 0 ; tcode <= GB_UDT_code ; tcode++)
285 {
286 GrB_Type utype = Complex ;
287 GrB_Type ttype = GB_code_type (tcode, utype) ;
288 printf ("\n----------------------------------tcode: %d\n", tcode) ;
289 OK (GB_Type_check (ttype, "GB_code_type:", G3, NULL)) ;
290 OK (GxB_Type_fprint_(ttype, G3, ff)) ;
291 }
292
293 // Tgunk is allocated but uninitialized
294
295 //--------------------------------------------------------------------------
296 // UnaryOp
297 //--------------------------------------------------------------------------
298
299 printf ("GrB_UnaryOp--------------------------------------------------\n") ;
300 expected = GrB_NULL_POINTER ;
301
302 ERR (GrB_UnaryOp_new (NULL, NULL, NULL, NULL)) ;
303
304 ERR (GrB_UnaryOp_new (&op1, NULL, NULL, NULL)) ;
305 CHECK (op1 == NULL) ;
306
307 ERR (GrB_UnaryOp_new (&op1, f1, NULL, NULL)) ;
308 CHECK (op1 == NULL) ;
309
310 ERR (GrB_UnaryOp_new (&op1, f1, GrB_FP64, NULL)) ;
311 CHECK (op1 == NULL) ;
312
313 ERR (GrB_UnaryOp_new (&op1, f1, NULL, GrB_UINT32)) ;
314 CHECK (op1 == NULL) ;
315
316 ERR (GrB_UnaryOp_new (&op1, NULL, GrB_FP64, GrB_UINT32)) ;
317 CHECK (op1 == NULL) ;
318
319 expected = GrB_UNINITIALIZED_OBJECT ;
320
321 ERR (GrB_UnaryOp_new (&op1, f1, Tgunk, Tgunk)) ;
322 CHECK (op1 == NULL) ;
323
324 ERR (GrB_UnaryOp_new (&op1, f1, GrB_FP64, Tgunk)) ;
325 CHECK (op1 == NULL) ;
326
327 ERR (GrB_UnaryOp_new (&op1, f1, Tgunk, GrB_FP64)) ;
328 CHECK (op1 == NULL) ;
329
330 OK (GrB_UnaryOp_new (&op1, f1, GrB_FP64, GrB_UINT32)) ;
331 CHECK (op1 != NULL) ;
332
333 expected = GrB_NULL_POINTER ;
334 T = NULL ;
335
336 ERR (GxB_UnaryOp_ztype (NULL, op1)) ;
337 ERR (GxB_UnaryOp_xtype (NULL, op1)) ;
338
339 ERR (GxB_UnaryOp_ztype (&T, NULL)) ;
340 CHECK (T == NULL) ;
341
342 ERR (GxB_UnaryOp_xtype (&T, NULL)) ;
343 CHECK (T == NULL) ;
344
345 OK (GxB_UnaryOp_ztype (&T, op1)) ;
346 CHECK (T == GrB_FP64) ;
347
348 OK (GxB_UnaryOp_xtype (&T, op1)) ;
349 CHECK (T == GrB_UINT32) ;
350
351 expected = GrB_UNINITIALIZED_OBJECT ;
352
353 op1gunk = op1 ;
354 op1 = NULL ;
355
356 op1gunk->magic = 99 ;
357 T = NULL ;
358
359 ERR (GxB_UnaryOp_ztype (&T, op1gunk)) ;
360 CHECK (T == NULL) ;
361
362 ERR (GxB_UnaryOp_xtype (&T, op1gunk)) ;
363 CHECK (T == NULL) ;
364
365 o1 = GrB_IDENTITY_BOOL ;
366 OK (GrB_UnaryOp_free_(&o1)) ;
367 CHECK (o1 == GrB_IDENTITY_BOOL) ;
368 o1 = NULL ;
369
370 OK (GrB_UnaryOp_new (&o1, f1, GrB_FP64, GrB_UINT32)) ;
371 CHECK (o1 != NULL) ;
372
373 OK (GrB_UnaryOp_free_(&o1)) ;
374 o1 = NULL ;
375
376 OK (GrB_UnaryOp_free_(&o1)) ;
377 o1 = NULL ;
378
379 #define FREE_DEEP_COPY ;
380 #define GET_DEEP_COPY ;
381
382 GrB_UnaryOp opzz ;
383 METHOD (GrB_UnaryOp_new (&opzz, f1, GrB_FP64, GrB_UINT32)) ;
384 OK (GB_UnaryOp_check (opzz, "new unary opzz", G3, NULL)) ;
385 OK (GxB_UnaryOp_fprint (opzz, "new unary opzz", G3, ff)) ;
386 OK (GrB_UnaryOp_free_(&opzz)) ;
387 CHECK (opzz == NULL) ;
388
389 #undef FREE_DEEP_COPY
390 #undef GET_DEEP_COPY
391
392 // op1gunk is allocated but uninitialized
393
394 //--------------------------------------------------------------------------
395 // BinaryOp
396 //--------------------------------------------------------------------------
397
398 printf ("GrB_BinaryOp-------------------------------------------------\n") ;
399 expected = GrB_NULL_POINTER ;
400 ERR (GrB_BinaryOp_new (NULL, NULL, NULL, NULL, NULL)) ;
401
402 ERR (GrB_BinaryOp_new (&op2, NULL, NULL, NULL, NULL)) ;
403 CHECK (op2 == NULL) ;
404
405 // void f2 (int32_t *z, uint8_t *x, int16_t *y)
406 ERR (GrB_BinaryOp_new (&op2, f2, NULL, NULL, NULL)) ;
407 CHECK (op2 == NULL) ;
408
409 ERR (GrB_BinaryOp_new (&op2, f2, GrB_INT32, NULL, NULL)) ;
410 CHECK (op2 == NULL) ;
411
412 ERR (GrB_BinaryOp_new (&op2, f2, GrB_INT32, GrB_UINT8, NULL)) ;
413 CHECK (op2 == NULL) ;
414
415 ERR (GrB_BinaryOp_new (&op2, f2, GrB_INT32, NULL, GrB_INT16)) ;
416 CHECK (op2 == NULL) ;
417
418 expected = GrB_UNINITIALIZED_OBJECT ;
419
420 ERR (GrB_BinaryOp_new (&op2, f2, Tgunk, GrB_UINT8, GrB_INT16)) ;
421 CHECK (op2 == NULL) ;
422
423 ERR (GrB_BinaryOp_new (&op2, f2, GrB_INT32, Tgunk, GrB_INT16)) ;
424 CHECK (op2 == NULL) ;
425
426 ERR (GrB_BinaryOp_new (&op2, f2, GrB_INT32, GrB_UINT8, Tgunk)) ;
427 CHECK (op2 == NULL) ;
428
429 OK (GrB_BinaryOp_new (&op2, f2, GrB_INT32, GrB_UINT8, GrB_INT16)) ;
430 CHECK (op2 != NULL) ;
431
432 expected = GrB_NULL_POINTER ;
433
434 ERR (GxB_BinaryOp_ztype (NULL, op2)) ;
435 ERR (GxB_BinaryOp_xtype (NULL, op2)) ;
436 ERR (GxB_BinaryOp_ytype (NULL, op2)) ;
437
438 expected = GrB_UNINITIALIZED_OBJECT ;
439
440 op2gunk = op2 ;
441 op2 = NULL ;
442 op2gunk->magic = 77 ;
443 T = NULL ;
444
445 ERR (GxB_BinaryOp_ztype (&T, op2gunk)) ;
446 CHECK (T == NULL) ;
447
448 ERR (GxB_BinaryOp_xtype (&T, op2gunk)) ;
449 CHECK (T == NULL) ;
450
451 ERR (GxB_BinaryOp_ytype (&T, op2gunk)) ;
452 CHECK (T == NULL) ;
453
454 o2 = GrB_PLUS_FP64 ;
455 OK (GrB_BinaryOp_free_(&o2)) ;
456 CHECK (o2 == GrB_PLUS_FP64) ;
457 o2 = NULL ;
458
459 OK (GrB_BinaryOp_new (&o2, f2, GrB_INT32, GrB_UINT8, GrB_INT16)) ;
460 CHECK (o2 != NULL) ;
461
462 OK (GrB_BinaryOp_free_(&o2)) ;
463 CHECK (o2 == NULL) ;
464
465 OK (GrB_BinaryOp_free_(&o2)) ;
466 CHECK (o2 == NULL) ;
467
468 #define FREE_DEEP_COPY ;
469 #define GET_DEEP_COPY ;
470
471 GrB_BinaryOp opxx ;
472 METHOD (GrB_BinaryOp_new (&opxx, f2, GrB_INT32, GrB_UINT8, GrB_INT16)) ;
473 OK (GB_BinaryOp_check (opxx, "new binary opxx", G3, NULL)) ;
474 OK (GxB_BinaryOp_fprint (opxx, "new binary opxx", G3, ff)) ;
475 OK (GxB_BinaryOp_fprint_(opxx, G3, ff)) ;
476 OK (GrB_BinaryOp_free_(&opxx)) ;
477 CHECK (opxx == NULL) ;
478
479 #undef FREE_DEEP_COPY
480 #undef GET_DEEP_COPY
481
482 //--------------------------------------------------------------------------
483 // SelectOp
484 //--------------------------------------------------------------------------
485
486 printf ("GxB_SelectOp-------------------------------------------------\n") ;
487 CHECK (selectop == NULL) ;
488 OK (GxB_SelectOp_new (&selectop, fselect, GrB_FP64, GrB_FP64)) ;
489 OK (GxB_SelectOp_free_(&selectop)) ;
490 CHECK (selectop == NULL) ;
491
492 expected = GrB_NULL_POINTER ;
493
494 CHECK (T == NULL) ;
495 ERR (GxB_SelectOp_xtype (&T, selectop)) ;
496 CHECK (T == NULL) ;
497
498 CHECK (T == NULL) ;
499 ERR (GxB_SelectOp_ttype (&T, selectop)) ;
500 CHECK (T == NULL) ;
501
502 CHECK (selectop == NULL) ;
503 OK (GxB_SelectOp_new (&selectop, fselect, GrB_FP64, GrB_FP64)) ;
504
505 CHECK (T == NULL) ;
506 OK (GxB_SelectOp_xtype (&T, selectop)) ;
507 CHECK (T == GrB_FP64) ;
508 T = NULL ;
509
510 CHECK (T == NULL) ;
511 OK (GxB_SelectOp_ttype (&T, selectop)) ;
512 CHECK (T == GrB_FP64) ;
513 T = NULL ;
514
515 OK (GxB_SelectOp_free_(&selectop)) ;
516 CHECK (selectop == NULL) ;
517
518 expected = GrB_NULL_POINTER ;
519 ERR (GxB_SelectOp_new (&selectop, NULL, GrB_FP64, GrB_FP64)) ;
520 CHECK (selectop == NULL) ;
521
522 OK (GxB_SelectOp_free_(&selectop)) ;
523 CHECK (selectop == NULL) ;
524
525 //--------------------------------------------------------------------------
526 // Monoid
527 //--------------------------------------------------------------------------
528
529 printf ("GrB_Monoid---------------------------------------------------\n") ;
530 expected = GrB_NULL_POINTER ;
531
532 ERR (GrB_Monoid_new_BOOL (NULL, NULL, 0)) ;
533 ERR (GrB_Monoid_new_INT8 (NULL, NULL, 0)) ;
534 ERR (GrB_Monoid_new_UINT8 (NULL, NULL, 0)) ;
535 ERR (GrB_Monoid_new_INT16 (NULL, NULL, 0)) ;
536 ERR (GrB_Monoid_new_UINT16 (NULL, NULL, 0)) ;
537 ERR (GrB_Monoid_new_INT32 (NULL, NULL, 0)) ;
538 ERR (GrB_Monoid_new_UINT32 (NULL, NULL, 0)) ;
539 ERR (GrB_Monoid_new_INT64 (NULL, NULL, 0)) ;
540 ERR (GrB_Monoid_new_UINT64 (NULL, NULL, 0)) ;
541 ERR (GrB_Monoid_new_FP32 (NULL, NULL, 0)) ;
542 ERR (GrB_Monoid_new_FP64 (NULL, NULL, 0)) ;
543 ERR (GrB_Monoid_new_UDT (NULL, NULL, NULL)) ;
544
545 ERR (GrB_Monoid_new_BOOL (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
546 ERR (GrB_Monoid_new_INT8 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
547 ERR (GrB_Monoid_new_UINT8 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
548 ERR (GrB_Monoid_new_INT16 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
549 ERR (GrB_Monoid_new_UINT16 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
550 ERR (GrB_Monoid_new_INT32 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
551 ERR (GrB_Monoid_new_UINT32 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
552 ERR (GrB_Monoid_new_INT64 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
553 ERR (GrB_Monoid_new_UINT64 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
554 ERR (GrB_Monoid_new_FP32 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
555 ERR (GrB_Monoid_new_FP64 (&monoid, NULL, 0)) ; CHECK (monoid == NULL) ;
556 ERR (GrB_Monoid_new_UDT (&monoid, NULL, NULL)) ; CHECK (monoid == NULL);
557
558 expected = GrB_UNINITIALIZED_OBJECT ;
559
560 ERR (GrB_Monoid_new_BOOL (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
561 ERR (GrB_Monoid_new_INT8 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
562 ERR (GrB_Monoid_new_UINT8 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
563 ERR (GrB_Monoid_new_INT16 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
564 ERR (GrB_Monoid_new_UINT16 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
565 ERR (GrB_Monoid_new_INT32 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
566 ERR (GrB_Monoid_new_UINT32 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
567 ERR (GrB_Monoid_new_INT64 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
568 ERR (GrB_Monoid_new_UINT64 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
569 ERR (GrB_Monoid_new_FP32 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
570 ERR (GrB_Monoid_new_FP64 (&monoid, op2gunk, 0)) ; CHECK (monoid == NULL);
571
572 expected = GrB_NULL_POINTER ;
573 ERR (GrB_Monoid_new_UDT (&monoid, op2gunk, NULL)) ; CHECK (monoid == NULL) ;
574
575 expected = GrB_UNINITIALIZED_OBJECT ;
576 ERR (GrB_Monoid_new_INT32 (&monoid, op2gunk, 0)) ;
577 CHECK (monoid == NULL) ;
578
579 expected = GrB_NULL_POINTER ;
580 ERR (GrB_Monoid_new_UDT (&monoid, GrB_PLUS_FP64, NULL)) ;
581 CHECK (monoid == NULL) ;
582
583 expected = GrB_DOMAIN_MISMATCH ;
584
585 ERR (GrB_Monoid_new_FP64 (&monoid, GrB_EQ_FP64, (double) 0)) ;
586 CHECK (monoid == NULL) ;
587
588 // These feel like they should work, but '0' becomes int, and it does not
589 // match the type of the operator. So it is expected to fail with a
590 // domain mismatch.
591 ERR (GrB_Monoid_new_INT32 (&monoid, GrB_PLUS_FP64, 0)) ;
592 CHECK (monoid == NULL) ;
593
594 // likewise, all these fail:
595 ERR (GrB_Monoid_new_BOOL (&monoid, GrB_PLUS_FP64, (bool) 0)) ;
596 CHECK (monoid == NULL) ;
597
598 ERR (GrB_Monoid_new_INT8 (&monoid, GrB_PLUS_FP64, (int8_t) 0)) ;
599 CHECK (monoid == NULL) ;
600
601 ERR (GrB_Monoid_new_UINT8 (&monoid, GrB_PLUS_FP64, (uint8_t) 0)) ;
602 CHECK (monoid == NULL) ;
603
604 ERR (GrB_Monoid_new_INT16 (&monoid, GrB_PLUS_FP64, (int16_t) 0)) ;
605 CHECK (monoid == NULL) ;
606
607 ERR (GrB_Monoid_new_UINT16 (&monoid, GrB_PLUS_FP64, (uint16_t) 0)) ;
608 CHECK (monoid == NULL) ;
609
610 ERR (GrB_Monoid_new_INT32 (&monoid, GrB_PLUS_FP64, (int32_t) 0)) ;
611 CHECK (monoid == NULL) ;
612
613 ERR (GrB_Monoid_new_UINT32 (&monoid, GrB_PLUS_FP64, (uint32_t) 0)) ;
614 CHECK (monoid == NULL) ;
615
616 ERR (GrB_Monoid_new_INT64 (&monoid, GrB_PLUS_FP64, (int64_t) 0)) ;
617 CHECK (monoid == NULL) ;
618
619 ERR (GrB_Monoid_new_UINT64 (&monoid, GrB_PLUS_FP64, (uint64_t) 0)) ;
620 CHECK (monoid == NULL) ;
621
622 ERR (GrB_Monoid_new_FP32 (&monoid, GrB_PLUS_FP64, (float) 0)) ;
623 CHECK (monoid == NULL) ;
624
625 ERR (GrB_Monoid_new_FP64 (&monoid, GrB_PLUS_FP32, (double) 0)) ;
626 CHECK (monoid == NULL) ;
627
628 ERR (GxB_Monoid_new_FC32 (&monoid, GrB_PLUS_FP64, GxB_CMPLXF(0,0))) ;
629 CHECK (monoid == NULL) ;
630
631 ERR (GxB_Monoid_new_FC64 (&monoid, GrB_PLUS_FP32, GxB_CMPLX (0,0))) ;
632 CHECK (monoid == NULL) ;
633
634 // this works
635 OK (GrB_Monoid_new_FP64 (&monoid, GrB_PLUS_FP64, (double) 0)) ;
636 CHECK (monoid != NULL) ;
637
638 expected = GrB_NULL_POINTER ;
639
640 ERR (GxB_Monoid_identity (NULL, NULL)) ;
641 ERR (GxB_Monoid_identity (NULL, monoid)) ;
642 x_double = 97.0 ;
643 ERR (GxB_Monoid_identity (&x_double, NULL)) ;
644 CHECK (x_double == 97.0) ;
645
646 OK (GxB_Monoid_identity (&x_double, GxB_TIMES_FP64_MONOID)) ;
647 CHECK (x_double == 1.0) ;
648
649 bool has_terminal = true ;
650 x_double = 42.0 ;
651 OK (GxB_Monoid_terminal (&has_terminal, &x_double, GxB_TIMES_FP64_MONOID)) ;
652 CHECK (!has_terminal) ;
653 CHECK (x_double == 42.0) ;
654
655 OK (GxB_Monoid_terminal (&has_terminal, &x_double, GxB_MAX_FP64_MONOID)) ;
656 CHECK (has_terminal) ;
657 CHECK (x_double == ((double) INFINITY)) ;
658
659 ERR (GxB_Monoid_terminal (NULL, NULL, GxB_MAX_FP64_MONOID)) ;
660 ERR (GxB_Monoid_terminal (&has_terminal, NULL, GxB_MAX_FP64_MONOID)) ;
661 ERR (GxB_Monoid_terminal (NULL, &x_double, GxB_MAX_FP64_MONOID)) ;
662 ERR (GxB_Monoid_terminal (&has_terminal, &x_double, NULL)) ;
663
664 monoid_gunk = monoid ;
665 monoid_gunk->magic = 8080 ;
666 monoid = NULL ;
667
668 expected = GrB_UNINITIALIZED_OBJECT ;
669
670 x_double = 33. ;
671 ERR (GxB_Monoid_identity (&x_double, monoid_gunk)) ;
672 CHECK (x_double == 33.) ;
673
674 expected = GrB_NULL_POINTER ;
675
676 ERR (GxB_Monoid_operator (NULL, NULL)) ;
677 ERR (GxB_Monoid_operator (NULL, GxB_TIMES_FP64_MONOID)) ;
678 ERR (GxB_Monoid_operator (&o2, NULL)) ;
679 CHECK (o2 == NULL) ;
680
681 OK (GxB_Monoid_operator (&o2, GxB_TIMES_FP64_MONOID)) ;
682 CHECK (o2 == GrB_TIMES_FP64) ;
683
684 m2 = GxB_TIMES_FP64_MONOID ;
685 OK (GrB_Monoid_free_(&m2)) ;
686 CHECK (m2 == GxB_TIMES_FP64_MONOID) ;
687 m2 = NULL ;
688
689 expected = GrB_UNINITIALIZED_OBJECT ;
690
691 o2 = NULL ;
692 ERR (GxB_Monoid_operator (&o2, monoid_gunk)) ;
693 CHECK (o2 == NULL) ;
694
695 OK (GrB_Monoid_new_FP64 (&m2, GrB_PLUS_FP64, (double) 0)) ;
696 CHECK (m2 != NULL) ;
697
698 OK (GrB_Monoid_free_(&m2)) ;
699 CHECK (m2 == NULL) ;
700
701 OK (GrB_Monoid_free_(&m2)) ;
702 CHECK (m2 == NULL) ;
703
704 // monoid_gunk is allocated but not initialized
705
706 //--------------------------------------------------------------------------
707 // Semiring
708 //--------------------------------------------------------------------------
709
710 printf ("GrB_Semiring-------------------------------------------------\n") ;
711 expected = GrB_NULL_POINTER ;
712
713 ERR (GrB_Semiring_new (NULL, NULL, NULL)) ;
714 ERR (GrB_Semiring_new (NULL, GxB_MAX_FP64_MONOID, GrB_PLUS_FP64)) ;
715
716 ERR (GrB_Semiring_new (&semiring, NULL, GrB_PLUS_FP64)) ;
717 CHECK (semiring == NULL) ;
718
719 ERR (GrB_Semiring_new (&semiring, GxB_MAX_FP64_MONOID, NULL)) ;
720 CHECK (semiring == NULL) ;
721
722 ERR (GrB_Semiring_new (&semiring, NULL, NULL)) ;
723 CHECK (semiring == NULL) ;
724
725 expected = GrB_UNINITIALIZED_OBJECT ;
726
727 ERR (GrB_Semiring_new (&semiring, monoid_gunk, GrB_PLUS_FP64)) ;
728 CHECK (semiring == NULL) ;
729
730 ERR (GrB_Semiring_new (&semiring, GxB_MAX_FP32_MONOID, op2gunk)) ;
731 CHECK (semiring == NULL) ;
732
733 expected = GrB_DOMAIN_MISMATCH ;
734
735 ERR (GrB_Semiring_new (&semiring, GxB_MAX_FP32_MONOID, GrB_PLUS_FP64)) ;
736 CHECK (semiring == NULL) ;
737
738 OK (GrB_Semiring_new (&semiring, GxB_MAX_FP64_MONOID, GrB_PLUS_FP64)) ;
739 CHECK (semiring != NULL) ;
740
741 o2 = NULL ;
742 OK (GxB_Semiring_multiply (&o2, GxB_MAX_PLUS_FP64)) ;
743 CHECK (o2 == GrB_PLUS_FP64) ;
744 o2 = NULL ;
745
746 m2 = NULL ;
747 OK (GxB_Semiring_add (&m2, GxB_MAX_PLUS_FP64)) ;
748 CHECK (m2 == GxB_MAX_FP64_MONOID) ;
749 m2 = NULL ;
750
751 expected = GrB_NULL_POINTER ;
752
753 ERR (GxB_Semiring_multiply (NULL, NULL)) ;
754 ERR (GxB_Semiring_multiply (NULL, GxB_MAX_PLUS_FP64)) ;
755 ERR (GxB_Semiring_multiply (&o2, NULL)) ;
756 CHECK (o2 == NULL) ;
757
758 ERR (GxB_Semiring_add (NULL, NULL)) ;
759 ERR (GxB_Semiring_add (NULL, GxB_MAX_PLUS_FP64)) ;
760 ERR (GxB_Semiring_add (&m2, NULL)) ;
761 CHECK (m2 == NULL) ;
762
763 expected = GrB_UNINITIALIZED_OBJECT ;
764
765 semigunk = semiring ;
766 semigunk->magic = 747 ;
767 semiring = NULL ;
768
769 m2 = GxB_MAX_INT32_MONOID ;
770 ERR (GxB_Semiring_add (&m2, semigunk)) ;
771 CHECK (m2 == GxB_MAX_INT32_MONOID) ;
772 m2 = NULL ;
773
774 o2 = GxB_LXOR_BOOL ;
775 ERR (GxB_Semiring_multiply (&o2, semigunk)) ;
776 CHECK (o2 == GxB_LXOR_BOOL) ;
777 o2 = NULL ;
778
779 s2 = GxB_PLUS_TIMES_FP64 ;
780 OK (GrB_Semiring_free_(&s2)) ;
781 CHECK (s2 == GxB_PLUS_TIMES_FP64) ;
782 s2 = NULL ;
783
784 OK (GrB_Semiring_new (&s2, GxB_MAX_FP64_MONOID, GrB_PLUS_FP64)) ;
785 CHECK (s2 != NULL) ;
786
787 OK (GrB_Semiring_free_(&s2)) ;
788 CHECK (s2 == NULL) ;
789
790 // semigunk is allocated but not initialized
791
792 //--------------------------------------------------------------------------
793 // user defined ops
794 //--------------------------------------------------------------------------
795
796 #define FREE_DEEP_COPY Complex_finalize ( ) ;
797 #define GET_DEEP_COPY ;
798
799 METHOD (Complex_finalize ( )) ;
800 METHOD (Complex_init (true)) ;
801 METHOD (Complex_finalize ( )) ;
802 METHOD (Complex_init (false)) ;
803
804 #undef FREE_DEEP_COPY
805 #undef GET_DEEP_COPY
806
807 //--------------------------------------------------------------------------
808 // basic Scalar methods
809 //--------------------------------------------------------------------------
810
811 printf ("GrB_Vector---------------------------------------------------\n") ;
812
813 OK (GxB_Scalar_new (&a_scalar, GrB_INT32)) ;
814 CHECK (a_scalar != NULL) ;
815
816 int32_t i_scalar = 33 ;
817 OK (GxB_Scalar_setElement_INT32 (a_scalar, 42)) ;
818 OK (GxB_Scalar_extractElement_INT32_(&i_scalar, a_scalar)) ;
819 CHECK (i_scalar == 42) ;
820 GxB_Scalar_fprint_(a_scalar, 3, NULL) ;
821
822 // force a zombie
823 i_scalar = 33 ;
824 bool scalar_is_full = GB_IS_FULL (a_scalar) ;
825 if (!scalar_is_full)
826 {
827 a_scalar->i [0] = GB_FLIP (0) ;
828 a_scalar->nzombies = 1 ;
829 }
830
831 info = GxB_Scalar_extractElement_INT32_(&i_scalar, a_scalar) ;
832 CHECK (i_scalar == (scalar_is_full) ? 42 : 33) ;
833 CHECK (info == (scalar_is_full) ? GrB_SUCCESS : GrB_NO_VALUE) ;
834
835 OK (GxB_Scalar_free_(&a_scalar)) ;
836
837 OK (GrB_Type_new (&T, sizeof (int))) ;
838
839 i_scalar = 207 ;
840 expected = GrB_DOMAIN_MISMATCH ;
841 OK (GxB_Scalar_new (&a_scalar, T)) ;
842 GxB_Scalar_fprint_(a_scalar, 3, NULL) ;
843 GxB_Type_fprint_(T, 3, NULL) ;
844 ERR1 (a_scalar, GxB_Scalar_setElement_INT32 (a_scalar, 42)) ;
845 ERR (GxB_Scalar_extractElement_INT32_(&i_scalar, a_scalar)) ;
846 CHECK (i_scalar == 207) ;
847
848 printf ("error expected: %d\n", info) ;
849
850 OK (GrB_Type_free_(&T)) ;
851 OK (GxB_Scalar_free_(&a_scalar)) ;
852
853 //--------------------------------------------------------------------------
854 // basic Vector methods
855 //--------------------------------------------------------------------------
856
857 printf ("GrB_Vector---------------------------------------------------\n") ;
858 expected = GrB_NULL_POINTER ;
859
860 ERR (GrB_Vector_new (NULL, NULL, 0)) ;
861 ERR (GrB_Vector_new (NULL, GrB_BOOL, 0)) ;
862 ERR (GrB_Vector_new (&v, NULL, 0)) ;
863 CHECK (v == NULL) ;
864
865 expected = GrB_INVALID_VALUE ;
866
867 ERR (GrB_Vector_new (&v, GrB_BOOL, UINT64_MAX)) ;
868 CHECK (v == NULL) ;
869
870 OK (GrB_Vector_new (&vempty, GrB_BOOL, 0)) ;
871 CHECK (vempty != NULL) ;
872
873 OK (GrB_Vector_free_(&vempty)) ;
874 CHECK (vempty == NULL) ;
875
876 OK (GrB_Vector_free_(&vempty)) ;
877 CHECK (vempty == NULL) ;
878
879 OK (GrB_Vector_new (&vempty, GrB_BOOL, 0)) ;
880 CHECK (vempty != NULL) ;
881
882 OK (GrB_Vector_new (&vgunk, GrB_BOOL, 1)) ;
883 CHECK (vgunk != NULL) ;
884 vgunk->magic = 1024 ;
885
886 OK (GrB_Vector_new (&v, GrB_UINT16, 32)) ;
887 CHECK (v != NULL) ;
888
889 OK (GrB_Vector_dup (&u, v)) ;
890 CHECK (u != NULL) ;
891
892 OK (GrB_Vector_free_(&u)) ;
893 CHECK (u == NULL) ;
894
895 OK (GrB_Vector_free_(&u)) ;
896 CHECK (u == NULL) ;
897
898 expected = GrB_NULL_POINTER ;
899
900 ERR (GrB_Vector_dup (NULL, NULL)) ;
901 ERR (GrB_Vector_dup (NULL, v)) ;
902 ERR (GrB_Vector_dup (NULL, vgunk)) ;
903 ERR (GrB_Vector_dup (NULL, vempty)) ;
904 ERR (GrB_Vector_clear (NULL)) ;
905
906 ERR (GrB_Vector_dup (&u, NULL)) ;
907 CHECK (u == NULL) ;
908
909 expected = GrB_UNINITIALIZED_OBJECT ;
910
911 ERR (GrB_Vector_dup (&u, vgunk)) ;
912 CHECK (u == NULL) ;
913
914 OK (GrB_Vector_clear (v)) ;
915
916 expected = GrB_NULL_POINTER ;
917
918 ERR (GrB_Vector_size (NULL, NULL)) ;
919 ERR (GrB_Vector_size (NULL, v)) ;
920 ERR (GrB_Vector_size (NULL, vgunk)) ;
921 ERR (GrB_Vector_size (NULL, vempty)) ;
922 ERR (GrB_Vector_size (&n, NULL)) ;
923 CHECK (n == 0) ;
924
925 OK (GrB_Vector_size (&n, v)) ;
926 CHECK (n == 32) ;
927
928 expected = GrB_UNINITIALIZED_OBJECT ;
929
930 nvals = 7 ;
931 ERR (GrB_Vector_dup (&u, vgunk)) ;
932 ERR (GrB_Vector_nvals (&nvals, vgunk)) ;
933 CHECK (nvals == 7) ;
934
935 OK (GrB_Vector_setElement_INT32 (v, 12, 0)) ;
936 OK (GrB_Vector_setElement_BOOL (v, false, 18)) ;
937 OK (GrB_Vector_setElement_INT8 (v, 1, 19)) ;
938 OK (GrB_Vector_setElement_UINT8 (v, 2, 20)) ;
939 OK (GrB_Vector_setElement_INT16 (v, 3, 21)) ;
940 OK (GrB_Vector_setElement_UINT16 (v, 4, 22)) ;
941 OK (GrB_Vector_setElement_INT32 (v, 5, 23)) ;
942 OK (GrB_Vector_setElement_UINT32 (v, 6, 24)) ;
943 OK (GrB_Vector_setElement_INT64 (v, 7, 25)) ;
944 OK (GrB_Vector_setElement_UINT64 (v, 8, 26)) ;
945 OK (GrB_Vector_setElement_FP32 (v, 9, 27)) ;
946 OK (GrB_Vector_setElement_FP64 (v, 10, 28)) ;
947 GB_Vector_check (v, "vector 18:28", G3, NULL) ;
948 GxB_Vector_fprint (v, "v", G3, ff) ;
949
950 expected = GrB_NULL_POINTER ;
951
952 nvals = 0 ;
953 ERR (GrB_Vector_nvals (NULL, NULL)) ;
954 ERR (GrB_Vector_nvals (NULL, v)) ;
955 ERR (GrB_Vector_nvals (NULL, vempty)) ;
956 ERR (GrB_Vector_nvals (&nvals, NULL)) ;
957 CHECK (nvals == 0) ;
958
959 OK (GrB_Vector_nvals (&nvals, v)) ;
960 OK (GrB_Vector_wait (&v)) ;
961 printf ("nvals "GBd"\n", nvals) ;
962 GB_Vector_check (v, "vector 18:28", G3, NULL) ;
963 GxB_Vector_fprint (v, "v", G3, ff) ;
964 CHECK (nvals == 12) ;
965
966 expected = GrB_INVALID_OBJECT ;
967 GrB_Vector zz ;
968 OK (GrB_Vector_dup (&zz, v)) ;
969 OK (GB_Vector_check (zz, "zz ok vector", G3, NULL)) ;
970 GB_convert_any_to_hyper ((GrB_Matrix) zz, Context) ;
971 ERR (GB_Vector_check (zz, "zz mangled: vectors cannot be hyper", G3, ff)) ;
972 OK (GrB_Vector_free_(&zz)) ;
973
974 OK (GrB_Vector_clear (v)) ;
975 OK (GrB_Vector_nvals (&nvals, v)) ;
976 CHECK (nvals == 0) ;
977
978 expected = GrB_NULL_POINTER ;
979
980 ERR (GxB_Vector_type (NULL, NULL)) ;
981
982 ERR (GxB_Vector_type (NULL, v)) ;
983 ERR (GxB_Vector_type (NULL, vempty)) ;
984 ERR (GxB_Vector_type (&T, NULL)) ;
985 CHECK (T == NULL) ;
986
987 expected = GrB_UNINITIALIZED_OBJECT ;
988
989 ERR (GrB_Vector_nvals (NULL, vgunk)) ;
990 ERR (GxB_Vector_type (NULL, vgunk)) ;
991 ERR (GxB_Vector_type (&T, vgunk)) ;
992 CHECK (T == NULL) ;
993
994 nvals = 42 ;
995 ERR (GrB_Vector_nvals (&nvals, vgunk)) ;
996 CHECK (nvals == 42) ;
997
998 OK (GrB_Vector_free_(&v)) ;
999 CHECK (v == NULL) ;
1000
1001 // vgunk is allocated but not initialized
1002
1003 //--------------------------------------------------------------------------
1004 // Vector build
1005 //--------------------------------------------------------------------------
1006
1007 printf ("GrB_Vector_build---------------------------------------------\n") ;
1008 expected = GrB_NULL_POINTER ;
1009
1010 ERR (GrB_Vector_build_BOOL (NULL, NULL, NULL, 0, NULL)) ;
1011 ERR (GrB_Vector_build_INT8 (NULL, NULL, NULL, 0, NULL)) ;
1012 ERR (GrB_Vector_build_UINT8 (NULL, NULL, NULL, 0, NULL)) ;
1013 ERR (GrB_Vector_build_INT16 (NULL, NULL, NULL, 0, NULL)) ;
1014 ERR (GrB_Vector_build_UINT16 (NULL, NULL, NULL, 0, NULL)) ;
1015 ERR (GrB_Vector_build_INT32 (NULL, NULL, NULL, 0, NULL)) ;
1016 ERR (GrB_Vector_build_UINT32 (NULL, NULL, NULL, 0, NULL)) ;
1017 ERR (GrB_Vector_build_INT64 (NULL, NULL, NULL, 0, NULL)) ;
1018 ERR (GrB_Vector_build_UINT64 (NULL, NULL, NULL, 0, NULL)) ;
1019 ERR (GrB_Vector_build_FP32 (NULL, NULL, NULL, 0, NULL)) ;
1020 ERR (GrB_Vector_build_FP64 (NULL, NULL, NULL, 0, NULL)) ;
1021 ERR (GrB_Vector_build_UDT (NULL, NULL, NULL, 0, NULL)) ;
1022
1023 expected = GrB_UNINITIALIZED_OBJECT ;
1024
1025 ERR1 (vgunk, GrB_Vector_build_BOOL (vgunk, NULL, NULL, 0, NULL)) ;
1026 ERR1 (vgunk, GrB_Vector_build_INT8 (vgunk, NULL, NULL, 0, NULL)) ;
1027 ERR1 (vgunk, GrB_Vector_build_UINT8 (vgunk, NULL, NULL, 0, NULL)) ;
1028 ERR1 (vgunk, GrB_Vector_build_INT16 (vgunk, NULL, NULL, 0, NULL)) ;
1029 ERR1 (vgunk, GrB_Vector_build_UINT16 (vgunk, NULL, NULL, 0, NULL)) ;
1030 ERR1 (vgunk, GrB_Vector_build_INT32 (vgunk, NULL, NULL, 0, NULL)) ;
1031 ERR1 (vgunk, GrB_Vector_build_UINT32 (vgunk, NULL, NULL, 0, NULL)) ;
1032 ERR1 (vgunk, GrB_Vector_build_INT64 (vgunk, NULL, NULL, 0, NULL)) ;
1033 ERR1 (vgunk, GrB_Vector_build_UINT64 (vgunk, NULL, NULL, 0, NULL)) ;
1034 ERR1 (vgunk, GrB_Vector_build_FP32 (vgunk, NULL, NULL, 0, NULL)) ;
1035 ERR1 (vgunk, GrB_Vector_build_FP64 (vgunk, NULL, NULL, 0, NULL)) ;
1036 ERR1 (vgunk, GrB_Vector_build_UDT (vgunk, NULL, NULL, 0, NULL)) ;
1037
1038 expected = GrB_NULL_POINTER ;
1039
1040 OK (GrB_Vector_new (&v, GrB_FP64, 10)) ;
1041 ERR1 (v, GrB_Vector_build_FP64 (v, I, NULL, 0, NULL)) ;
1042 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 0, NULL)) ;
1043
1044 expected = GrB_INVALID_VALUE ;
1045 o2 = GrB_SECOND_FP64 ;
1046 ERR1 (v, GrB_Vector_build_FP64 (v, GrB_ALL, X, 0, o2)) ;
1047
1048 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, GxB_INDEX_MAX+1, o2)) ;
1049
1050 expected = GrB_UNINITIALIZED_OBJECT ;
1051
1052 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, op2gunk)) ;
1053
1054 expected = GrB_DOMAIN_MISMATCH ;
1055
1056 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, GrB_LE_FP64)) ;
1057 ERR1 (v, GrB_Vector_build_UDT_(v, I, (void *) X, 5, GrB_PLUS_FP64)) ;
1058
1059 OK (GxB_BinaryOp_fprint (Complex_plus, "Complex-plus op", G3, f)) ;
1060 OK (GxB_Type_fprint (Complex, "Complex user type", G3, f)) ;
1061 OK (GxB_Type_fprint (GxB_FC64, "Complex built-in type", G3, f)) ;
1062 if (Complex == GxB_FC64)
1063 {
1064 OK (GrB_Vector_build_FP64_(v, I, X, 5, Complex_plus)) ;
1065 GrB_Vector_free_(&v) ;
1066 OK (GrB_Vector_new (&v, GrB_FP64, 10)) ;
1067 }
1068 else
1069 {
1070 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, Complex_plus)) ;
1071 }
1072
1073 expected = GrB_OUTPUT_NOT_EMPTY ;
1074
1075 OK (GrB_Vector_setElement_INT32 (v, 12, 0)) ;
1076
1077 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, GrB_PLUS_FP64)) ;
1078
1079 OK (GrB_Vector_clear (v)) ;
1080 OK (GrB_Vector_build_FP64_(v, I, X, 5, GrB_PLUS_FP64)) ;
1081 OK (GrB_Vector_clear (v)) ;
1082 GB_Vector_check (v, "v clear", G3, NULL) ;
1083 GxB_Vector_fprint (v, "v", G3, ff) ;
1084
1085 expected = GrB_INVALID_VALUE ;
1086 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, GxB_RANGE, GrB_PLUS_FP64)) ;
1087 GrB_Vector_error_(&err, v) ;
1088 printf ("%s\n", err) ;
1089
1090 expected = GrB_INDEX_OUT_OF_BOUNDS ;
1091
1092 I [0] = 10 ;
1093 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, GrB_PLUS_FP64)) ;
1094 GrB_Vector_error_(&err, v) ;
1095 printf ("expected error, index out of bounds:\n%s\n", err) ;
1096
1097 GB_Vector_check (v, "v bad", G3, NULL) ;
1098 GxB_Vector_fprint (v, "v", G3, ff) ;
1099
1100 expected = GrB_INVALID_OBJECT ;
1101 ERR (GrB_Vector_nvals (&nvals, v)) ;
1102
1103 OK (GrB_Vector_free_(&v)) ;
1104 OK (GrB_Vector_new (&v, GrB_FP64, 10)) ;
1105
1106 I [0] = -1 ;
1107 expected = GrB_INDEX_OUT_OF_BOUNDS ;
1108 ERR1 (v, GrB_Vector_build_FP64_(v, I, X, 5, GrB_PLUS_FP64)) ;
1109
1110 expected = GrB_INVALID_OBJECT ;
1111 ERR (GrB_Vector_nvals (&nvals, v)) ;
1112 I [0] = 0 ;
1113
1114 OK (GrB_Vector_free_(&v)) ;
1115 OK (GrB_Vector_new (&v, GrB_FP64, 10)) ;
1116
1117 // v is a valid 10-by-1 FP64 vector with no entries
1118
1119 //--------------------------------------------------------------------------
1120 // Vector setElement
1121 //--------------------------------------------------------------------------
1122
1123 printf ("GrB_Vector_setElement----------------------------------------\n") ;
1124 expected = GrB_NULL_POINTER ;
1125
1126 ERR (GrB_Vector_setElement_BOOL (NULL, 0, 0)) ;
1127 ERR (GrB_Vector_setElement_INT8 (NULL, 0, 0)) ;
1128 ERR (GrB_Vector_setElement_UINT8 (NULL, 0, 0)) ;
1129 ERR (GrB_Vector_setElement_INT16 (NULL, 0, 0)) ;
1130 ERR (GrB_Vector_setElement_UINT16 (NULL, 0, 0)) ;
1131 ERR (GrB_Vector_setElement_INT32 (NULL, 0, 0)) ;
1132 ERR (GrB_Vector_setElement_UINT32 (NULL, 0, 0)) ;
1133 ERR (GrB_Vector_setElement_INT64 (NULL, 0, 0)) ;
1134 ERR (GrB_Vector_setElement_UINT64 (NULL, 0, 0)) ;
1135 ERR (GrB_Vector_setElement_FP32 (NULL, 0, 0)) ;
1136 ERR (GrB_Vector_setElement_FP64 (NULL, 0, 0)) ;
1137 ERR (GrB_Vector_setElement_UDT (NULL, 0, 0)) ;
1138 ERR1 (v, GrB_Vector_setElement_UDT (v, NULL, 0)) ;
1139
1140 expected = GrB_UNINITIALIZED_OBJECT ;
1141
1142 ERR1 (vgunk, GrB_Vector_setElement_BOOL (vgunk, 0, 0)) ;
1143 ERR1 (vgunk, GrB_Vector_setElement_INT8 (vgunk, 0, 0)) ;
1144 ERR1 (vgunk, GrB_Vector_setElement_UINT8 (vgunk, 0, 0)) ;
1145 ERR1 (vgunk, GrB_Vector_setElement_INT16 (vgunk, 0, 0)) ;
1146 ERR1 (vgunk, GrB_Vector_setElement_UINT16 (vgunk, 0, 0)) ;
1147 ERR1 (vgunk, GrB_Vector_setElement_INT32 (vgunk, 0, 0)) ;
1148 ERR1 (vgunk, GrB_Vector_setElement_UINT32 (vgunk, 0, 0)) ;
1149 ERR1 (vgunk, GrB_Vector_setElement_INT64 (vgunk, 0, 0)) ;
1150 ERR1 (vgunk, GrB_Vector_setElement_UINT64 (vgunk, 0, 0)) ;
1151 ERR1 (vgunk, GrB_Vector_setElement_FP32 (vgunk, 0, 0)) ;
1152 ERR1 (vgunk, GrB_Vector_setElement_FP64 (vgunk, 0, 0)) ;
1153 ERR1 (vgunk, GrB_Vector_setElement_UDT (vgunk, 0, 0)) ;
1154
1155 expected = GrB_INVALID_INDEX ;
1156
1157 ERR1 (v, GrB_Vector_setElement_INT32 (v, 0, -1)) ;
1158
1159 expected = GrB_DOMAIN_MISMATCH ;
1160
1161 ERR1 (v, GrB_Vector_setElement_UDT (v, (void *) X, 0)) ;
1162
1163 //--------------------------------------------------------------------------
1164 // Vector extractElement
1165 //--------------------------------------------------------------------------
1166
1167 printf ("GrB_Vector_extractElement------------------------------------\n") ;
1168 expected = GrB_NULL_POINTER ;
1169
1170 ERR (GrB_Vector_extractElement_BOOL (NULL, NULL, 0)) ;
1171 ERR (GrB_Vector_extractElement_INT8 (NULL, NULL, 0)) ;
1172 ERR (GrB_Vector_extractElement_UINT8 (NULL, NULL, 0)) ;
1173 ERR (GrB_Vector_extractElement_INT16 (NULL, NULL, 0)) ;
1174 ERR (GrB_Vector_extractElement_UINT16 (NULL, NULL, 0)) ;
1175 ERR (GrB_Vector_extractElement_INT32 (NULL, NULL, 0)) ;
1176 ERR (GrB_Vector_extractElement_UINT32 (NULL, NULL, 0)) ;
1177 ERR (GrB_Vector_extractElement_INT64 (NULL, NULL, 0)) ;
1178 ERR (GrB_Vector_extractElement_UINT64 (NULL, NULL, 0)) ;
1179 ERR (GrB_Vector_extractElement_FP32 (NULL, NULL, 0)) ;
1180 ERR (GrB_Vector_extractElement_FP64 (NULL, NULL, 0)) ;
1181 ERR (GrB_Vector_extractElement_UDT (NULL, NULL, 0)) ;
1182
1183 ERR (GrB_Vector_extractElement_BOOL (NULL, v, 0)) ;
1184 ERR (GrB_Vector_extractElement_INT8 (NULL, v, 0)) ;
1185 ERR (GrB_Vector_extractElement_UINT8 (NULL, v, 0)) ;
1186 ERR (GrB_Vector_extractElement_INT16 (NULL, v, 0)) ;
1187 ERR (GrB_Vector_extractElement_UINT16 (NULL, v, 0)) ;
1188 ERR (GrB_Vector_extractElement_INT32 (NULL, v, 0)) ;
1189 ERR (GrB_Vector_extractElement_UINT32 (NULL, v, 0)) ;
1190 ERR (GrB_Vector_extractElement_INT64 (NULL, v, 0)) ;
1191 ERR (GrB_Vector_extractElement_UINT64 (NULL, v, 0)) ;
1192 ERR (GrB_Vector_extractElement_FP32 (NULL, v, 0)) ;
1193 ERR (GrB_Vector_extractElement_FP64 (NULL, v, 0)) ;
1194 ERR (GrB_Vector_extractElement_UDT (NULL, v, 0)) ;
1195
1196 expected = GrB_UNINITIALIZED_OBJECT ;
1197
1198 ERR (GrB_Vector_extractElement_BOOL (NULL, vgunk, 0)) ;
1199 ERR (GrB_Vector_extractElement_INT8 (NULL, vgunk, 0)) ;
1200 ERR (GrB_Vector_extractElement_UINT8 (NULL, vgunk, 0)) ;
1201 ERR (GrB_Vector_extractElement_INT16 (NULL, vgunk, 0)) ;
1202 ERR (GrB_Vector_extractElement_UINT16 (NULL, vgunk, 0)) ;
1203 ERR (GrB_Vector_extractElement_INT32 (NULL, vgunk, 0)) ;
1204 ERR (GrB_Vector_extractElement_UINT32 (NULL, vgunk, 0)) ;
1205 ERR (GrB_Vector_extractElement_INT64 (NULL, vgunk, 0)) ;
1206 ERR (GrB_Vector_extractElement_UINT64 (NULL, vgunk, 0)) ;
1207 ERR (GrB_Vector_extractElement_FP32 (NULL, vgunk, 0)) ;
1208 ERR (GrB_Vector_extractElement_FP64 (NULL, vgunk, 0)) ;
1209 ERR (GrB_Vector_extractElement_UDT (NULL, vgunk, 0)) ;
1210
1211 expected = GrB_INVALID_INDEX ;
1212
1213 ERR (GrB_Vector_extractElement_FP64_(&x_double, v, -1)) ;
1214 ERR (GrB_Vector_extractElement_FP64_(&x_double, v, 10)) ;
1215
1216 expected = GrB_DOMAIN_MISMATCH ;
1217
1218 ERR (GrB_Vector_extractElement_UDT ((void *) X, v, 0)) ;
1219
1220 OK (GrB_Vector_setElement_FP64 (v, 22.8, 2)) ;
1221 OK (GrB_Vector_setElement_FP64 (v, 44.9, 4)) ;
1222
1223 x_double = 404 ;
1224 OK (GrB_Vector_extractElement_FP64_(&x_double, v, 3)) ;
1225 CHECK (x_double == 404) ;
1226 CHECK (info == GrB_NO_VALUE) ;
1227
1228 OK (GrB_Vector_setElement_FP64 (v, 77.3, 0)) ;
1229
1230 OK (GrB_Vector_extractElement_FP64_(&x_double, v, 0)) ;
1231
1232 CHECK (info == GrB_SUCCESS) ;
1233 CHECK (x_double == 77.3) ;
1234
1235 OK (GrB_Vector_nvals (&n2, v)) ;
1236 OK (GrB_Vector_wait_(&v)) ;
1237 fprintf (f, "vector nvals: %d\n", (int) n2) ;
1238 CHECK (n2 == 3) ;
1239
1240 // v is now a valid FP64 vector with 3 entries
1241
1242 //--------------------------------------------------------------------------
1243 // Vector extractTuples
1244 //--------------------------------------------------------------------------
1245
1246 printf ("GrB_Vector_extractTuples-------------------------------------\n") ;
1247
1248 expected = GrB_NULL_POINTER ;
1249 OK (GrB_Vector_nvals (&n2, v)) ;
1250 nvals = n2 ;
1251
1252 ERR (GrB_Vector_extractTuples_BOOL (NULL, NULL, NULL, v)) ;
1253 ERR (GrB_Vector_extractTuples_INT8 (NULL, NULL, NULL, v)) ;
1254 ERR (GrB_Vector_extractTuples_UINT8 (NULL, NULL, NULL, v)) ;
1255 ERR (GrB_Vector_extractTuples_INT16 (NULL, NULL, NULL, v)) ;
1256 ERR (GrB_Vector_extractTuples_UINT16 (NULL, NULL, NULL, v)) ;
1257 ERR (GrB_Vector_extractTuples_INT32 (NULL, NULL, NULL, v)) ;
1258 ERR (GrB_Vector_extractTuples_UINT32 (NULL, NULL, NULL, v)) ;
1259 ERR (GrB_Vector_extractTuples_INT64 (NULL, NULL, NULL, v)) ;
1260 ERR (GrB_Vector_extractTuples_UINT64 (NULL, NULL, NULL, v)) ;
1261 ERR (GrB_Vector_extractTuples_FP32 (NULL, NULL, NULL, v)) ;
1262 ERR (GrB_Vector_extractTuples_FP64 (NULL, NULL, NULL, v)) ;
1263 ERR (GrB_Vector_extractTuples_UDT (NULL, NULL, NULL, v)) ;
1264
1265 ERR (GrB_Vector_extractTuples_BOOL (NULL, NULL, &nvals, NULL)) ;
1266 ERR (GrB_Vector_extractTuples_INT8 (NULL, NULL, &nvals, NULL)) ;
1267 ERR (GrB_Vector_extractTuples_UINT8 (NULL, NULL, &nvals, NULL)) ;
1268 ERR (GrB_Vector_extractTuples_INT16 (NULL, NULL, &nvals, NULL)) ;
1269 ERR (GrB_Vector_extractTuples_UINT16 (NULL, NULL, &nvals, NULL)) ;
1270 ERR (GrB_Vector_extractTuples_INT32 (NULL, NULL, &nvals, NULL)) ;
1271 ERR (GrB_Vector_extractTuples_UINT32 (NULL, NULL, &nvals, NULL)) ;
1272 ERR (GrB_Vector_extractTuples_INT64 (NULL, NULL, &nvals, NULL)) ;
1273 ERR (GrB_Vector_extractTuples_UINT64 (NULL, NULL, &nvals, NULL)) ;
1274 ERR (GrB_Vector_extractTuples_FP32 (NULL, NULL, &nvals, NULL)) ;
1275 ERR (GrB_Vector_extractTuples_FP64 (NULL, NULL, &nvals, NULL)) ;
1276 ERR (GrB_Vector_extractTuples_UDT (NULL, NULL, &nvals, NULL)) ;
1277
1278 expected = GrB_UNINITIALIZED_OBJECT ;
1279
1280 ERR (GrB_Vector_extractTuples_BOOL (NULL, NULL, &nvals, vgunk)) ;
1281 ERR (GrB_Vector_extractTuples_INT8 (NULL, NULL, &nvals, vgunk)) ;
1282 ERR (GrB_Vector_extractTuples_UINT8 (NULL, NULL, &nvals, vgunk)) ;
1283 ERR (GrB_Vector_extractTuples_INT16 (NULL, NULL, &nvals, vgunk)) ;
1284 ERR (GrB_Vector_extractTuples_UINT16 (NULL, NULL, &nvals, vgunk)) ;
1285 ERR (GrB_Vector_extractTuples_INT32 (NULL, NULL, &nvals, vgunk)) ;
1286 ERR (GrB_Vector_extractTuples_UINT32 (NULL, NULL, &nvals, vgunk)) ;
1287 ERR (GrB_Vector_extractTuples_INT64 (NULL, NULL, &nvals, vgunk)) ;
1288 ERR (GrB_Vector_extractTuples_UINT64 (NULL, NULL, &nvals, vgunk)) ;
1289 ERR (GrB_Vector_extractTuples_FP32 (NULL, NULL, &nvals, vgunk)) ;
1290 ERR (GrB_Vector_extractTuples_FP64 (NULL, NULL, &nvals, vgunk)) ;
1291 ERR (GrB_Vector_extractTuples_UDT (NULL, NULL, &nvals, vgunk)) ;
1292
1293 expected = GrB_INSUFFICIENT_SPACE ;
1294
1295 nvals = n2-1 ;
1296 ERR (GrB_Vector_extractTuples_FP64_(I2, X2, &nvals, v)) ;
1297 nvals = n2 ;
1298 OK (GrB_Vector_extractTuples_FP64_(I2, X2, &nvals, v)) ;
1299
1300 for (int k = 0 ; k < n2 ; k++)
1301 {
1302 fprintf (f, "%d: v("GBu") = %g\n", k, I2 [k], X2 [k]) ;
1303 }
1304 fprintf (f, "\n") ;
1305
1306 expected = GrB_DOMAIN_MISMATCH ;
1307
1308 ERR (GrB_Vector_extractTuples_UDT_(I2, (void *) X2, &nvals, v)) ;
1309
1310 GrB_Vector_free_(&v) ;
1311 CHECK (v == NULL) ;
1312
1313 //--------------------------------------------------------------------------
1314 // basic Matrix methods
1315 //--------------------------------------------------------------------------
1316
1317 printf ("GrB_Matrix---------------------------------------------------\n") ;
1318 expected = GrB_NULL_POINTER ;
1319
1320 ERR (GrB_Matrix_new (NULL, NULL, 0, 0)) ;
1321 ERR (GrB_Matrix_new (NULL, GrB_BOOL, 0, 0)) ;
1322 ERR (GrB_Matrix_new (&A, NULL, 0, 0)) ;
1323 CHECK (A == NULL) ;
1324
1325 expected = GrB_INVALID_VALUE ;
1326
1327 ERR (GrB_Matrix_new (&A, GrB_BOOL, UINT64_MAX, 0)) ; CHECK (A == NULL) ;
1328 ERR (GrB_Matrix_new (&A, GrB_BOOL, 0, UINT64_MAX)) ; CHECK (A == NULL) ;
1329
1330 OK (GrB_Matrix_new (&Aempty, GrB_BOOL, 0, 0)) ;
1331 CHECK (Aempty != NULL) ;
1332
1333 OK (GrB_Matrix_free_(&Aempty)) ;
1334 CHECK (Aempty == NULL) ;
1335
1336 OK (GrB_Matrix_free_(&Aempty)) ;
1337 CHECK (Aempty == NULL) ;
1338
1339 OK (GrB_Matrix_new (&Aempty, GrB_BOOL, 0, 0)) ;
1340 CHECK (Aempty != NULL) ;
1341
1342 OK (GrB_Matrix_new (&Agunk, GrB_BOOL, 1, 1)) ;
1343 CHECK (Agunk != NULL) ;
1344 Agunk->magic = 1024 ;
1345
1346 OK (GrB_Matrix_new (&A, GrB_UINT16, 32, 8)) ;
1347 CHECK (A != NULL) ;
1348
1349 OK (GrB_Matrix_dup (&C, A)) ;
1350 CHECK (C != NULL) ;
1351
1352 OK (GrB_Matrix_free_(&C)) ;
1353 CHECK (C == NULL) ;
1354
1355 OK (GrB_Matrix_free_(&C)) ;
1356 CHECK (C == NULL) ;
1357
1358 expected = GrB_NULL_POINTER ;
1359
1360 ERR (GrB_Matrix_dup (NULL, NULL)) ;
1361 ERR (GrB_Matrix_dup (NULL, A)) ;
1362 ERR (GrB_Matrix_dup (NULL, Agunk)) ;
1363 ERR (GrB_Matrix_dup (NULL, Aempty)) ;
1364 ERR (GrB_Matrix_clear (NULL)) ;
1365
1366 ERR (GrB_Matrix_dup (&C, NULL)) ;
1367 CHECK (C == NULL) ;
1368
1369 expected = GrB_UNINITIALIZED_OBJECT ;
1370
1371 ERR (GrB_Matrix_nrows (&n, Agunk)) ;
1372 ERR (GrB_Matrix_ncols (&n, Agunk)) ;
1373 ERR (GrB_Matrix_nvals (&n, Agunk)) ;
1374 ERR (GrB_Matrix_dup (&C, Agunk)) ;
1375 CHECK (C == NULL) ;
1376
1377 OK (GrB_Matrix_clear (A)) ;
1378
1379 expected = GrB_NULL_POINTER ;
1380
1381 n = 999 ;
1382 ERR (GrB_Matrix_nrows (NULL, NULL)) ;
1383 ERR (GrB_Matrix_nrows (NULL, A)) ;
1384 ERR (GrB_Matrix_nrows (NULL, Agunk)) ;
1385 ERR (GrB_Matrix_nrows (NULL, Aempty)) ;
1386 ERR (GrB_Matrix_nrows (&n, NULL)) ;
1387 CHECK (n == 999) ;
1388
1389 ERR (GrB_Matrix_ncols (NULL, NULL)) ;
1390 ERR (GrB_Matrix_ncols (NULL, A)) ;
1391 ERR (GrB_Matrix_ncols (NULL, Agunk)) ;
1392 ERR (GrB_Matrix_ncols (NULL, Aempty)) ;
1393 ERR (GrB_Matrix_ncols (&n, NULL)) ;
1394 CHECK (n == 999) ;
1395
1396 OK (GrB_Matrix_nrows (&n, A)) ;
1397 CHECK (n == 32) ;
1398
1399 OK (GrB_Matrix_ncols (&n, A)) ;
1400 CHECK (n == 8) ;
1401
1402 expected = GrB_UNINITIALIZED_OBJECT ;
1403
1404 ERR (GrB_Matrix_dup (&C, Agunk)) ;
1405
1406 OK (GrB_Matrix_setElement_INT32 (A, 21, 0, 2)) ;
1407 OK (GrB_Matrix_setElement_INT32 (A, 19, 3, 1)) ;
1408
1409 expected = GrB_INVALID_INDEX ;
1410 ERR1 (A, GrB_Matrix_setElement_INT32 (A, 19, 3, 1000)) ;
1411
1412 expected = GrB_NULL_POINTER ;
1413
1414 n = 0 ;
1415 ERR (GrB_Matrix_nvals (NULL, NULL)) ;
1416 ERR (GrB_Matrix_nvals (NULL, A)) ;
1417 ERR (GrB_Matrix_nvals (NULL, Aempty)) ;
1418 ERR (GrB_Matrix_nvals (&nvals, NULL)) ;
1419 CHECK (n == 0) ;
1420
1421 OK (GrB_Matrix_nvals (&nvals, A)) ;
1422 CHECK (nvals == 2) ;
1423
1424 OK (GrB_Matrix_clear (A)) ;
1425 OK (GrB_Matrix_nvals (&nvals, A)) ;
1426 CHECK (n == 0) ;
1427
1428 expected = GrB_NULL_POINTER ;
1429
1430 ERR (GxB_Matrix_type (NULL, NULL)) ;
1431
1432 ERR (GxB_Matrix_type (NULL, A)) ;
1433 ERR (GxB_Matrix_type (NULL, Aempty)) ;
1434 ERR (GxB_Matrix_type (&T, NULL)) ;
1435 CHECK (T == NULL) ;
1436
1437 expected = GrB_UNINITIALIZED_OBJECT ;
1438
1439 ERR (GrB_Matrix_nvals (NULL, Agunk)) ;
1440 ERR (GxB_Matrix_type (NULL, Agunk)) ;
1441 ERR (GxB_Matrix_type (&T, Agunk)) ;
1442 CHECK (T == NULL) ;
1443
1444 nvals = 42 ;
1445 ERR (GrB_Matrix_nvals (&nvals, Agunk)) ;
1446 CHECK (nvals == 42) ;
1447
1448 OK (GrB_Matrix_free_(&A)) ;
1449 CHECK (A == NULL) ;
1450
1451 // Agunk is allocated but not initialized
1452
1453 //--------------------------------------------------------------------------
1454 // Matrix build
1455 //--------------------------------------------------------------------------
1456
1457 printf ("GrB_Matrix_build---------------------------------------------\n") ;
1458 expected = GrB_NULL_POINTER ;
1459
1460 ERR (GrB_Matrix_build_BOOL (NULL, NULL, NULL, NULL, 0, NULL)) ;
1461 ERR (GrB_Matrix_build_INT8 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1462 ERR (GrB_Matrix_build_UINT8 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1463 ERR (GrB_Matrix_build_INT16 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1464 ERR (GrB_Matrix_build_UINT16 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1465 ERR (GrB_Matrix_build_INT32 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1466 ERR (GrB_Matrix_build_UINT32 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1467 ERR (GrB_Matrix_build_INT64 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1468 ERR (GrB_Matrix_build_UINT64 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1469 ERR (GrB_Matrix_build_FP32 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1470 ERR (GrB_Matrix_build_FP64 (NULL, NULL, NULL, NULL, 0, NULL)) ;
1471 ERR (GrB_Matrix_build_UDT (NULL, NULL, NULL, NULL, 0, NULL)) ;
1472
1473 expected = GrB_UNINITIALIZED_OBJECT ;
1474
1475 ERR1 (Agunk, GrB_Matrix_build_BOOL (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1476 ERR1 (Agunk, GrB_Matrix_build_INT8 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1477 ERR1 (Agunk, GrB_Matrix_build_UINT8 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1478 ERR1 (Agunk, GrB_Matrix_build_INT16 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1479 ERR1 (Agunk, GrB_Matrix_build_UINT16 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1480 ERR1 (Agunk, GrB_Matrix_build_INT32 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1481 ERR1 (Agunk, GrB_Matrix_build_UINT32 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1482 ERR1 (Agunk, GrB_Matrix_build_INT64 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1483 ERR1 (Agunk, GrB_Matrix_build_UINT64 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1484 ERR1 (Agunk, GrB_Matrix_build_FP32 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1485 ERR1 (Agunk, GrB_Matrix_build_FP64 (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1486 ERR1 (Agunk, GrB_Matrix_build_UDT (Agunk, NULL, NULL, NULL, 0, NULL)) ;
1487
1488 expected = GrB_NULL_POINTER ;
1489
1490 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 5)) ;
1491 ERR1 (A, GrB_Matrix_build_FP64 (A, I, NULL, NULL, 0, NULL)) ;
1492 ERR1 (A, GrB_Matrix_build_FP64 (A, NULL, NULL, NULL, 0, NULL)) ;
1493 ERR1 (A, GrB_Matrix_build_FP64 (A, I, J, NULL, 0, NULL)) ;
1494 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 0, NULL)) ;
1495
1496 expected = GrB_INVALID_VALUE ;
1497
1498 o2 = GrB_SECOND_FP64 ;
1499 ERR1 (A, GrB_Matrix_build_FP64_(A, GrB_ALL, J, X, 0, o2)) ;
1500 ERR1 (A, GrB_Matrix_build_FP64_(A, I, GrB_ALL, X, 0, o2)) ;
1501 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, GxB_INDEX_MAX+1, o2)) ;
1502
1503 expected = GrB_UNINITIALIZED_OBJECT ;
1504
1505 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, op2gunk)) ;
1506
1507 expected = GrB_DOMAIN_MISMATCH ;
1508
1509 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, GrB_LE_FP64)) ;
1510 if (Complex == GxB_FC64)
1511 {
1512 OK (GrB_Matrix_build_FP64_(A, I, J, X, 5, Complex_plus)) ;
1513 GrB_Matrix_free_(&A) ;
1514 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 5)) ;
1515 }
1516 else
1517 {
1518 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, Complex_plus)) ;
1519 }
1520 ERR1 (A, GrB_Matrix_build_UDT_(A, I, J, (void *) X, 5, GrB_PLUS_FP64)) ;
1521
1522 expected = GrB_OUTPUT_NOT_EMPTY ;
1523
1524 OK (GrB_Matrix_setElement_INT32 (A, 12, 0, 0)) ;
1525 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, GrB_PLUS_FP64)) ;
1526 OK (GrB_Matrix_clear (A)) ;
1527 OK (GrB_Matrix_build_FP64_(A, I, J, X, 5, GrB_PLUS_FP64)) ;
1528 OK (GrB_Matrix_clear (A)) ;
1529
1530 expected = GrB_INDEX_OUT_OF_BOUNDS ;
1531
1532 I [0] = 10 ;
1533 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, GrB_PLUS_FP64)) ;
1534
1535 expected = GrB_INVALID_OBJECT ;
1536 ERR (GrB_Matrix_nvals (&nvals, A)) ;
1537
1538 OK (GrB_Matrix_free_(&A)) ;
1539 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 5)) ;
1540
1541 I [0] = -1 ;
1542
1543 expected = GrB_INDEX_OUT_OF_BOUNDS ;
1544 ERR1 (A, GrB_Matrix_build_FP64_(A, I, J, X, 5, GrB_PLUS_FP64)) ;
1545
1546 expected = GrB_INVALID_OBJECT ;
1547 ERR (GrB_Matrix_nvals (&nvals, A)) ;
1548 I [0] = 0 ;
1549
1550 OK (GrB_Matrix_free_(&A)) ;
1551 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 5)) ;
1552
1553 // A is a valid 10-by-5 FP64 matrix with no entries
1554
1555 //--------------------------------------------------------------------------
1556 // Matrix setElement
1557 //--------------------------------------------------------------------------
1558
1559 printf ("GrB_Matrix_setElement----------------------------------------\n") ;
1560 expected = GrB_NULL_POINTER ;
1561
1562 ERR (GrB_Matrix_setElement_BOOL (NULL, 0, 0, 0)) ;
1563 ERR (GrB_Matrix_setElement_INT8 (NULL, 0, 0, 0)) ;
1564 ERR (GrB_Matrix_setElement_UINT8 (NULL, 0, 0, 0)) ;
1565 ERR (GrB_Matrix_setElement_INT16 (NULL, 0, 0, 0)) ;
1566 ERR (GrB_Matrix_setElement_UINT16 (NULL, 0, 0, 0)) ;
1567 ERR (GrB_Matrix_setElement_INT32 (NULL, 0, 0, 0)) ;
1568 ERR (GrB_Matrix_setElement_UINT32 (NULL, 0, 0, 0)) ;
1569 ERR (GrB_Matrix_setElement_INT64 (NULL, 0, 0, 0)) ;
1570 ERR (GrB_Matrix_setElement_UINT64 (NULL, 0, 0, 0)) ;
1571 ERR (GrB_Matrix_setElement_FP32 (NULL, 0, 0, 0)) ;
1572 ERR (GrB_Matrix_setElement_FP64 (NULL, 0, 0, 0)) ;
1573 ERR (GrB_Matrix_setElement_UDT (NULL, 0, 0, 0)) ;
1574 ERR1 (A, GrB_Matrix_setElement_UDT (A, NULL, 0, 0)) ;
1575
1576 expected = GrB_UNINITIALIZED_OBJECT ;
1577
1578 ERR1 (Agunk, GrB_Matrix_setElement_BOOL (Agunk, 0, 0, 0)) ;
1579 ERR1 (Agunk, GrB_Matrix_setElement_INT8 (Agunk, 0, 0, 0)) ;
1580 ERR1 (Agunk, GrB_Matrix_setElement_UINT8 (Agunk, 0, 0, 0)) ;
1581 ERR1 (Agunk, GrB_Matrix_setElement_INT16 (Agunk, 0, 0, 0)) ;
1582 ERR1 (Agunk, GrB_Matrix_setElement_UINT16 (Agunk, 0, 0, 0)) ;
1583 ERR1 (Agunk, GrB_Matrix_setElement_INT32 (Agunk, 0, 0, 0)) ;
1584 ERR1 (Agunk, GrB_Matrix_setElement_UINT32 (Agunk, 0, 0, 0)) ;
1585 ERR1 (Agunk, GrB_Matrix_setElement_INT64 (Agunk, 0, 0, 0)) ;
1586 ERR1 (Agunk, GrB_Matrix_setElement_UINT64 (Agunk, 0, 0, 0)) ;
1587 ERR1 (Agunk, GrB_Matrix_setElement_FP32 (Agunk, 0, 0, 0)) ;
1588 ERR1 (Agunk, GrB_Matrix_setElement_FP64 (Agunk, 0, 0, 0)) ;
1589 ERR1 (Agunk, GrB_Matrix_setElement_UDT (Agunk, 0, 0, 0)) ;
1590
1591 expected = GrB_INVALID_INDEX ;
1592
1593 ERR1 (A, GrB_Matrix_setElement_INT32 (A, 0, -1, 0)) ;
1594
1595 expected = GrB_DOMAIN_MISMATCH ;
1596
1597 ERR1 (A, GrB_Matrix_setElement_UDT (A, (void *) X, 0, 0)) ;
1598
1599 //--------------------------------------------------------------------------
1600 // Matrix extractElement
1601 //--------------------------------------------------------------------------
1602
1603 printf ("GrB_Matrix_extractElement------------------------------------\n") ;
1604 expected = GrB_NULL_POINTER ;
1605
1606 ERR (GrB_Matrix_extractElement_BOOL (NULL, NULL, 0, 0)) ;
1607 ERR (GrB_Matrix_extractElement_INT8 (NULL, NULL, 0, 0)) ;
1608 ERR (GrB_Matrix_extractElement_UINT8 (NULL, NULL, 0, 0)) ;
1609 ERR (GrB_Matrix_extractElement_INT16 (NULL, NULL, 0, 0)) ;
1610 ERR (GrB_Matrix_extractElement_UINT16 (NULL, NULL, 0, 0)) ;
1611 ERR (GrB_Matrix_extractElement_INT32 (NULL, NULL, 0, 0)) ;
1612 ERR (GrB_Matrix_extractElement_UINT32 (NULL, NULL, 0, 0)) ;
1613 ERR (GrB_Matrix_extractElement_INT64 (NULL, NULL, 0, 0)) ;
1614 ERR (GrB_Matrix_extractElement_UINT64 (NULL, NULL, 0, 0)) ;
1615 ERR (GrB_Matrix_extractElement_FP32 (NULL, NULL, 0, 0)) ;
1616 ERR (GrB_Matrix_extractElement_FP64 (NULL, NULL, 0, 0)) ;
1617 ERR (GrB_Matrix_extractElement_UDT (NULL, NULL, 0, 0)) ;
1618
1619 ERR (GrB_Matrix_extractElement_BOOL (NULL, A, 0, 0)) ;
1620 ERR (GrB_Matrix_extractElement_INT8 (NULL, A, 0, 0)) ;
1621 ERR (GrB_Matrix_extractElement_UINT8 (NULL, A, 0, 0)) ;
1622 ERR (GrB_Matrix_extractElement_INT16 (NULL, A, 0, 0)) ;
1623 ERR (GrB_Matrix_extractElement_UINT16 (NULL, A, 0, 0)) ;
1624 ERR (GrB_Matrix_extractElement_INT32 (NULL, A, 0, 0)) ;
1625 ERR (GrB_Matrix_extractElement_UINT32 (NULL, A, 0, 0)) ;
1626 ERR (GrB_Matrix_extractElement_INT64 (NULL, A, 0, 0)) ;
1627 ERR (GrB_Matrix_extractElement_UINT64 (NULL, A, 0, 0)) ;
1628 ERR (GrB_Matrix_extractElement_FP32 (NULL, A, 0, 0)) ;
1629 ERR (GrB_Matrix_extractElement_FP64 (NULL, A, 0, 0)) ;
1630 ERR (GrB_Matrix_extractElement_UDT (NULL, A, 0, 0)) ;
1631
1632 expected = GrB_UNINITIALIZED_OBJECT ;
1633
1634 ERR (GrB_Matrix_extractElement_BOOL (NULL, Agunk, 0, 0)) ;
1635 ERR (GrB_Matrix_extractElement_INT8 (NULL, Agunk, 0, 0)) ;
1636 ERR (GrB_Matrix_extractElement_UINT8 (NULL, Agunk, 0, 0)) ;
1637 ERR (GrB_Matrix_extractElement_INT16 (NULL, Agunk, 0, 0)) ;
1638 ERR (GrB_Matrix_extractElement_UINT16 (NULL, Agunk, 0, 0)) ;
1639 ERR (GrB_Matrix_extractElement_INT32 (NULL, Agunk, 0, 0)) ;
1640 ERR (GrB_Matrix_extractElement_UINT32 (NULL, Agunk, 0, 0)) ;
1641 ERR (GrB_Matrix_extractElement_INT64 (NULL, Agunk, 0, 0)) ;
1642 ERR (GrB_Matrix_extractElement_UINT64 (NULL, Agunk, 0, 0)) ;
1643 ERR (GrB_Matrix_extractElement_FP32 (NULL, Agunk, 0, 0)) ;
1644 ERR (GrB_Matrix_extractElement_FP64 (NULL, Agunk, 0, 0)) ;
1645 ERR (GrB_Matrix_extractElement_UDT (NULL, Agunk, 0, 0)) ;
1646
1647 expected = GrB_INVALID_INDEX ;
1648
1649 ERR (GrB_Matrix_extractElement_FP64_(&x_double, A, -1, 0)) ;
1650 ERR (GrB_Matrix_extractElement_FP64_(&x_double, A, 10, 0)) ;
1651 ERR (GrB_Matrix_extractElement_FP64_(&x_double, A, 0, 911)) ;
1652
1653 expected = GrB_DOMAIN_MISMATCH ;
1654
1655 ERR (GrB_Matrix_extractElement_UDT ((void *) X, A, 0, 0)) ;
1656
1657 OK (GrB_Matrix_setElement_FP64 (A, 22.8, 2, 0)) ;
1658 OK (GrB_Matrix_setElement_FP64 (A, 44.9, 4, 0)) ;
1659
1660 x_double = 404 ;
1661 OK (GrB_Matrix_extractElement_FP64_(&x_double, A, 3, 0)) ;
1662 CHECK (x_double == 404) ;
1663 CHECK (info == GrB_NO_VALUE) ;
1664
1665 OK (GrB_Matrix_setElement_FP64 (A, 707.3, 0, 0)) ;
1666
1667 OK (GrB_Matrix_extractElement_FP64_(&x_double, A, 0, 0)) ;
1668
1669 CHECK (info == GrB_SUCCESS) ;
1670 CHECK (x_double == 707.3) ;
1671
1672 OK (GrB_Matrix_nvals (&n2, A)) ;
1673 OK (GrB_Matrix_wait_(&A)) ;
1674 fprintf (f, "nvals: %d\n", (int) n2) ;
1675
1676 // A is now a valid FP64 matrix with 3 entries
1677
1678 //--------------------------------------------------------------------------
1679 // Matrix extractTuples
1680 //--------------------------------------------------------------------------
1681
1682 printf ("GrB_Matrix_extractTuples-------------------------------------\n") ;
1683 expected = GrB_NULL_POINTER ;
1684 OK (GrB_Matrix_nvals (&n2, A)) ;
1685 nvals = n2 ;
1686
1687 ERR (GrB_Matrix_extractTuples_BOOL (NULL, NULL, NULL, NULL, A)) ;
1688 ERR (GrB_Matrix_extractTuples_INT8 (NULL, NULL, NULL, NULL, A)) ;
1689 ERR (GrB_Matrix_extractTuples_UINT8 (NULL, NULL, NULL, NULL, A)) ;
1690 ERR (GrB_Matrix_extractTuples_INT16 (NULL, NULL, NULL, NULL, A)) ;
1691 ERR (GrB_Matrix_extractTuples_UINT16 (NULL, NULL, NULL, NULL, A)) ;
1692 ERR (GrB_Matrix_extractTuples_INT32 (NULL, NULL, NULL, NULL, A)) ;
1693 ERR (GrB_Matrix_extractTuples_UINT32 (NULL, NULL, NULL, NULL, A)) ;
1694 ERR (GrB_Matrix_extractTuples_INT64 (NULL, NULL, NULL, NULL, A)) ;
1695 ERR (GrB_Matrix_extractTuples_UINT64 (NULL, NULL, NULL, NULL, A)) ;
1696 ERR (GrB_Matrix_extractTuples_FP32 (NULL, NULL, NULL, NULL, A)) ;
1697 ERR (GrB_Matrix_extractTuples_FP64 (NULL, NULL, NULL, NULL, A)) ;
1698 ERR (GrB_Matrix_extractTuples_UDT (NULL, NULL, NULL, NULL, A)) ;
1699
1700 ERR (GrB_Matrix_extractTuples_BOOL (NULL, NULL, NULL, &nvals, NULL)) ;
1701 ERR (GrB_Matrix_extractTuples_INT8 (NULL, NULL, NULL, &nvals, NULL)) ;
1702 ERR (GrB_Matrix_extractTuples_UINT8 (NULL, NULL, NULL, &nvals, NULL)) ;
1703 ERR (GrB_Matrix_extractTuples_INT16 (NULL, NULL, NULL, &nvals, NULL)) ;
1704 ERR (GrB_Matrix_extractTuples_UINT16 (NULL, NULL, NULL, &nvals, NULL)) ;
1705 ERR (GrB_Matrix_extractTuples_INT32 (NULL, NULL, NULL, &nvals, NULL)) ;
1706 ERR (GrB_Matrix_extractTuples_UINT32 (NULL, NULL, NULL, &nvals, NULL)) ;
1707 ERR (GrB_Matrix_extractTuples_INT64 (NULL, NULL, NULL, &nvals, NULL)) ;
1708 ERR (GrB_Matrix_extractTuples_UINT64 (NULL, NULL, NULL, &nvals, NULL)) ;
1709 ERR (GrB_Matrix_extractTuples_FP32 (NULL, NULL, NULL, &nvals, NULL)) ;
1710 ERR (GrB_Matrix_extractTuples_FP64 (NULL, NULL, NULL, &nvals, NULL)) ;
1711 ERR (GrB_Matrix_extractTuples_UDT (NULL, NULL, NULL, &nvals, NULL)) ;
1712
1713 expected = GrB_UNINITIALIZED_OBJECT ;
1714
1715 ERR (GrB_Matrix_extractTuples_BOOL (NULL, NULL, NULL, &nvals, Agunk)) ;
1716 ERR (GrB_Matrix_extractTuples_INT8 (NULL, NULL, NULL, &nvals, Agunk)) ;
1717 ERR (GrB_Matrix_extractTuples_UINT8 (NULL, NULL, NULL, &nvals, Agunk)) ;
1718 ERR (GrB_Matrix_extractTuples_INT16 (NULL, NULL, NULL, &nvals, Agunk)) ;
1719 ERR (GrB_Matrix_extractTuples_UINT16 (NULL, NULL, NULL, &nvals, Agunk)) ;
1720 ERR (GrB_Matrix_extractTuples_INT32 (NULL, NULL, NULL, &nvals, Agunk)) ;
1721 ERR (GrB_Matrix_extractTuples_UINT32 (NULL, NULL, NULL, &nvals, Agunk)) ;
1722 ERR (GrB_Matrix_extractTuples_INT64 (NULL, NULL, NULL, &nvals, Agunk)) ;
1723 ERR (GrB_Matrix_extractTuples_UINT64 (NULL, NULL, NULL, &nvals, Agunk)) ;
1724 ERR (GrB_Matrix_extractTuples_FP32 (NULL, NULL, NULL, &nvals, Agunk)) ;
1725 ERR (GrB_Matrix_extractTuples_FP64 (NULL, NULL, NULL, &nvals, Agunk)) ;
1726 ERR (GrB_Matrix_extractTuples_UDT (NULL, NULL, NULL, &nvals, Agunk)) ;
1727
1728 expected = GrB_INSUFFICIENT_SPACE ;
1729
1730 nvals = n2-1 ;
1731 ERR (GrB_Matrix_extractTuples_FP64_(I2, J2, X2, &nvals, A)) ;
1732 nvals = n2 ;
1733 OK (GrB_Matrix_extractTuples_FP64_(I2, J2, X2, &nvals, A)) ;
1734
1735 for (int k = 0 ; k < n2 ; k++)
1736 {
1737 fprintf (f, "%d: A("GBu","GBu") = %g\n", k, I2 [k], J2 [k], X2 [k]) ;
1738 }
1739 fprintf (f, "\n") ;
1740
1741 expected = GrB_DOMAIN_MISMATCH ;
1742
1743 nvals = n2 ;
1744 ERR (GrB_Matrix_extractTuples_UDT_(I2, J2, (void *) X2, &nvals, A)) ;
1745
1746 GrB_Matrix_free_(&A) ;
1747 CHECK (A == NULL) ;
1748
1749 // The following are now allocated; keep them for the rest the tests:
1750 // Agunk, Tgunk, op1gunk, op2gunk, monoid_gunk, semigunk, Aempty, vempty
1751
1752 //--------------------------------------------------------------------------
1753 // Descriptor
1754 //--------------------------------------------------------------------------
1755
1756 printf ("GrB_Descriptor-----------------------------------------------\n") ;
1757 expected = GrB_NULL_POINTER ;
1758
1759 ERR (GrB_Descriptor_new (NULL)) ;
1760
1761 OK (GrB_Descriptor_new (&dgunk)) ;
1762 CHECK (dgunk != NULL) ;
1763 dgunk->magic = 22309483 ;
1764
1765 GrB_Descriptor dnull = NULL ;
1766
1767 ERRD (dnull, GxB_Desc_set (dnull, 0, 0)) ;
1768 ERR (GxB_Desc_get (dnull, 0, NULL)) ;
1769
1770 ERRD (dnull, GrB_Descriptor_set (dnull, 0, 0)) ;
1771 ERR (GxB_Descriptor_get (NULL, dnull, 0)) ;
1772
1773 expected = GrB_UNINITIALIZED_OBJECT ;
1774
1775 ERRD (dgunk, GxB_Desc_set (dgunk, 0, 0)) ;
1776 ERR (GxB_Desc_get (dgunk, 0, &dval)) ;
1777
1778 ERRD (dgunk, GrB_Descriptor_set (dgunk, 0, 0)) ;
1779 ERR (GxB_Descriptor_get (&dval, dgunk, 0)) ;
1780
1781 OK (GxB_Desc_get (dnull, 0, &dval)) ;
1782 CHECK (dval == GxB_DEFAULT) ;
1783
1784 OK (GxB_Descriptor_get (&dval, dnull, 0)) ;
1785 CHECK (dval == GxB_DEFAULT) ;
1786
1787 OK (GrB_Descriptor_new (&desc)) ;
1788
1789 expected = GrB_INVALID_VALUE ;
1790
1791 ERR (GxB_Desc_get (desc, -1, &dval)) ;
1792 ERRD (desc, GxB_Desc_set (desc, -1, 0)) ;
1793
1794 ERR (GxB_Descriptor_get (&dval, desc, -1)) ;
1795 ERRD (desc, GrB_Descriptor_set (desc, -1, 0)) ;
1796
1797 ERRD (desc, GxB_Desc_set (desc, GrB_OUTP, -1)) ;
1798 GrB_Descriptor_error_(&err, desc) ;
1799 CHECK (err != NULL) ;
1800 printf ("%s\n", err) ;
1801 ERRD (desc, GxB_Desc_set (desc, GrB_MASK, -1)) ;
1802 GrB_Descriptor_error_(&err, desc) ;
1803 CHECK (err != NULL) ;
1804 printf ("%s\n", err) ;
1805 ERRD (desc, GxB_Desc_set (desc, GrB_INP0, -1)) ;
1806 GrB_Descriptor_error_(&err, desc) ;
1807 CHECK (err != NULL) ;
1808 printf ("%s\n", err) ;
1809 ERRD (desc, GxB_Desc_set (desc, GrB_INP1, -1)) ;
1810 GrB_Descriptor_error_(&err, desc) ;
1811 CHECK (err != NULL) ;
1812 printf ("%s\n", err) ;
1813 ERRD (desc, GrB_Descriptor_set (desc, GxB_AxB_METHOD, -1)) ;
1814 GrB_Descriptor_error_(&err, desc) ;
1815 CHECK (err != NULL) ;
1816 printf ("%s\n", err) ;
1817
1818 ERRD (desc, GrB_Descriptor_set (desc, GrB_OUTP, -1)) ;
1819 GrB_Descriptor_error_(&err, desc) ;
1820 CHECK (err != NULL) ;
1821 printf ("%s\n", err) ;
1822 ERRD (desc, GrB_Descriptor_set (desc, GrB_MASK, -1)) ;
1823 GrB_Descriptor_error_(&err, desc) ;
1824 CHECK (err != NULL) ;
1825 printf ("%s\n", err) ;
1826 ERRD (desc, GrB_Descriptor_set (desc, GrB_INP0, -1)) ;
1827 GrB_Descriptor_error_(&err, desc) ;
1828 CHECK (err != NULL) ;
1829 printf ("%s\n", err) ;
1830 ERRD (desc, GrB_Descriptor_set (desc, GrB_INP1, -1)) ;
1831 GrB_Descriptor_error_(&err, desc) ;
1832 CHECK (err != NULL) ;
1833 printf ("%s\n", err) ;
1834 ERRD (desc, GrB_Descriptor_set (desc, GxB_AxB_METHOD, -1)) ;
1835 GrB_Descriptor_error_(&err, desc) ;
1836 CHECK (err != NULL) ;
1837 printf ("%s\n", err) ;
1838
1839 OK (GxB_Desc_get (desc, GrB_OUTP, &dval)) ;
1840 CHECK (dval == GxB_DEFAULT) ;
1841 OK (GxB_Desc_get (desc, GrB_MASK, &dval)) ;
1842 CHECK (dval == GxB_DEFAULT) ;
1843 OK (GxB_Desc_get (desc, GrB_INP0, &dval)) ;
1844 CHECK (dval == GxB_DEFAULT) ;
1845 OK (GxB_Desc_get (desc, GrB_INP1, &dval)) ;
1846 CHECK (dval == GxB_DEFAULT) ;
1847
1848 OK (GxB_Descriptor_get (&dval, desc, GrB_OUTP)) ;
1849 CHECK (dval == GxB_DEFAULT) ;
1850 OK (GxB_Descriptor_get (&dval, desc, GrB_MASK)) ;
1851 CHECK (dval == GxB_DEFAULT) ;
1852 OK (GxB_Descriptor_get (&dval, desc, GrB_INP0)) ;
1853 CHECK (dval == GxB_DEFAULT) ;
1854 OK (GxB_Descriptor_get (&dval, desc, GrB_INP1)) ;
1855 CHECK (dval == GxB_DEFAULT) ;
1856
1857 // The following are now allocated; keep them for the rest the tests:
1858 // Agunk, Tgunk, op1gunk, op2gunk, monoid_gunk, semigunk, Aempty, vempty,
1859 // desc, dgunk
1860
1861 #define FREE_DEEP_COPY ;
1862 #define GET_DEEP_COPY ;
1863
1864 GrB_Descriptor d7 ;
1865 METHOD (GrB_Descriptor_new (&d7)) ;
1866 OK (GB_Descriptor_check (d7, "new descriptor", G3, NULL)) ;
1867 OK (GxB_Descriptor_fprint (d7, "new descriptor", G3, ff)) ;
1868 OK (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1869
1870 #undef FREE_DEEP_COPY
1871 #undef GET_DEEP_COPY
1872
1873 OK (GxB_Desc_set (d7, GxB_AxB_METHOD, GxB_DEFAULT)) ;
1874 OK (GB_Descriptor_check (d7, "new descriptor (default)", G3, NULL)) ;
1875 OK (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1876
1877 OK (GxB_Desc_set (d7, GxB_AxB_METHOD, GxB_AxB_DOT)) ;
1878 OK (GB_Descriptor_check (d7, "new descriptor (dot)", G3, NULL)) ;
1879 OK (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1880 OK (GxB_Descriptor_get (&dval, d7, GxB_AxB_METHOD)) ;
1881 CHECK (dval == GxB_AxB_DOT) ;
1882
1883 OK (GxB_Desc_set (d7, GxB_AxB_METHOD, GxB_AxB_GUSTAVSON)) ;
1884 OK (GB_Descriptor_check (d7, "new descriptor (Gustavson)", G3, NULL)) ;
1885 OK (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1886
1887 expected = GrB_INVALID_VALUE ;
1888 ERRD (d7, GxB_Desc_set (d7, GxB_AxB_METHOD, 911911)) ;
1889 OK (GB_Descriptor_check (d7, "new descriptor (still Gustavson)", G3, NULL));
1890 OK (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1891
1892 expected = GrB_INVALID_OBJECT ;
1893
1894 d7->axb = 99 ;
1895 ERR (GB_Descriptor_check (d7, "invalid", G3, NULL)) ;
1896 ERR (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1897 d7->axb = GxB_DEFAULT ;
1898
1899 d7->out = 99 ;
1900 ERR (GB_Descriptor_check (d7, "invalid", G3, NULL)) ;
1901 ERR (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1902 d7->out = GxB_DEFAULT ;
1903
1904 d7->out = GxB_AxB_HASH ;
1905 ERR (GB_Descriptor_check (d7, "invalid", G3, NULL)) ;
1906 ERR (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1907 d7->out = GxB_DEFAULT ;
1908
1909 d7->axb = GrB_TRAN ;
1910 ERR (GB_Descriptor_check (d7, "invalid", G3, NULL)) ;
1911 ERR (GxB_Descriptor_fprint (d7, "d7", G3, ff)) ;
1912 d7->out = GxB_DEFAULT ;
1913
1914 OK (GrB_Descriptor_free_(&d7)) ;
1915 CHECK (d7 == NULL) ;
1916
1917 //--------------------------------------------------------------------------
1918 // create some valid matrices and vectors
1919 //--------------------------------------------------------------------------
1920
1921 printf ("create test matrices-----------------------------------------\n") ;
1922
1923 OK (random_matrix (&A, false, false, 3, 4, 12, 0, false)) ;
1924 OK (random_matrix (&B, false, false, 4, 2, 6, 0, false)) ;
1925 OK (random_matrix (&C, false, false, 3, 2, 4, 0, false)) ;
1926 OK (random_matrix (&E, false, false, 3, 2, 4, 0, false)) ;
1927 OK (random_matrix (&F, false, false, 3, 2, 4, 0, false)) ;
1928 OK (random_matrix (&Z, false, false, 3, 2, 8, 0, true)) ; // Z complex
1929
1930 OK (GrB_Matrix_wait_(&A)) ;
1931 OK (GrB_Matrix_wait_(&B)) ;
1932 OK (GrB_Matrix_wait_(&C)) ;
1933 OK (GrB_Matrix_wait_(&E)) ;
1934 OK (GrB_Matrix_wait_(&F)) ;
1935 OK (GrB_Matrix_wait_(&Z)) ;
1936
1937 OK (GrB_Vector_new (&v, GrB_FP64, 5)) ;
1938 OK (GrB_Vector_new (&u, GrB_FP64, 5)) ;
1939 OK (GrB_Vector_wait_(&v)) ;
1940 OK (GrB_Vector_wait_(&u)) ;
1941
1942 printf ("complex vector:\n") ;
1943 OK (GrB_Vector_new (&z, Complex, 5)) ;
1944
1945 OK (GrB_Descriptor_new (&dnt)) ;
1946 OK (GxB_Desc_set (dnt, GrB_INP1, GrB_TRAN)) ;
1947 OK (GrB_Descriptor_wait_(&dnt)) ;
1948
1949 OK (GrB_Descriptor_new (&dtn)) ;
1950 OK (GxB_Desc_set (dtn, GrB_INP0, GrB_TRAN)) ;
1951 OK (GrB_Descriptor_wait_(&dtn)) ;
1952
1953 OK (GrB_Descriptor_new (&dtt)) ;
1954 OK (GxB_Desc_set (dtt, GrB_INP0, GrB_TRAN)) ;
1955 OK (GxB_Desc_set (dtt, GrB_INP1, GrB_TRAN)) ;
1956 OK (GrB_Descriptor_wait_(&dtt)) ;
1957
1958 //--------------------------------------------------------------------------
1959 // GrB_mxm, mxv, and vxm
1960 //--------------------------------------------------------------------------
1961
1962 printf ("GrB_mxm------------------------------------------------------\n") ;
1963 s2 = GxB_MAX_PLUS_FP32 ;
1964 o2 = GrB_MAX_FP32 ;
1965
1966 expected = GrB_UNINITIALIZED_OBJECT ;
1967
1968 ERR1 (Agunk, GrB_mxm (Agunk, NULL , NULL , NULL , NULL , NULL , NULL )) ;
1969 ERR1 (C, GrB_mxm (C , Agunk, NULL , NULL , NULL , NULL , NULL )) ;
1970 ERR1 (C, GrB_mxm (C , C , NULL , NULL , Agunk, NULL , NULL )) ;
1971 ERR1 (C, GrB_mxm (C , C , NULL , NULL , A , Agunk, NULL )) ;
1972 ERR1 (C, GrB_mxm (C , C , NULL , NULL , A , A , dgunk)) ;
1973 ERR1 (C, GrB_mxm (C , C , op2gunk, NULL , A , A , NULL )) ;
1974 ERR1 (C, GrB_mxm (C , C , o2 , semigunk, A , A , NULL )) ;
1975
1976 ERR1 (vgunk, GrB_vxm (vgunk, NULL , NULL , NULL , NULL , NULL , NULL )) ;
1977 ERR1 (v, GrB_vxm (v , vgunk, NULL , NULL , NULL , NULL , NULL )) ;
1978 ERR1 (v, GrB_vxm (v , v , NULL , NULL , vgunk, NULL , NULL )) ;
1979 ERR1 (v, GrB_vxm (v , v , NULL , NULL , v , Agunk, NULL )) ;
1980 ERR1 (v, GrB_vxm (v , v , NULL , NULL , v , A , dgunk)) ;
1981 ERR1 (v, GrB_vxm (v , v , op2gunk, NULL , v , A , NULL )) ;
1982 ERR1 (v, GrB_vxm (v , v , o2 , semigunk, v , A , NULL )) ;
1983
1984 ERR1 (vgunk, GrB_mxv (vgunk, NULL , NULL , NULL , NULL , NULL , NULL )) ;
1985 ERR1 (v, GrB_mxv (v , vgunk, NULL , NULL , NULL , NULL , NULL )) ;
1986 ERR1 (v, GrB_mxv (v , v , NULL , NULL , Agunk, NULL , NULL )) ;
1987 ERR1 (v, GrB_mxv (v , v , NULL , NULL , A , vgunk, NULL )) ;
1988 ERR1 (v, GrB_mxv (v , v , NULL , NULL , A , v , dgunk)) ;
1989 ERR1 (v, GrB_mxv (v , v , op2gunk, NULL , A , v , NULL )) ;
1990 ERR1 (v, GrB_mxv (v , v , o2 , semigunk, A , v , NULL )) ;
1991
1992 expected = GrB_NULL_POINTER ;
1993
1994 ERR (GrB_mxm (NULL , NULL , NULL , NULL , NULL , NULL , NULL )) ;
1995 ERR1 (C, GrB_mxm (C , NULL , NULL , NULL , NULL , NULL , NULL )) ;
1996 ERR1 (C, GrB_mxm (C , NULL , NULL , NULL , A , NULL , NULL )) ;
1997 ERR1 (C, GrB_mxm (C , NULL , o2 , NULL , A , A , NULL )) ;
1998
1999 ERR (GrB_vxm (NULL , NULL , NULL , NULL , NULL , NULL , NULL )) ;
2000 ERR1 (v, GrB_vxm (v , v , NULL , NULL , NULL , NULL , NULL )) ;
2001 ERR1 (v, GrB_vxm (v , v , NULL , NULL , v , NULL , NULL )) ;
2002 ERR1 (v, GrB_vxm (v , v , o2 , NULL , v , A , NULL )) ;
2003
2004 ERR (GrB_mxv (NULL , NULL , NULL , NULL , NULL , NULL , NULL )) ;
2005 ERR1 (v, GrB_mxv (v , v , NULL , NULL , NULL , NULL , NULL )) ;
2006 ERR1 (v, GrB_mxv (v , v , NULL , NULL , A , NULL , NULL )) ;
2007 ERR1 (v, GrB_mxv (v , v , o2 , NULL , A , v , NULL )) ;
2008
2009 expected = GrB_DIMENSION_MISMATCH ;
2010
2011 ERR1 (C, GrB_mxm (C , NULL, NULL, s2 , B , A , NULL)) ;
2012 ERR1 (C, GrB_mxm (C , A , NULL, s2 , A , B , NULL)) ;
2013
2014 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2015 ERR1 (C, GrB_mxm (C, NULL, NULL, s2, Z, B, NULL)) ;
2016 ERR1 (C, GrB_mxm (C, NULL, NULL, s2, B, Z, NULL)) ;
2017 if (Complex == GxB_FC64)
2018 {
2019 OK (GrB_mxm (C, NULL, NULL, Complex_plus_times, A, B, NULL)) ;
2020 OK (GrB_mxm (Z, NULL, NULL, s2, A, B, NULL)) ;
2021 OK (GrB_mxm (C, Z , NULL, s2, A, B, NULL)) ;
2022 }
2023 else
2024 {
2025 ERR1 (C, GrB_mxm (C, NULL, NULL, Complex_plus_times, A, B, NULL)) ;
2026 ERR1 (Z, GrB_mxm (Z, NULL, NULL, s2, A, B, NULL)) ;
2027 ERR1 (C, GrB_mxm (C, Z , NULL, s2, A, B, NULL)) ;
2028 }
2029
2030 GrB_Matrix_error_(&err, C) ;
2031 printf ("last error was [%s]\n", err) ;
2032 OK (GrB_mxm (C, NULL, o2 , s2, A, B, NULL)) ;
2033
2034 // The following are now allocated; keep them for the rest the tests:
2035 // Agunk, Tgunk, op1gunk, op2gunk, monoid_gunk, semigunk, Aempty, vempty,
2036 // desc, dgunk, A, B, C, E, F, Z, v, u
2037
2038 //--------------------------------------------------------------------------
2039 // GrB_mxm dot product
2040 //--------------------------------------------------------------------------
2041
2042 GrB_Index huge = GxB_INDEX_MAX ;
2043 GrB_Matrix HugeRow ;
2044 OK (GrB_Matrix_new (&HugeRow, GrB_FP64, 1, huge)) ;
2045 GB_Matrix_check (HugeRow, "huge row", G3, NULL) ;
2046 GxB_Matrix_fprint (HugeRow, "HugeRow", G3, ff) ;
2047
2048 struct GB_Matrix_opaque HugeMatrix_header ;
2049 GrB_Matrix HugeMatrix = GB_clear_static_header (&HugeMatrix_header) ;
2050
2051 OK (GB_AxB_dot2 (HugeMatrix, NULL, false, false, HugeRow, HugeRow,
2052 GxB_PLUS_TIMES_FP64, false, Context)) ;
2053
2054 GxB_Matrix_fprint (HugeMatrix, "HugeMatrix", G3, ff) ;
2055 GrB_Matrix_free_(&HugeMatrix) ;
2056 GrB_Matrix_free_(&HugeRow) ;
2057
2058 //--------------------------------------------------------------------------
2059 // eWiseMult and eWiseAdd
2060 //--------------------------------------------------------------------------
2061
2062 printf ("GrB_eWise ---------------------------------------------------\n") ;
2063
2064 m2 = GxB_MIN_FP64_MONOID ;
2065 s2 = GxB_PLUS_ISEQ_FP32 ;
2066
2067 expected = GrB_NULL_POINTER ;
2068
2069 ERR1 (v0, GrB_Vector_eWiseMult_Semiring_(v0, NULL, NULL, s0 , v0, v0, d0)) ; // vector semiring
2070 ERR1 (v0, GrB_Vector_eWiseMult_Semiring_(v0, NULL, NULL, s2 , v0, v0, d0)) ;
2071 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , NULL, NULL, s2 , v0, v0, d0)) ;
2072 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , NULL, NULL, s2 , v , v0, d0)) ;
2073
2074 ERR1 (v0, GrB_Vector_eWiseMult_Monoid_(v0, NULL, NULL, m0 , v0, v0, d0)) ; // vector monoid
2075 ERR1 (v0, GrB_Vector_eWiseMult_Monoid_(v0, NULL, NULL, m2 , v0, v0, d0)) ;
2076 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , NULL, NULL, m2 , v0, v0, d0)) ;
2077 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , NULL, NULL, m2 , v , v0, d0)) ;
2078
2079 ERR1 (v0, GrB_Vector_eWiseMult_BinaryOp_(v0, NULL, NULL, op0, v0, v0, d0)) ; // vector op
2080 ERR1 (v0, GrB_Vector_eWiseMult_BinaryOp_(v0, NULL, NULL, o2 , v0, v0, d0)) ;
2081 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , NULL, NULL, o2 , v0, v0, d0)) ;
2082 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , NULL, NULL, o2 , v , v0, d0)) ;
2083
2084 ERR1 (A0, GrB_Matrix_eWiseMult_Semiring_(A0, NULL, NULL, s0 , A0, A0, d0)) ; // matrix semiring
2085 ERR1 (A0, GrB_Matrix_eWiseMult_Semiring_(A0, NULL, NULL, s2 , A0, A0, d0)) ;
2086 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , NULL, NULL, s2 , A0, A0, d0)) ;
2087 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , NULL, NULL, s2 , A , A0, d0)) ;
2088
2089 ERR1 (A0, GrB_Matrix_eWiseMult_Monoid_(A0, NULL, NULL, m0 , A0, A0, d0)) ; // matrix monoid
2090 ERR1 (A0, GrB_Matrix_eWiseMult_Monoid_(A0, NULL, NULL, m2 , A0, A0, d0)) ;
2091 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , NULL, NULL, m2 , A0, A0, d0)) ;
2092 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , NULL, NULL, m2 , A , A0, d0)) ;
2093
2094 ERR1 (A0, GrB_Matrix_eWiseMult_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2095 ERR1 (A0, GrB_Matrix_eWiseMult_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2096 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2097 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2098
2099 ERR1 (v0, GrB_Vector_eWiseAdd_Semiring_(v0, NULL, NULL, s0 , v0, v0, d0)) ; // vector semiring
2100 ERR1 (v0, GrB_Vector_eWiseAdd_Semiring_(v0, NULL, NULL, s2 , v0, v0, d0)) ;
2101 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , NULL, NULL, s2 , v0, v0, d0)) ;
2102 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , NULL, NULL, s2 , v , v0, d0)) ;
2103
2104 ERR1 (v0, GrB_Vector_eWiseAdd_Monoid_(v0, NULL, NULL, m0 , v0, v0, d0)) ; // vector monoid
2105 ERR1 (v0, GrB_Vector_eWiseAdd_Monoid_(v0, NULL, NULL, m2 , v0, v0, d0)) ;
2106 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , NULL, NULL, m2 , v0, v0, d0)) ;
2107 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , NULL, NULL, m2 , v , v0, d0)) ;
2108
2109 ERR1 (v0, GrB_Vector_eWiseAdd_BinaryOp_(v0, NULL, NULL, op0, v0, v0, d0)) ; // vector op
2110 ERR1 (v0, GrB_Vector_eWiseAdd_BinaryOp_(v0, NULL, NULL, o2 , v0, v0, d0)) ;
2111 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , NULL, NULL, o2 , v0, v0, d0)) ;
2112 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , NULL, NULL, o2 , v , v0, d0)) ;
2113
2114 ERR1 (A0, GrB_Matrix_eWiseAdd_Semiring_(A0, NULL, NULL, s0 , A0, A0, d0)) ; // matrix semiring
2115 ERR1 (A0, GrB_Matrix_eWiseAdd_Semiring_(A0, NULL, NULL, s2 , A0, A0, d0)) ;
2116 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , NULL, NULL, s2 , A0, A0, d0)) ;
2117 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , NULL, NULL, s2 , A , A0, d0)) ;
2118
2119 ERR1 (A0, GrB_Matrix_eWiseAdd_Monoid_(A0, NULL, NULL, m0 , A0, A0, d0)) ; // matrix monoid
2120 ERR1 (A0, GrB_Matrix_eWiseAdd_Monoid_(A0, NULL, NULL, m2 , A0, A0, d0)) ;
2121 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , NULL, NULL, m2 , A0, A0, d0)) ;
2122 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , NULL, NULL, m2 , A , A0, d0)) ;
2123
2124 ERR1 (A0, GrB_Matrix_eWiseAdd_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2125 ERR1 (A0, GrB_Matrix_eWiseAdd_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2126 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2127 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2128
2129 expected = GrB_UNINITIALIZED_OBJECT ;
2130
2131 m0 = monoid_gunk ;
2132 s0 = semigunk ;
2133 v0 = vgunk ;
2134 A0 = Agunk ;
2135 op0 = op2gunk ;
2136
2137 ERR1 (v0, GrB_Vector_eWiseMult_Semiring_(v0, NULL, NULL, s0 , v0, v0, d0)) ; // vector semiring
2138 ERR1 (v0, GrB_Vector_eWiseMult_Semiring_(v0, NULL, NULL, s2 , v0, v0, d0)) ;
2139 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , NULL, NULL, s2 , v0, v0, d0)) ;
2140 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , NULL, NULL, s2 , v , v0, d0)) ;
2141 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , v0 , NULL, s2 , v , v , d0)) ;
2142 ERR1 (v, GrB_Vector_eWiseMult_Semiring_(v , NULL, op0 , s2 , v , v , NULL)) ;
2143
2144 ERR1 (v0, GrB_Vector_eWiseMult_Monoid_(v0, NULL, NULL, m0 , v0, v0, d0)) ; // vector monoid
2145 ERR1 (v0, GrB_Vector_eWiseMult_Monoid_(v0, NULL, NULL, m2 , v0, v0, d0)) ;
2146 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , NULL, NULL, m2 , v0, v0, d0)) ;
2147 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , NULL, NULL, m2 , v , v0, d0)) ;
2148 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , v0 , NULL, m2 , v , v , d0)) ;
2149 ERR1 (v, GrB_Vector_eWiseMult_Monoid_(v , NULL, op0 , m2 , v , v , NULL)) ;
2150
2151 ERR1 (v0, GrB_Vector_eWiseMult_BinaryOp_(v0, NULL, NULL, op0, v0, v0, d0)) ; // vector op
2152 ERR1 (v0, GrB_Vector_eWiseMult_BinaryOp_(v0, NULL, NULL, o2 , v0, v0, d0)) ;
2153 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , NULL, NULL, o2 , v0, v0, d0)) ;
2154 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , NULL, NULL, o2 , v , v0, d0)) ;
2155 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , v0 , NULL, o2 , v , v , d0)) ;
2156 ERR1 (v, GrB_Vector_eWiseMult_BinaryOp_(v , NULL, op0 , o2 , v , v , NULL)) ;
2157
2158 ERR1 (A0, GrB_Matrix_eWiseMult_Semiring_(A0, NULL, NULL, s0 , A0, A0, d0)) ; // matrix semiring
2159 ERR1 (A0, GrB_Matrix_eWiseMult_Semiring_(A0, NULL, NULL, s2 , A0, A0, d0)) ;
2160 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , NULL, NULL, s2 , A0, A0, d0)) ;
2161 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , NULL, NULL, s2 , A , A0, d0)) ;
2162 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , A0 , NULL, s2 , A , A , d0)) ;
2163 ERR1 (A, GrB_Matrix_eWiseMult_Semiring_(A , NULL, op0 , s2 , A , A , NULL)) ;
2164
2165 ERR1 (A0, GrB_Matrix_eWiseMult_Monoid_(A0, NULL, NULL, m0 , A0, A0, d0)) ; // matrix monoid
2166 ERR1 (A0, GrB_Matrix_eWiseMult_Monoid_(A0, NULL, NULL, m2 , A0, A0, d0)) ;
2167 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , NULL, NULL, m2 , A0, A0, d0)) ;
2168 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , NULL, NULL, m2 , A , A0, d0)) ;
2169 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , A0 , NULL, m2 , A , A , d0)) ;
2170 ERR1 (A, GrB_Matrix_eWiseMult_Monoid_(A , NULL, op0 , m2 , A , A , NULL)) ;
2171
2172 ERR1 (A0, GrB_Matrix_eWiseMult_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2173 ERR1 (A0, GrB_Matrix_eWiseMult_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2174 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2175 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2176 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , A0 , NULL, o2 , A , A , d0)) ;
2177 ERR1 (A, GrB_Matrix_eWiseMult_BinaryOp_(A , NULL, op0 , o2 , A , A , NULL)) ;
2178
2179 ERR1 (v0, GrB_Vector_eWiseAdd_Semiring_(v0, NULL, NULL, s0 , v0, v0, d0)) ; // vector semiring
2180 ERR1 (v0, GrB_Vector_eWiseAdd_Semiring_(v0, NULL, NULL, s2 , v0, v0, d0)) ;
2181 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , NULL, NULL, s2 , v0, v0, d0)) ;
2182 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , NULL, NULL, s2 , v , v0, d0)) ;
2183 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , v0 , NULL, s2 , v , v , d0)) ;
2184 ERR1 (v, GrB_Vector_eWiseAdd_Semiring_(v , NULL, op0 , s2 , v , v , NULL)) ;
2185
2186 ERR1 (v0, GrB_Vector_eWiseAdd_Monoid_(v0, NULL, NULL, m0 , v0, v0, d0)) ; // vector monoid
2187 ERR1 (v0, GrB_Vector_eWiseAdd_Monoid_(v0, NULL, NULL, m2 , v0, v0, d0)) ;
2188 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , NULL, NULL, m2 , v0, v0, d0)) ;
2189 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , NULL, NULL, m2 , v , v0, d0)) ;
2190 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , v0 , NULL, m2 , v , v , d0)) ;
2191 ERR1 (v, GrB_Vector_eWiseAdd_Monoid_(v , NULL, op0 , m2 , v , v , NULL)) ;
2192
2193 ERR1 (v0, GrB_Vector_eWiseAdd_BinaryOp_(v0, NULL, NULL, op0, v0, v0, d0)) ; // vector op
2194 ERR1 (v0, GrB_Vector_eWiseAdd_BinaryOp_(v0, NULL, NULL, o2 , v0, v0, d0)) ;
2195 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , NULL, NULL, o2 , v0, v0, d0)) ;
2196 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , NULL, NULL, o2 , v , v0, d0)) ;
2197 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , v0 , NULL, o2 , v , v , d0)) ;
2198 ERR1 (v, GrB_Vector_eWiseAdd_BinaryOp_(v , NULL, op0 , o2 , v , v , NULL)) ;
2199
2200 ERR1 (A0, GrB_Matrix_eWiseAdd_Semiring_(A0, NULL, NULL, s0 , A0, A0, d0)) ; // matrix semiring
2201 ERR1 (A0, GrB_Matrix_eWiseAdd_Semiring_(A0, NULL, NULL, s2 , A0, A0, d0)) ;
2202 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , NULL, NULL, s2 , A0, A0, d0)) ;
2203 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , NULL, NULL, s2 , A , A0, d0)) ;
2204 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , A0 , NULL, s2 , A , A , d0)) ;
2205 ERR1 (A, GrB_Matrix_eWiseAdd_Semiring_(A , NULL, op0 , s2 , A , A , NULL)) ;
2206
2207 ERR1 (A0, GrB_Matrix_eWiseAdd_Monoid_(A0, NULL, NULL, m0 , A0, A0, d0)) ; // matrix monoid
2208 ERR1 (A0, GrB_Matrix_eWiseAdd_Monoid_(A0, NULL, NULL, m2 , A0, A0, d0)) ;
2209 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , NULL, NULL, m2 , A0, A0, d0)) ;
2210 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , NULL, NULL, m2 , A , A0, d0)) ;
2211 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , A0 , NULL, m2 , A , A , d0)) ;
2212 ERR1 (A, GrB_Matrix_eWiseAdd_Monoid_(A , NULL, op0 , m2 , A , A , NULL)) ;
2213
2214 ERR1 (A0, GrB_Matrix_eWiseAdd_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2215 ERR1 (A0, GrB_Matrix_eWiseAdd_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2216 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2217 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2218 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , A0 , NULL, o2 , A , A , d0)) ;
2219 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, op0 , o2 , A , A , NULL)) ;
2220
2221 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2222 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , Z , A , d0)) ;
2223 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, o2 , A , Z , d0)) ;
2224 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, Complex_plus, Z , A , d0)) ;
2225 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, Complex_plus, A , Z , d0)) ;
2226 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, NULL, Complex_plus, Z , Z , d0)) ;
2227 ERR1 (Z, GrB_Matrix_eWiseAdd_BinaryOp_(Z , NULL, NULL, Complex_complex, A , A , d0)) ;
2228
2229 if (Complex == GxB_FC64)
2230 {
2231 OK (GrB_Matrix_eWiseAdd_BinaryOp_(Z , Z , NULL, Complex_plus, Z , Z , d0)) ;
2232 }
2233 else
2234 {
2235 ERR1 (Z, GrB_Matrix_eWiseAdd_BinaryOp_(Z , Z , NULL, Complex_plus, Z , Z , d0)) ;
2236 }
2237
2238 OK (GrB_BinaryOp_new (&op3, f3, Complex, Complex, GrB_FP64)) ;
2239
2240 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2241 ERR1 (Z, GrB_Matrix_eWiseAdd_BinaryOp_(Z , NULL, NULL, op3, Z , A , d0)) ;
2242 ERR1 (Z, GrB_Matrix_eWiseAdd_BinaryOp_(Z , NULL, op3 , o2 , A , A , d0)) ;
2243
2244 if (Complex == GxB_FC64)
2245 {
2246 OK (GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, op3 , o2 , A , A , d0)) ;
2247 OK (GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, Complex_complex, o2 , A , A , d0)) ;
2248 }
2249 else
2250 {
2251 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, op3 , o2 , A , A , d0)) ;
2252 ERR1 (A, GrB_Matrix_eWiseAdd_BinaryOp_(A , NULL, Complex_complex, o2 , A , A , d0)) ;
2253 }
2254
2255 expected = GrB_DIMENSION_MISMATCH ;
2256
2257 ERR1 (C, GrB_Matrix_eWiseAdd_BinaryOp_(C , NULL, NULL, o2 , A , B , d0)) ;
2258 ERR1 (C, GrB_Matrix_eWiseAdd_BinaryOp_(C , NULL, NULL, o2 , A , B , dtn)) ;
2259 ERR1 (C, GrB_Matrix_eWiseAdd_BinaryOp_(C , NULL, NULL, o2 , A , B , dnt)) ;
2260 ERR1 (C, GrB_Matrix_eWiseAdd_BinaryOp_(C , NULL, NULL, o2 , A , B , dtt)) ;
2261
2262 // The following are now allocated; keep them for the rest the tests:
2263 // Agunk, Tgunk, op1gunk, op2gunk, monoid_gunk, semigunk, Aempty, vempty,
2264 // desc, dgunk, A, B, C, E, F, Z, v, u, dnt, dtn, dtt
2265
2266 //--------------------------------------------------------------------------
2267 // GrB_kronecker
2268 //--------------------------------------------------------------------------
2269
2270 printf ("GrB_kronecker -----------------------------------------------\n") ;
2271
2272 m2 = GxB_MIN_FP64_MONOID ;
2273 s2 = GxB_PLUS_ISEQ_FP32 ;
2274
2275 m0 = NULL ;
2276 s0 = NULL ;
2277 v0 = NULL ;
2278 A0 = NULL ;
2279 op0 = NULL ;
2280
2281 expected = GrB_NULL_POINTER ;
2282
2283 info = (GrB_Matrix_kronecker_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2284 ERR1 (A0, GrB_Matrix_kronecker_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2285 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2286 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2287
2288 expected = GrB_UNINITIALIZED_OBJECT ;
2289
2290 m0 = monoid_gunk ;
2291 s0 = semigunk ;
2292 v0 = vgunk ;
2293 A0 = Agunk ;
2294 op0 = op2gunk ;
2295
2296 ERR1 (A0, GrB_Matrix_kronecker_BinaryOp_(A0, NULL, NULL, op0, A0, A0, d0)) ; // matrix op
2297 ERR1 (A0, GrB_Matrix_kronecker_BinaryOp_(A0, NULL, NULL, o2 , A0, A0, d0)) ;
2298 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , NULL, NULL, o2 , A0, A0, d0)) ;
2299 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , NULL, NULL, o2 , A , A0, d0)) ;
2300 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , A0 , NULL, o2 , A , A , d0)) ;
2301 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_(A , NULL, op0 , o2 , A , A , NULL)) ;
2302
2303 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2304
2305 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_ (A , NULL, NULL, o2 , Z , A , d0)) ;
2306 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_ (A , NULL, NULL, o2 , A , Z , d0)) ;
2307 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_ (A , NULL, NULL, Complex_plus, Z , A , d0)) ;
2308 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_ (A , NULL, NULL, Complex_plus, A , Z , d0)) ;
2309 ERR1 (A, GrB_Matrix_kronecker_BinaryOp_ (A , NULL, NULL, Complex_plus, Z , Z , d0)) ;
2310 ERR1 (Z, GrB_Matrix_kronecker_BinaryOp_ (Z , Z , NULL, Complex_plus, Z , Z , d0)) ;
2311
2312 expected = GrB_DIMENSION_MISMATCH ;
2313
2314 ERR1 (C, GrB_Matrix_kronecker_BinaryOp_ (C , NULL, NULL, o2 , A , B , d0)) ;
2315 ERR1 (C, GrB_Matrix_kronecker_BinaryOp_ (C , NULL, NULL, o2 , A , B , dtn)) ;
2316 ERR1 (C, GrB_Matrix_kronecker_BinaryOp_ (C , NULL, NULL, o2 , A , B , dnt)) ;
2317 ERR1 (C, GrB_Matrix_kronecker_BinaryOp_ (C , NULL, NULL, o2 , A , B , dtt)) ;
2318
2319 //--------------------------------------------------------------------------
2320 // extract
2321 //--------------------------------------------------------------------------
2322
2323 printf ("GrB_extract -------------------------------------------------\n") ;
2324
2325 expected = GrB_NULL_POINTER ;
2326
2327 m0 = NULL ;
2328 s0 = NULL ;
2329 v0 = NULL ;
2330 A0 = NULL ;
2331 op0 = NULL ;
2332
2333 ERR1 (v0, GrB_Vector_extract_(v0, NULL, NULL, v0, I0, 0, d0)) ; // vector extract
2334 ERR1 (v, GrB_Vector_extract_(v , NULL, NULL, v0, I0, 0, d0)) ;
2335 ERR1 (v, GrB_Vector_extract_(v , NULL, NULL, u , I0, 0, d0)) ;
2336
2337 ERR1 (v0, GrB_Col_extract_(v0, NULL, NULL, A0, I0, 0, 0, d0)) ; // column extract
2338 ERR1 (v, GrB_Col_extract_(v , NULL, NULL, A0, I0, 0, 0, d0)) ;
2339 ERR1 (v, GrB_Col_extract_(v , NULL, NULL, A , I0, 0, 0, d0)) ;
2340
2341 ERR1 (A0, GrB_Matrix_extract_(A0, NULL, NULL, A0, I0, 0, J0, 0, d0)) ; // matrix extract
2342 ERR1 (A, GrB_Matrix_extract_(A , NULL, NULL, A0, I0, 0, J0, 0, d0)) ;
2343 ERR1 (A, GrB_Matrix_extract_(A , NULL, NULL, A , I0, 0, J0, 0, d0)) ;
2344 ERR1 (A, GrB_Matrix_extract_(A , NULL, NULL, A , I , 0, J0, 0, d0)) ;
2345
2346 expected = GrB_UNINITIALIZED_OBJECT ;
2347
2348 v0 = vgunk ;
2349 A0 = Agunk ;
2350 d0 = dgunk ;
2351 op0 = op2gunk ;
2352
2353 ERR1 (v0, GrB_Vector_extract_(v0, NULL, NULL, v0, I0, 0, d0)) ; // vector extract
2354 ERR1 (v, GrB_Vector_extract_(v , v0 , NULL, v0, I0, 0, d0)) ;
2355 ERR1 (v, GrB_Vector_extract_(v , v , NULL, v0, I0, 0, d0)) ;
2356 ERR1 (v, GrB_Vector_extract_(v , v , NULL, v , I , 1, d0)) ;
2357 ERR1 (v, GrB_Vector_extract_(v , v , op0 , v , I , 1, NULL)) ;
2358
2359 ERR1 (v0, GrB_Col_extract_(v0, NULL, NULL, A0, I0, 0, 0, d0)) ; // column extract
2360 ERR1 (v, GrB_Col_extract_(v , v0 , NULL, A0, I0, 0, 0, d0)) ;
2361 ERR1 (v, GrB_Col_extract_(v , v , NULL, A0, I0, 0, 0, d0)) ;
2362 ERR1 (v, GrB_Col_extract_(v , v , NULL, A , I , 1, 0, d0)) ;
2363 ERR1 (v, GrB_Col_extract_(v , v , op0 , A , I , 1, 0, NULL)) ;
2364
2365 ERR1 (A0, GrB_Matrix_extract_(A0, NULL, NULL, A0, I0, 0, J0, 0, d0)) ; // matrix extract
2366 ERR1 (A, GrB_Matrix_extract_(A , A0 , NULL, A0, I0, 0, J0, 0, d0)) ;
2367 ERR1 (A, GrB_Matrix_extract_(A , A , NULL, A0, I0, 0, J0, 0, d0)) ;
2368 ERR1 (A, GrB_Matrix_extract_(A , A , NULL, A0, I , 1, J , 1, d0)) ;
2369 ERR1 (A, GrB_Matrix_extract_(A , A , op0 , A , I , 1, J , 1, NULL)) ;
2370
2371 v0 = NULL ;
2372 A0 = NULL ;
2373 d0 = NULL ;
2374 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2375
2376 ERR1 (v, GrB_Vector_extract_(v, z, NULL, u, I, 0, d0)) ; // vector extract
2377 ERR1 (v, GrB_Vector_extract_(v, NULL, Complex_plus, u, I, 0, d0)) ;
2378 ERR1 (v, GrB_Vector_extract_(v, NULL, Complex_plus, z, I, 0, d0)) ;
2379 ERR1 (z, GrB_Vector_extract_(z, NULL, o2 , u, I, 0, d0)) ;
2380 ERR1 (v, GrB_Vector_extract_(v, NULL, o2 , z, I, 0, d0)) ;
2381
2382 ERR1 (v, GrB_Col_extract_(v, z, NULL, A, I, 0, 0, d0)) ; // column extract
2383 ERR1 (v, GrB_Col_extract_(v, NULL, Complex_plus, A, I, 0, 0, d0)) ;
2384 ERR1 (v, GrB_Col_extract_(v, NULL, Complex_plus, Z, I, 0, 0, d0)) ;
2385 ERR1 (z, GrB_Col_extract_(z, NULL, o2 , A, I, 0, 0, d0)) ;
2386 ERR1 (v, GrB_Col_extract_(v, NULL, o2 , Z, I, 0, 0, d0)) ;
2387
2388 ERR1 (A, GrB_Matrix_extract_(A, Z, NULL, A, I, 0, J, 0, d0)) ; // matrix extract
2389 ERR1 (A, GrB_Matrix_extract_(A, NULL, Complex_plus, A, I, 0, J, 0, d0)) ;
2390 ERR1 (A, GrB_Matrix_extract_(A, NULL, Complex_plus, Z, I, 0, J, 0, d0)) ;
2391 ERR1 (Z, GrB_Matrix_extract_(Z, NULL, o2 , A, I, 0, J, 0, d0)) ;
2392 ERR1 (A, GrB_Matrix_extract_(A, NULL, o2 , Z, I, 0, J, 0, d0)) ;
2393
2394 expected = GrB_DIMENSION_MISMATCH ;
2395
2396 ERR1 (A, GrB_Matrix_extract_(A, NULL, NULL, A, I, 1, J, 2, d0)) ;
2397 ERR1 (A, GrB_Matrix_extract_(A, NULL, NULL, A, I, 1, J, 2, dtn)) ;
2398
2399 expected = GrB_INVALID_INDEX ;
2400
2401 OK (GrB_Vector_new (&h, GrB_FP64, 1)) ;
2402
2403 OK (GrB_Col_extract_(h, NULL, NULL, A, I, 1, 0, d0)) ; // column extract
2404
2405 ERR1 (h, GrB_Col_extract_(h, NULL, NULL, A, I, 1, 911, d0)) ; // column extract
2406
2407 expected = GrB_INDEX_OUT_OF_BOUNDS ;
2408
2409 OK (GrB_Matrix_new (&H, GrB_FP64, 1, 1)) ;
2410
2411 I [0] = 911 ;
2412 ERR1 (H, GrB_Matrix_extract (H, NULL, NULL, A, I, 1, J, 1, d0)) ;
2413 I [0] = 0 ;
2414
2415 J [0] = 911 ;
2416 ERR1 (H, GrB_Matrix_extract (H, NULL, NULL, A, I, 1, J, 1, d0)) ;
2417 J [0] = 4 ;
2418
2419 //--------------------------------------------------------------------------
2420 // subassign
2421 //--------------------------------------------------------------------------
2422
2423 printf ("GxB_subassign -----------------------------------------------\n") ;
2424 expected = GrB_NULL_POINTER ;
2425
2426 // GxB_Vector_subassign (w,mask,acc,u,I,ni,d)
2427 // GxB_Matrix_subassign (C,Mask,acc,A,I,ni,J,nj,d)
2428 // GxB_Col_subassign (C,mask,acc,u,I,ni,j,d)
2429 // GxB_Row_subassign (C,mask,acc,u,i,J,nj,d)
2430 // GxB_Vector_subassign_T (w,mask,acc,x,I,ni,d)
2431 // GxB_Matrix_subassign_T (C,Mask,acc,x,I,ni,J,nj,d)
2432
2433 ERR1 (v0, GxB_Vector_subassign_(v0, NULL, NULL, v0, I0, 0, d0)) ; // vector assign
2434 ERR1 (v, GxB_Vector_subassign_(v , NULL, NULL, v0, I0, 0, d0)) ;
2435 ERR1 (v, GxB_Vector_subassign_(v , NULL, NULL, v , I0, 0, d0)) ;
2436
2437 ERR1 (A0, GxB_Matrix_subassign_(A0, NULL, NULL, A0, I0, 0, J0, 0, d0)) ;// matrix assign
2438 ERR1 (A, GxB_Matrix_subassign_(A , NULL, NULL, A0, I0, 0, J0, 0, d0)) ;
2439 ERR1 (A, GxB_Matrix_subassign_(A , NULL, NULL, A , I0, 0, J0, 0, d0)) ;
2440 ERR1 (A, GxB_Matrix_subassign_(A , NULL, NULL, A , I , 0, J0, 0, d0)) ;
2441
2442 ERR1 (A0, GxB_Col_subassign_(A0, NULL, NULL, v0, I0, 0, 0, d0)) ; // column assign
2443 ERR1 (A, GxB_Col_subassign_(A , NULL, NULL, v0, I0, 0, 0, d0)) ;
2444 ERR1 (A, GxB_Col_subassign_(A , NULL, NULL, v , I0, 0, 0, d0)) ;
2445
2446 ERR1 (A0, GxB_Row_subassign_(A0, NULL, NULL, v0, 0, J0, 0, d0)) ; // row assign
2447 ERR1 (A, GxB_Row_subassign_(A , NULL, NULL, v0, 0, J0, 0, d0)) ;
2448 ERR1 (A, GxB_Row_subassign_(A , NULL, NULL, v , 0, J0, 0, d0)) ;
2449
2450 ERR1 (v0, GxB_Vector_subassign_FP64_(v0, NULL, NULL, x, I0, 0, d0)) ; // vector scalar
2451 ERR1 (v, GxB_Vector_subassign_FP64_(v , NULL, NULL, x, I0, 0, d0)) ;
2452
2453 ERR1 (v0, GxB_Vector_subassign_BOOL_(v0, NULL, NULL, (bool) 0, I0, 0, d0)) ;
2454 ERR1 (v, GxB_Vector_subassign_BOOL_(v , NULL, NULL, (bool) 0, I0, 0, d0)) ;
2455
2456 ERR1 (v0, GxB_Vector_subassign_INT8_(v0, NULL, NULL, (int8_t) 0, I0, 0, d0)) ;
2457 ERR1 (v, GxB_Vector_subassign_INT8_(v , NULL, NULL, (int8_t) 0, I0, 0, d0)) ;
2458
2459 ERR1 (v0, GxB_Vector_subassign_UINT8_(v0, NULL, NULL, (uint8_t) 0, I0, 0, d0)) ;
2460 ERR1 (v, GxB_Vector_subassign_UINT8_(v , NULL, NULL, (uint8_t) 0, I0, 0, d0)) ;
2461
2462 ERR1 (v0, GxB_Vector_subassign_INT16_(v0, NULL, NULL, (int16_t) 0, I0, 0, d0)) ;
2463 ERR1 (v, GxB_Vector_subassign_INT16_(v , NULL, NULL, (int16_t) 0, I0, 0, d0)) ;
2464
2465 ERR1 (v0, GxB_Vector_subassign_UINT16_(v0, NULL, NULL, (uint16_t) 0, I0, 0, d0)) ;
2466 ERR1 (v, GxB_Vector_subassign_UINT16_(v , NULL, NULL, (uint16_t) 0, I0, 0, d0)) ;
2467
2468 ERR1 (v0, GxB_Vector_subassign_INT32_(v0, NULL, NULL, (int32_t) 0, I0, 0, d0)) ;
2469 ERR1 (v, GxB_Vector_subassign_INT32_(v , NULL, NULL, (int32_t) 0, I0, 0, d0)) ;
2470
2471 ERR1 (v0, GxB_Vector_subassign_UINT32_(v0, NULL, NULL, (uint32_t) 0, I0, 0, d0)) ;
2472 ERR1 (v, GxB_Vector_subassign_UINT32_(v , NULL, NULL, (uint32_t) 0, I0, 0, d0)) ;
2473
2474 ERR1 (v0, GxB_Vector_subassign_INT64_(v0, NULL, NULL, (int64_t) 0, I0, 0, d0)) ;
2475 ERR1 (v, GxB_Vector_subassign_INT64_(v , NULL, NULL, (int64_t) 0, I0, 0, d0)) ;
2476
2477 ERR1 (v0, GxB_Vector_subassign_UINT64_(v0, NULL, NULL, (uint64_t) 0, I0, 0, d0)) ;
2478 ERR1 (v, GxB_Vector_subassign_UINT64_(v , NULL, NULL, (uint64_t) 0, I0, 0, d0)) ;
2479
2480 ERR1 (v0, GxB_Vector_subassign_FP32_(v0, NULL, NULL, (float) 0, I0, 0, d0)) ;
2481 ERR1 (v, GxB_Vector_subassign_FP32_(v , NULL, NULL, (float) 0, I0, 0, d0)) ;
2482
2483 ERR1 (v0, GxB_Vector_subassign_UDT_(v0, NULL, NULL, (void *) X, I0, 0, d0)) ;
2484 ERR1 (v, GxB_Vector_subassign_UDT_(v , NULL, NULL, (void *) X, I0, 0, d0)) ;
2485 ERR1 (v, GxB_Vector_subassign_UDT_(v , NULL, NULL, (void *) NULL, I, 0, d0)) ;
2486
2487
2488 ERR1 (A0, GxB_Matrix_subassign_FP64_(A0, NULL, NULL, x, I0, 0, J0, 0, d0)) ;// matrix scalar
2489 ERR1 (A, GxB_Matrix_subassign_FP64_(A , NULL, NULL, x, I0, 0, J0, 0, d0)) ;
2490 ERR1 (A, GxB_Matrix_subassign_FP64_(A , NULL, NULL, x, I , 0, J0, 0, d0)) ;
2491
2492 ERR1 (A0, GxB_Matrix_subassign_BOOL_(A0, NULL, NULL, (bool) 0, I0, 0, J0, 0, d0)) ;
2493 ERR1 (A, GxB_Matrix_subassign_BOOL_(A , NULL, NULL, (bool) 0, I0, 0, J0, 0, d0)) ;
2494 ERR1 (A, GxB_Matrix_subassign_BOOL_(A , NULL, NULL, (bool) 0, I , 0, J0, 0, d0)) ;
2495
2496 ERR1 (A0, GxB_Matrix_subassign_INT8_(A0, NULL, NULL, (int8_t) 0, I0, 0, J0, 0, d0)) ;
2497 ERR1 (A, GxB_Matrix_subassign_INT8_(A , NULL, NULL, (int8_t) 0, I0, 0, J0, 0, d0)) ;
2498 ERR1 (A, GxB_Matrix_subassign_INT8_(A , NULL, NULL, (int8_t) 0, I , 0, J0, 0, d0)) ;
2499
2500 ERR1 (A0, GxB_Matrix_subassign_UINT8_(A0, NULL, NULL, (uint8_t) 0, I0, 0, J0, 0, d0)) ;
2501 ERR1 (A, GxB_Matrix_subassign_UINT8_(A , NULL, NULL, (uint8_t) 0, I0, 0, J0, 0, d0)) ;
2502 ERR1 (A, GxB_Matrix_subassign_UINT8_(A , NULL, NULL, (uint8_t) 0, I , 0, J0, 0, d0)) ;
2503
2504 ERR1 (A0, GxB_Matrix_subassign_INT16_(A0, NULL, NULL, (int16_t) 0, I0, 0, J0, 0, d0)) ;
2505 ERR1 (A, GxB_Matrix_subassign_INT16_(A , NULL, NULL, (int16_t) 0, I0, 0, J0, 0, d0)) ;
2506 ERR1 (A, GxB_Matrix_subassign_INT16_(A , NULL, NULL, (int16_t) 0, I , 0, J0, 0, d0)) ;
2507
2508 ERR1 (A0, GxB_Matrix_subassign_UINT16_(A0, NULL, NULL, (uint16_t) 0, I0, 0, J0, 0, d0)) ;
2509 ERR1 (A, GxB_Matrix_subassign_UINT16_(A , NULL, NULL, (uint16_t) 0, I0, 0, J0, 0, d0)) ;
2510 ERR1 (A, GxB_Matrix_subassign_UINT16_(A , NULL, NULL, (uint16_t) 0, I , 0, J0, 0, d0)) ;
2511
2512 ERR1 (A0, GxB_Matrix_subassign_INT32_(A0, NULL, NULL, (int32_t) 0, I0, 0, J0, 0, d0)) ;
2513 ERR1 (A, GxB_Matrix_subassign_INT32_(A , NULL, NULL, (int32_t) 0, I0, 0, J0, 0, d0)) ;
2514 ERR1 (A, GxB_Matrix_subassign_INT32_(A , NULL, NULL, (int32_t) 0, I , 0, J0, 0, d0)) ;
2515
2516 ERR1 (A0, GxB_Matrix_subassign_UINT32_(A0, NULL, NULL, (uint32_t) 0, I0, 0, J0, 0, d0)) ;
2517 ERR1 (A, GxB_Matrix_subassign_UINT32_(A , NULL, NULL, (uint32_t) 0, I0, 0, J0, 0, d0)) ;
2518 ERR1 (A, GxB_Matrix_subassign_UINT32_(A , NULL, NULL, (uint32_t) 0, I , 0, J0, 0, d0)) ;
2519
2520 ERR1 (A0, GxB_Matrix_subassign_INT64_(A0, NULL, NULL, (int64_t) 0, I0, 0, J0, 0, d0)) ;
2521 ERR1 (A, GxB_Matrix_subassign_INT64_(A , NULL, NULL, (int64_t) 0, I0, 0, J0, 0, d0)) ;
2522 ERR1 (A, GxB_Matrix_subassign_INT64_(A , NULL, NULL, (int64_t) 0, I , 0, J0, 0, d0)) ;
2523
2524 ERR1 (A0, GxB_Matrix_subassign_UINT64_(A0, NULL, NULL, (uint64_t) 0, I0, 0, J0, 0, d0)) ;
2525 ERR1 (A, GxB_Matrix_subassign_UINT64_(A , NULL, NULL, (uint64_t) 0, I0, 0, J0, 0, d0)) ;
2526 ERR1 (A, GxB_Matrix_subassign_UINT64_(A , NULL, NULL, (uint64_t) 0, I , 0, J0, 0, d0)) ;
2527
2528 ERR1 (A0, GxB_Matrix_subassign_FP32_(A0, NULL, NULL, (float) 0, I0, 0, J0, 0, d0)) ;
2529 ERR1 (A, GxB_Matrix_subassign_FP32_(A , NULL, NULL, (float) 0, I0, 0, J0, 0, d0)) ;
2530 ERR1 (A, GxB_Matrix_subassign_FP32_(A , NULL, NULL, (float) 0, I , 0, J0, 0, d0)) ;
2531
2532 ERR1 (A0, GxB_Matrix_subassign_UDT_(A0, NULL, NULL, (void *) X, I0, 0, J0, 0, d0)) ;
2533 ERR1 (A, GxB_Matrix_subassign_UDT_(A , NULL, NULL, (void *) X, I0, 0, J0, 0, d0)) ;
2534 ERR1 (A, GxB_Matrix_subassign_UDT_(A , NULL, NULL, (void *) X, I , 0, J0, 0, d0)) ;
2535 ERR1 (A, GxB_Matrix_subassign_UDT_(A , NULL, NULL, (void *) NULL, I , 0, J, 0, d0)) ;
2536
2537 expected = GrB_UNINITIALIZED_OBJECT ;
2538
2539 v0 = vgunk ;
2540 A0 = Agunk ;
2541 d0 = dgunk ;
2542 op0 = op2gunk ;
2543
2544 ERR1 (v0, GxB_Vector_subassign_(v0, NULL, NULL, v0, I, 0, d0)) ; // vector assign
2545 ERR1 (v, GxB_Vector_subassign_(v , v0 , NULL, v0, I, 0, d0)) ;
2546 ERR1 (v, GxB_Vector_subassign_(v , v , NULL, v0, I, 0, d0)) ;
2547 ERR1 (v, GxB_Vector_subassign_(v , v , NULL, v , I, 0, d0)) ;
2548 ERR1 (v, GxB_Vector_subassign_(v , v , op0 , v , I, 0, NULL)) ;
2549
2550 ERR1 (A0, GxB_Matrix_subassign_(A0, NULL, NULL, A0, I, 0, J, 0, d0)) ; // matrix assign
2551 ERR1 (A, GxB_Matrix_subassign_(A , A0 , NULL, A0, I, 0, J, 0, d0)) ;
2552 ERR1 (A, GxB_Matrix_subassign_(A , A , NULL, A0, I, 0, J, 0, d0)) ;
2553 ERR1 (A, GxB_Matrix_subassign_(A , A , NULL, A , I, 0, J, 0, d0)) ;
2554 ERR1 (A, GxB_Matrix_subassign_(A , A , op0 , A , I, 0, J, 0, NULL)) ;
2555
2556 ERR1 (A0, GxB_Col_subassign_(A0, NULL, NULL, v0, I, 0, 0, d0)) ; // column assign
2557 ERR1 (A, GxB_Col_subassign_(A , v0 , NULL, v0, I, 0, 0, d0)) ;
2558 ERR1 (A, GxB_Col_subassign_(A , v , NULL, v0, I, 0, 0, d0)) ;
2559 ERR1 (A, GxB_Col_subassign_(A , v , NULL, v , I, 0, 0, d0)) ;
2560 ERR1 (A, GxB_Col_subassign_(A , v , op0 , v , I, 0, 0, NULL)) ;
2561
2562 ERR1 (A0, GxB_Row_subassign_(A0, NULL, NULL, v0, 0, J, 0, d0)) ; // row assign
2563 ERR1 (A, GxB_Row_subassign_(A , v0 , NULL, v0, 0, J, 0, d0)) ;
2564 ERR1 (A, GxB_Row_subassign_(A , v , NULL, v0, 0, J, 0, d0)) ;
2565 ERR1 (A, GxB_Row_subassign_(A , v , NULL, v , 0, J, 0, d0)) ;
2566 ERR1 (A, GxB_Row_subassign_(A , NULL, op0 , v , 0, J, 0, NULL)) ;
2567
2568 ERR1 (v0, GxB_Vector_subassign_FP64 (v0, NULL, NULL, x, I, 0, d0)) ; // vector scalar
2569 ERR1 (v, GxB_Vector_subassign_FP64 (v , v0 , NULL, x, I, 0, d0)) ;
2570 ERR1 (v, GxB_Vector_subassign_FP64 (v , v , NULL, x, I, 0, d0)) ;
2571 ERR1 (v, GxB_Vector_subassign_FP64 (v , v , op0 , x, I, 0, NULL)) ;
2572
2573 ERR1 (v0, GxB_Vector_subassign_BOOL (v0, NULL, NULL, (bool) 0, I, 0, d0)) ;
2574 ERR1 (v, GxB_Vector_subassign_BOOL (v , v0 , NULL, (bool) 0, I, 0, d0)) ;
2575 ERR1 (v, GxB_Vector_subassign_BOOL (v , v , NULL, (bool) 0, I, 0, d0)) ;
2576 ERR1 (v, GxB_Vector_subassign_BOOL (v , v , op0 , (bool) 0, I, 0, NULL)) ;
2577
2578 ERR1 (v0, GxB_Vector_subassign_INT8 (v0, NULL, NULL, (int8_t) 0, I, 0, d0)) ;
2579 ERR1 (v, GxB_Vector_subassign_INT8 (v , v0 , NULL, (int8_t) 0, I, 0, d0)) ;
2580 ERR1 (v, GxB_Vector_subassign_INT8 (v , v , NULL, (int8_t) 0, I, 0, d0)) ;
2581 ERR1 (v, GxB_Vector_subassign_INT8 (v , v , op0 , (int8_t) 0, I, 0, NULL)) ;
2582
2583 ERR1 (v0, GxB_Vector_subassign_UINT8 (v0, NULL, NULL, (uint8_t) 0, I, 0, d0)) ;
2584 ERR1 (v, GxB_Vector_subassign_UINT8 (v , v0 , NULL, (uint8_t) 0, I, 0, d0)) ;
2585 ERR1 (v, GxB_Vector_subassign_UINT8 (v , v , NULL, (uint8_t) 0, I, 0, d0)) ;
2586 ERR1 (v, GxB_Vector_subassign_UINT8 (v , v , NULL, (uint8_t) 0, I, 0, d0)) ;
2587
2588 ERR1 (v0, GxB_Vector_subassign_INT16 (v0, NULL, NULL, (int16_t) 0, I, 0, d0)) ;
2589 ERR1 (v, GxB_Vector_subassign_INT16 (v , v0 , NULL, (int16_t) 0, I, 0, d0)) ;
2590 ERR1 (v, GxB_Vector_subassign_INT16 (v , v , NULL, (int16_t) 0, I, 0, d0)) ;
2591 ERR1 (v, GxB_Vector_subassign_INT16 (v , v , op0 , (int16_t) 0, I, 0, NULL)) ;
2592
2593 ERR1 (v0, GxB_Vector_subassign_UINT16 (v0, NULL, NULL, (uint16_t) 0, I, 0, d0)) ;
2594 ERR1 (v, GxB_Vector_subassign_UINT16 (v , v0 , NULL, (uint16_t) 0, I, 0, d0)) ;
2595 ERR1 (v, GxB_Vector_subassign_UINT16 (v , v , NULL, (uint16_t) 0, I, 0, d0)) ;
2596 ERR1 (v, GxB_Vector_subassign_UINT16 (v , v , op0 , (uint16_t) 0, I, 0, NULL)) ;
2597
2598 ERR1 (v0, GxB_Vector_subassign_INT32 (v0, NULL, NULL, (int32_t) 0, I, 0, d0)) ;
2599 ERR1 (v, GxB_Vector_subassign_INT32 (v , v0 , NULL, (int32_t) 0, I, 0, d0)) ;
2600 ERR1 (v, GxB_Vector_subassign_INT32 (v , v , NULL, (int32_t) 0, I, 0, d0)) ;
2601 ERR1 (v, GxB_Vector_subassign_INT32 (v , v , op0 , (int32_t) 0, I, 0, NULL)) ;
2602
2603 ERR1 (v0, GxB_Vector_subassign_UINT32 (v0, NULL, NULL, (uint32_t) 0, I, 0, d0)) ;
2604 ERR1 (v, GxB_Vector_subassign_UINT32 (v , v0 , NULL, (uint32_t) 0, I, 0, d0)) ;
2605 ERR1 (v, GxB_Vector_subassign_UINT32 (v , v , NULL, (uint32_t) 0, I, 0, d0)) ;
2606 ERR1 (v, GxB_Vector_subassign_UINT32 (v , v , op0 , (uint32_t) 0, I, 0, NULL)) ;
2607
2608 ERR1 (v0, GxB_Vector_subassign_INT64 (v0, NULL, NULL, (int64_t) 0, I, 0, d0)) ;
2609 ERR1 (v, GxB_Vector_subassign_INT64 (v , v0 , NULL, (int64_t) 0, I, 0, d0)) ;
2610 ERR1 (v, GxB_Vector_subassign_INT64 (v , v , NULL, (int64_t) 0, I, 0, d0)) ;
2611 ERR1 (v, GxB_Vector_subassign_INT64 (v , v , op0 , (int64_t) 0, I, 0, NULL)) ;
2612
2613 ERR1 (v0, GxB_Vector_subassign_UINT64 (v0, NULL, NULL, (uint64_t) 0, I, 0, d0)) ;
2614 ERR1 (v, GxB_Vector_subassign_UINT64 (v , v0 , NULL, (uint64_t) 0, I, 0, d0)) ;
2615 ERR1 (v, GxB_Vector_subassign_UINT64 (v , v , NULL, (uint64_t) 0, I, 0, d0)) ;
2616 ERR1 (v, GxB_Vector_subassign_UINT64 (v , v , op0 , (uint64_t) 0, I, 0, NULL)) ;
2617
2618 ERR1 (v0, GxB_Vector_subassign_FP32 (v0, NULL, NULL, (float) 0, I, 0, d0)) ;
2619 ERR1 (v, GxB_Vector_subassign_FP32 (v , v0 , NULL, (float) 0, I, 0, d0)) ;
2620 ERR1 (v, GxB_Vector_subassign_FP32 (v , v , NULL, (float) 0, I, 0, d0)) ;
2621 ERR1 (v, GxB_Vector_subassign_FP32 (v , v , op0 , (float) 0, I, 0, NULL)) ;
2622
2623 ERR1 (v, GxB_Vector_subassign_UDT (v0, NULL, NULL, (void *) X, I, 0, d0)) ;
2624 ERR1 (v, GxB_Vector_subassign_UDT (v , v0 , NULL, (void *) X, I, 0, d0)) ;
2625 ERR1 (v, GxB_Vector_subassign_UDT (v , v , NULL, (void *) X, I, 0, d0)) ;
2626 ERR1 (v, GxB_Vector_subassign_UDT (v , v , op0 , (void *) X, I, 0, NULL)) ;
2627
2628 ERR1 (A0, GxB_Matrix_subassign_FP64_(A0, NULL, NULL, x, I, 0, J, 0, d0)) ; // matrix scalar
2629 ERR1 (A, GxB_Matrix_subassign_FP64_(A , A0 , NULL, x, I, 0, J, 0, d0)) ;
2630 ERR1 (A, GxB_Matrix_subassign_FP64_(A , A , NULL, x, I, 0, J, 0, d0)) ;
2631 ERR1 (A, GxB_Matrix_subassign_FP64_(A , A , op0 , x, I, 0, J, 0, NULL)) ;
2632
2633 ERR1 (A0, GxB_Matrix_subassign_BOOL_(A0, NULL, NULL, (bool) 0, I, 0, J, 0, d0)) ;
2634 ERR1 (A, GxB_Matrix_subassign_BOOL_(A , A0 , NULL, (bool) 0, I, 0, J, 0, d0)) ;
2635 ERR1 (A, GxB_Matrix_subassign_BOOL_(A , A , NULL, (bool) 0, I, 0, J, 0, d0)) ;
2636 ERR1 (A, GxB_Matrix_subassign_BOOL_(A , A , op0 , (bool) 0, I, 0, J, 0, NULL)) ;
2637
2638 ERR1 (A0, GxB_Matrix_subassign_INT8_(A0, NULL, NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
2639 ERR1 (A, GxB_Matrix_subassign_INT8_(A , A0 , NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
2640 ERR1 (A, GxB_Matrix_subassign_INT8_(A , A , NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
2641 ERR1 (A, GxB_Matrix_subassign_INT8_(A , A , op0 , (int8_t) 0, I, 0, J, 0, NULL)) ;
2642
2643 ERR1 (A0, GxB_Matrix_subassign_UINT8_(A0, NULL, NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
2644 ERR1 (A, GxB_Matrix_subassign_UINT8_(A , A0 , NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
2645 ERR1 (A, GxB_Matrix_subassign_UINT8_(A , A , NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
2646 ERR1 (A, GxB_Matrix_subassign_UINT8_(A , A , op0 , (uint8_t) 0, I, 0, J, 0, NULL)) ;
2647
2648 ERR1 (A0, GxB_Matrix_subassign_INT16_(A0, NULL, NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
2649 ERR1 (A, GxB_Matrix_subassign_INT16_(A , A0 , NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
2650 ERR1 (A, GxB_Matrix_subassign_INT16_(A , A , NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
2651 ERR1 (A, GxB_Matrix_subassign_INT16_(A , A , op0 , (int16_t) 0, I, 0, J, 0, NULL)) ;
2652
2653 ERR1 (A0, GxB_Matrix_subassign_UINT16_(A0, NULL, NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
2654 ERR1 (A, GxB_Matrix_subassign_UINT16_(A , A0 , NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
2655 ERR1 (A, GxB_Matrix_subassign_UINT16_(A , A , NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
2656 ERR1 (A, GxB_Matrix_subassign_UINT16_(A , A , op0 , (uint16_t) 0, I, 0, J, 0, NULL)) ;
2657
2658 ERR1 (A0, GxB_Matrix_subassign_INT32_(A0, NULL, NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
2659 ERR1 (A, GxB_Matrix_subassign_INT32_(A , A0 , NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
2660 ERR1 (A, GxB_Matrix_subassign_INT32_(A , A , NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
2661 ERR1 (A, GxB_Matrix_subassign_INT32_(A , A , op0 , (int32_t) 0, I, 0, J, 0, NULL)) ;
2662
2663 ERR1 (A0, GxB_Matrix_subassign_UINT32_(A0, NULL, NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
2664 ERR1 (A, GxB_Matrix_subassign_UINT32_(A , A0 , NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
2665 ERR1 (A, GxB_Matrix_subassign_UINT32_(A , A , NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
2666 ERR1 (A, GxB_Matrix_subassign_UINT32_(A , A , op0 , (uint32_t) 0, I, 0, J, 0, NULL)) ;
2667
2668 ERR1 (A0, GxB_Matrix_subassign_INT64_(A0, NULL, NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
2669 ERR1 (A, GxB_Matrix_subassign_INT64_(A , A0 , NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
2670 ERR1 (A, GxB_Matrix_subassign_INT64_(A , A , NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
2671 ERR1 (A, GxB_Matrix_subassign_INT64_(A , A , op0 , (int64_t) 0, I, 0, J, 0, NULL)) ;
2672
2673 ERR1 (A0, GxB_Matrix_subassign_UINT64_(A0, NULL, NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
2674 ERR1 (A, GxB_Matrix_subassign_UINT64_(A , A0 , NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
2675 ERR1 (A, GxB_Matrix_subassign_UINT64_(A , A , NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
2676 ERR1 (A, GxB_Matrix_subassign_UINT64_(A , A , op0 , (uint64_t) 0, I, 0, J, 0, NULL)) ;
2677
2678 ERR1 (A0, GxB_Matrix_subassign_FP32_(A0, NULL, NULL, (float) 0, I, 0, J, 0, d0)) ;
2679 ERR1 (A, GxB_Matrix_subassign_FP32_(A , A0 , NULL, (float) 0, I, 0, J, 0, d0)) ;
2680 ERR1 (A, GxB_Matrix_subassign_FP32_(A , A , NULL, (float) 0, I, 0, J, 0, d0)) ;
2681 ERR1 (A, GxB_Matrix_subassign_FP32_(A , A , op0 , (float) 0, I, 0, J, 0, NULL)) ;
2682
2683 ERR1 (A0, GxB_Matrix_subassign_UDT_(A0, NULL, NULL, (void *) X, I, 0, J, 0, d0)) ;
2684 ERR1 (A, GxB_Matrix_subassign_UDT_(A , A0 , NULL, (void *) X, I, 0, J, 0, d0)) ;
2685 ERR1 (A, GxB_Matrix_subassign_UDT_(A , A , NULL, (void *) X, I, 0, J, 0, d0)) ;
2686 ERR1 (A, GxB_Matrix_subassign_UDT_(A , A , op0 , (void *) X, I, 0, J, 0, NULL)) ;
2687
2688 v0 = NULL ;
2689 A0 = NULL ;
2690 d0 = NULL ;
2691 op0 = Complex_plus ;
2692 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
2693
2694 ERR1 (v, GxB_Vector_subassign_(v, z , NULL, v, I, 0, d0)) ; // vector assign
2695 ERR1 (v, GxB_Vector_subassign_(v, v0, op0 , v, I, 0, d0)) ;
2696 ERR1 (v, GxB_Vector_subassign_(v, v0, op0 , z, I, 0, d0)) ;
2697 ERR1 (z, GxB_Vector_subassign_(z, v0, o2 , v, I, 0, d0)) ;
2698 ERR1 (v, GxB_Vector_subassign_(v, v0, o2 , z, I, 0, d0)) ;
2699 ERR1 (v, GxB_Vector_subassign_(v, v0, NULL, z, I, 0, d0)) ;
2700
2701 ERR1 (A, GxB_Matrix_subassign_(A, Z , NULL, A, I, 0, J, 0, d0)) ; // matrix assign
2702 ERR1 (A, GxB_Matrix_subassign_(A, A0, op0 , A, I, 0, J, 0, d0)) ;
2703 ERR1 (A, GxB_Matrix_subassign_(A, A0, op0 , Z, I, 0, J, 0, d0)) ;
2704 ERR1 (Z, GxB_Matrix_subassign_(Z, A0, o2 , A, I, 0, J, 0, d0)) ;
2705 ERR1 (A, GxB_Matrix_subassign_(A, A0, o2 , Z, I, 0, J, 0, d0)) ;
2706 ERR1 (A, GxB_Matrix_subassign_(A, A0, NULL, Z, I, 0, J, 0, d0)) ;
2707
2708 ERR1 (A, GxB_Col_subassign_(A, z , NULL, v, I, 0, 0, d0)) ; // column assign
2709 ERR1 (A, GxB_Col_subassign_(A, v0, op0 , v, I, 0, 0, d0)) ;
2710 ERR1 (A, GxB_Col_subassign_(A, v0, op0 , z, I, 0, 0, d0)) ;
2711 ERR1 (Z, GxB_Col_subassign_(Z, v0, o2 , v, I, 0, 0, d0)) ;
2712 ERR1 (A, GxB_Col_subassign_(A, v0, o2 , z, I, 0, 0, d0)) ;
2713 ERR1 (A, GxB_Col_subassign_(A, v0, NULL, z, I, 0, 0, d0)) ;
2714
2715 ERR1 (A, GxB_Row_subassign_(A, z , NULL, v, 0, J, 0, d0)) ; // row assign
2716 ERR1 (A, GxB_Row_subassign_(A, v0, op0 , v, 0, J, 0, d0)) ;
2717 ERR1 (A, GxB_Row_subassign_(A, v0, op0 , z, 0, J, 0, d0)) ;
2718 ERR1 (Z, GxB_Row_subassign_(Z, v0, o2 , v, 0, J, 0, d0)) ;
2719 ERR1 (A, GxB_Row_subassign_(A, v0, o2 , z, 0, J, 0, d0)) ;
2720 ERR1 (A, GxB_Row_subassign_(A, v0, NULL, z, 0, J, 0, d0)) ;
2721
2722 ERR1 (v, GxB_Vector_subassign_FP64_(v, z , NULL, x, I, 0, d0)) ; // vector scalar
2723
2724 if (Complex == GxB_FC64)
2725 {
2726 OK (GxB_Vector_subassign_FP64_(v, v0, op0 , x, I, 0, d0)) ;
2727 }
2728 else
2729 {
2730 ERR1 (v, GxB_Vector_subassign_FP64_(v, v0, op0 , x, I, 0, d0)) ;
2731 }
2732
2733 expected = GrB_DOMAIN_MISMATCH ;
2734
2735 ERR1 (v, GxB_Vector_subassign_UDT_(v, v0, op0 ,(void *) &c, I, 0, d0)) ;
2736
2737 if (Complex == GxB_FC64)
2738 {
2739 OK (GxB_Vector_subassign_FP64_(z, v0, o2 , x, I, 0, d0)) ;
2740 }
2741 else
2742 {
2743 ERR1 (z, GxB_Vector_subassign_FP64_(z, v0, o2 , x, I, 0, d0)) ;
2744 }
2745
2746 ERR1 (v, GxB_Vector_subassign_UDT_(v, v0, o2 ,(void *) &c, I, 0, d0)) ;
2747 ERR1 (v, GxB_Vector_subassign_UDT_(v, v0, NULL,(void *) &c, I, 0, d0)) ;
2748
2749 // matrix scalar
2750 if (Complex == GxB_FC64)
2751 {
2752 expected = GrB_DIMENSION_MISMATCH ;
2753 OK (GxB_Matrix_subassign_FP64_(A, A0, op0 , x, I, 0, J, 0, d0)) ;
2754 OK (GxB_Matrix_subassign_FP64_(Z, A0, o2 , x, I, 0, J, 0, d0)) ;
2755 }
2756 else
2757 {
2758 expected = GrB_DOMAIN_MISMATCH ;
2759 ERR1 (A, GxB_Matrix_subassign_FP64_(A, A0, op0 , x, I, 0, J, 0, d0)) ;
2760 ERR1 (Z, GxB_Matrix_subassign_FP64_(Z, A0, o2 , x, I, 0, J, 0, d0)) ;
2761 }
2762
2763 ERR1 (A, GxB_Matrix_subassign_FP64_(A, Z , NULL, x, I, 0, J, 0, d0)) ;
2764
2765 expected = GrB_DOMAIN_MISMATCH ;
2766 ERR1 (A, GxB_Matrix_subassign_UDT_(A, A0, op0 ,(void *) &c , I, 0, J, 0, d0)) ;
2767 ERR1 (A, GxB_Matrix_subassign_UDT_(A, A0, o2 ,(void *) &c , I, 0, J, 0, d0)) ;
2768 ERR1 (A, GxB_Matrix_subassign_UDT_(A, A0, NULL,(void *) &c , I, 0, J, 0, d0)) ;
2769
2770 expected = GrB_DIMENSION_MISMATCH ;
2771
2772 ERR1 (A, GxB_Matrix_subassign_(A, NULL, NULL, A, I, 2, J, 3, d0)) ;
2773 ERR1 (A, GxB_Matrix_subassign_(A, NULL, NULL, A, I, 2, J, 3, dtn)) ;
2774 ERR1 (A, GxB_Row_subassign_(A , v , NULL, v , 0, J, 0, NULL)) ;
2775
2776 fprintf (ff, "test for indices out of bounds:\n") ;
2777 OK (GxB_Matrix_fprint (A, "A", GxB_COMPLETE, ff)) ;
2778 OK (GxB_Matrix_fprint (C, "C", GxB_COMPLETE, ff)) ;
2779 for (int k = 0 ; k < 3 ; k++)
2780 {
2781 fprintf (ff, "I [%d] = %g\n", k, (double) I [k]) ;
2782 }
2783 for (int k = 0 ; k < 2 ; k++)
2784 {
2785 fprintf (ff, "J [%d] = %g\n", k, (double) J [k]) ;
2786 }
2787 expected = GrB_INDEX_OUT_OF_BOUNDS ;
2788
2789 OK (GrB_Matrix_dup (&A4, A)) ;
2790 ERR1 (A4, GxB_Matrix_subassign_(A4, NULL, GrB_PLUS_FP64, C, I, 3, J, 2, NULL)) ;
2791 GrB_Matrix_error_(&err, A4) ;
2792 fprintf (ff, "done bounds test: error returned:\n%s\n", err) ;
2793 OK (GrB_Matrix_free_(&A4)) ;
2794
2795 GrB_Index I3 [5] = { 0, 1, 2, 3, 4 } ;
2796 GrB_Index J3 [5] = { 0, 1, 2, 3, 4 } ;
2797
2798 OK (GxB_Matrix_fprint_(A, GxB_COMPLETE, NULL)) ;
2799 OK (GxB_Matrix_fprint_(A, GxB_COMPLETE, ff)) ;
2800 OK (GxB_Matrix_subassign_(A, NULL, GrB_PLUS_FP64, C, I3, 3, J3, 2, NULL)) ;
2801
2802 OK (GxB_Matrix_subassign (C, C, GrB_PLUS_FP64, C, I3, 3, J3, 2, NULL)) ;
2803
2804 J3 [0] = 999 ;
2805 OK (GrB_Matrix_dup (&C4, C)) ;
2806 ERR1 (C4, GxB_Matrix_subassign (C4, C4, GrB_PLUS_FP64, C4, I3, 3, J3, 2, NULL)) ;
2807 OK (GrB_Matrix_free_(&C4)) ;
2808
2809 OK (GrB_Matrix_dup (&A4, A)) ;
2810 ERR1 (A4, GxB_Matrix_subassign_FP64_(A4, NULL, GrB_PLUS_FP64, x_double, I3, 1, J3, 1, NULL));
2811 OK (GrB_Matrix_free_(&A4)) ;
2812
2813 J3 [0] = 0 ;
2814 I3 [0] = 999 ;
2815
2816 OK (GrB_Matrix_dup (&A4, A)) ;
2817 ERR1 (A4, GxB_Matrix_subassign_FP64_(A4, NULL, GrB_PLUS_FP64, x_double, I3, 1, J3, 1, NULL));
2818 OK (GrB_Matrix_free_(&A4)) ;
2819
2820 //--------------------------------------------------------------------------
2821 // assign
2822 //--------------------------------------------------------------------------
2823
2824 printf ("GrB_assign---------------------------------------------------\n") ;
2825 expected = GrB_NULL_POINTER ;
2826
2827 // GrB_Vector_assign (w,mask,acc,u,I,ni,d)
2828 // GrB_Matrix_assign (C,Mask,acc,A,I,ni,J,nj,d)
2829 // GrB_Col_assign (C,mask,acc,u,I,ni,j,d)
2830 // GrB_Row_assign (C,mask,acc,u,i,J,nj,d)
2831 // GrB_Vector_assign_T (w,mask,acc,x,I,ni,d)
2832 // GrB_Matrix_assign_T (C,Mask,acc,x,I,ni,J,nj,d)
2833
2834 ERR1 (v0, GrB_Vector_assign_(v0, NULL, NULL, v0, I0, 0, d0)) ; // vector assign
2835 ERR1 (v, GrB_Vector_assign_(v , NULL, NULL, v0, I0, 0, d0)) ;
2836 ERR1 (v, GrB_Vector_assign_(v , NULL, NULL, v , I0, 0, d0)) ;
2837
2838 ERR1 (A0, GrB_Matrix_assign_(A0, NULL, NULL, A0, I0, 0, J0, 0, d0)) ; // matrix assign
2839 ERR1 (A, GrB_Matrix_assign_(A , NULL, NULL, A0, I0, 0, J0, 0, d0)) ;
2840 ERR1 (A, GrB_Matrix_assign_(A , NULL, NULL, A , I0, 0, J0, 0, d0)) ;
2841 ERR1 (A, GrB_Matrix_assign_(A , NULL, NULL, A , I , 0, J0, 0, d0)) ;
2842
2843 ERR1 (A0, GrB_Col_assign_(A0, NULL, NULL, v0, I0, 0, 0, d0)) ; // column assign
2844 ERR1 (A, GrB_Col_assign_(A , NULL, NULL, v0, I0, 0, 0, d0)) ;
2845 ERR1 (A, GrB_Col_assign_(A , NULL, NULL, v , I0, 0, 0, d0)) ;
2846
2847 ERR1 (A0, GrB_Row_assign_(A0, NULL, NULL, v0, 0, J0, 0, d0)) ; // row assign
2848 ERR1 (A, GrB_Row_assign_(A , NULL, NULL, v0, 0, J0, 0, d0)) ;
2849 ERR1 (A, GrB_Row_assign_(A , NULL, NULL, v , 0, J0, 0, d0)) ;
2850
2851 ERR1 (v0, GrB_Vector_assign_FP64_(v0, NULL, NULL, x, I0, 0, d0)) ; // vector scalar
2852 ERR1 (v, GrB_Vector_assign_FP64_(v , NULL, NULL, x, I0, 0, d0)) ;
2853
2854 ERR1 (v0, GrB_Vector_assign_BOOL_(v0, NULL, NULL, (bool) 0, I0, 0, d0)) ;
2855 ERR1 (v, GrB_Vector_assign_BOOL_(v , NULL, NULL, (bool) 0, I0, 0, d0)) ;
2856
2857 ERR1 (v0, GrB_Vector_assign_INT8_(v0, NULL, NULL, (int8_t) 0, I0, 0, d0)) ;
2858 ERR1 (v, GrB_Vector_assign_INT8_(v , NULL, NULL, (int8_t) 0, I0, 0, d0)) ;
2859
2860 ERR1 (v0, GrB_Vector_assign_UINT8_(v0, NULL, NULL, (uint8_t) 0, I0, 0, d0)) ;
2861 ERR1 (v, GrB_Vector_assign_UINT8_(v , NULL, NULL, (uint8_t) 0, I0, 0, d0)) ;
2862
2863 ERR1 (v0, GrB_Vector_assign_INT16_(v0, NULL, NULL, (int16_t) 0, I0, 0, d0)) ;
2864 ERR1 (v, GrB_Vector_assign_INT16_(v , NULL, NULL, (int16_t) 0, I0, 0, d0)) ;
2865
2866 ERR1 (v0, GrB_Vector_assign_UINT16_(v0, NULL, NULL, (uint16_t) 0, I0, 0, d0)) ;
2867 ERR1 (v, GrB_Vector_assign_UINT16_(v , NULL, NULL, (uint16_t) 0, I0, 0, d0)) ;
2868
2869 ERR1 (v0, GrB_Vector_assign_INT32_(v0, NULL, NULL, (int32_t) 0, I0, 0, d0)) ;
2870 ERR1 (v, GrB_Vector_assign_INT32_(v , NULL, NULL, (int32_t) 0, I0, 0, d0)) ;
2871
2872 ERR1 (v0, GrB_Vector_assign_UINT32_(v0, NULL, NULL, (uint32_t) 0, I0, 0, d0)) ;
2873 ERR1 (v, GrB_Vector_assign_UINT32_(v , NULL, NULL, (uint32_t) 0, I0, 0, d0)) ;
2874
2875 ERR1 (v0, GrB_Vector_assign_INT64_(v0, NULL, NULL, (int64_t) 0, I0, 0, d0)) ;
2876 ERR1 (v, GrB_Vector_assign_INT64_(v , NULL, NULL, (int64_t) 0, I0, 0, d0)) ;
2877
2878 ERR1 (v0, GrB_Vector_assign_UINT64_(v0, NULL, NULL, (uint64_t) 0, I0, 0, d0)) ;
2879 ERR1 (v, GrB_Vector_assign_UINT64_(v , NULL, NULL, (uint64_t) 0, I0, 0, d0)) ;
2880
2881 ERR1 (v0, GrB_Vector_assign_FP32_(v0, NULL, NULL, (float) 0, I0, 0, d0)) ;
2882 ERR1 (v, GrB_Vector_assign_FP32_(v , NULL, NULL, (float) 0, I0, 0, d0)) ;
2883
2884 ERR1 (v0, GrB_Vector_assign_UDT_(v0, NULL, NULL, (void *) X, I0, 0, d0)) ;
2885 ERR1 (v, GrB_Vector_assign_UDT_(v , NULL, NULL, (void *) X, I0, 0, d0)) ;
2886 ERR1 (v, GrB_Vector_assign_UDT_(v , NULL, NULL, (void *) NULL, I, 0, d0)) ;
2887
2888 ERR1 (A0, GrB_Matrix_assign_FP64_(A0, NULL, NULL, x, I0, 0, J0, 0, d0)) ; // matrix scalar
2889 ERR1 (A, GrB_Matrix_assign_FP64_(A , NULL, NULL, x, I0, 0, J0, 0, d0)) ;
2890 ERR1 (A, GrB_Matrix_assign_FP64_(A , NULL, NULL, x, I , 0, J0, 0, d0)) ;
2891
2892 ERR1 (A0, GrB_Matrix_assign_BOOL_(A0, NULL, NULL, (bool) 0, I0, 0, J0, 0, d0)) ;
2893 ERR1 (A, GrB_Matrix_assign_BOOL_(A , NULL, NULL, (bool) 0, I0, 0, J0, 0, d0)) ;
2894 ERR1 (A, GrB_Matrix_assign_BOOL_(A , NULL, NULL, (bool) 0, I , 0, J0, 0, d0)) ;
2895
2896 ERR1 (A0, GrB_Matrix_assign_INT8_(A0, NULL, NULL, (int8_t) 0, I0, 0, J0, 0, d0)) ;
2897 ERR1 (A, GrB_Matrix_assign_INT8_(A , NULL, NULL, (int8_t) 0, I0, 0, J0, 0, d0)) ;
2898 ERR1 (A, GrB_Matrix_assign_INT8_(A , NULL, NULL, (int8_t) 0, I , 0, J0, 0, d0)) ;
2899
2900 ERR1 (A0, GrB_Matrix_assign_UINT8_(A0, NULL, NULL, (uint8_t) 0, I0, 0, J0, 0, d0)) ;
2901 ERR1 (A, GrB_Matrix_assign_UINT8_(A , NULL, NULL, (uint8_t) 0, I0, 0, J0, 0, d0)) ;
2902 ERR1 (A, GrB_Matrix_assign_UINT8_(A , NULL, NULL, (uint8_t) 0, I , 0, J0, 0, d0)) ;
2903
2904 ERR1 (A0, GrB_Matrix_assign_INT16_(A0, NULL, NULL, (int16_t) 0, I0, 0, J0, 0, d0)) ;
2905 ERR1 (A, GrB_Matrix_assign_INT16_(A , NULL, NULL, (int16_t) 0, I0, 0, J0, 0, d0)) ;
2906 ERR1 (A, GrB_Matrix_assign_INT16_(A , NULL, NULL, (int16_t) 0, I , 0, J0, 0, d0)) ;
2907
2908 ERR1 (A0, GrB_Matrix_assign_UINT16_(A0, NULL, NULL, (uint16_t) 0, I0, 0, J0, 0, d0)) ;
2909 ERR1 (A, GrB_Matrix_assign_UINT16_(A , NULL, NULL, (uint16_t) 0, I0, 0, J0, 0, d0)) ;
2910 ERR1 (A, GrB_Matrix_assign_UINT16_(A , NULL, NULL, (uint16_t) 0, I , 0, J0, 0, d0)) ;
2911
2912 ERR1 (A0, GrB_Matrix_assign_INT32_(A0, NULL, NULL, (int32_t) 0, I0, 0, J0, 0, d0)) ;
2913 ERR1 (A, GrB_Matrix_assign_INT32_(A , NULL, NULL, (int32_t) 0, I0, 0, J0, 0, d0)) ;
2914 ERR1 (A, GrB_Matrix_assign_INT32_(A , NULL, NULL, (int32_t) 0, I , 0, J0, 0, d0)) ;
2915
2916 ERR1 (A0, GrB_Matrix_assign_UINT32_(A0, NULL, NULL, (uint32_t) 0, I0, 0, J0, 0, d0)) ;
2917 ERR1 (A, GrB_Matrix_assign_UINT32_(A , NULL, NULL, (uint32_t) 0, I0, 0, J0, 0, d0)) ;
2918 ERR1 (A, GrB_Matrix_assign_UINT32_(A , NULL, NULL, (uint32_t) 0, I , 0, J0, 0, d0)) ;
2919
2920 ERR1 (A0, GrB_Matrix_assign_INT64_(A0, NULL, NULL, (int64_t) 0, I0, 0, J0, 0, d0)) ;
2921 ERR1 (A, GrB_Matrix_assign_INT64_(A , NULL, NULL, (int64_t) 0, I0, 0, J0, 0, d0)) ;
2922 ERR1 (A, GrB_Matrix_assign_INT64_(A , NULL, NULL, (int64_t) 0, I , 0, J0, 0, d0)) ;
2923
2924 ERR1 (A0, GrB_Matrix_assign_UINT64_(A0, NULL, NULL, (uint64_t) 0, I0, 0, J0, 0, d0)) ;
2925 ERR1 (A, GrB_Matrix_assign_UINT64_(A , NULL, NULL, (uint64_t) 0, I0, 0, J0, 0, d0)) ;
2926 ERR1 (A, GrB_Matrix_assign_UINT64_(A , NULL, NULL, (uint64_t) 0, I , 0, J0, 0, d0)) ;
2927
2928 ERR1 (A0, GrB_Matrix_assign_FP32_(A0, NULL, NULL, (float) 0, I0, 0, J0, 0, d0)) ;
2929 ERR1 (A, GrB_Matrix_assign_FP32_(A , NULL, NULL, (float) 0, I0, 0, J0, 0, d0)) ;
2930 ERR1 (A, GrB_Matrix_assign_FP32_(A , NULL, NULL, (float) 0, I , 0, J0, 0, d0)) ;
2931
2932 ERR1 (A0, GrB_Matrix_assign_UDT_(A0, NULL, NULL, (void *) X, I0, 0, J0, 0, d0)) ;
2933 ERR1 (A, GrB_Matrix_assign_UDT_(A , NULL, NULL, (void *) X, I0, 0, J0, 0, d0)) ;
2934 ERR1 (A, GrB_Matrix_assign_UDT_(A , NULL, NULL, (void *) X, I , 0, J0, 0, d0)) ;
2935 ERR1 (A, GrB_Matrix_assign_UDT_(A , NULL, NULL, (void *) NULL, I , 0, J, 0, d0)) ;
2936
2937 expected = GrB_UNINITIALIZED_OBJECT ;
2938
2939 v0 = vgunk ;
2940 A0 = Agunk ;
2941 d0 = dgunk ;
2942 op0 = op2gunk ;
2943
2944 ERR1 (v0, GrB_Vector_assign_(v0, NULL, NULL, v0, I, 0, d0)) ; // vector assign
2945 ERR1 (v, GrB_Vector_assign_(v , v0 , NULL, v0, I, 0, d0)) ;
2946 ERR1 (v, GrB_Vector_assign_(v , v , NULL, v0, I, 0, d0)) ;
2947 ERR1 (v, GrB_Vector_assign_(v , v , NULL, v , I, 0, d0)) ;
2948 ERR1 (v, GrB_Vector_assign_(v , v , op0 , v , I, 0, NULL)) ;
2949
2950 ERR1 (A0, GrB_Matrix_assign_(A0, NULL, NULL, A0, I, 0, J, 0, d0)) ; // matrix assign
2951 ERR1 (A, GrB_Matrix_assign_(A , A0 , NULL, A0, I, 0, J, 0, d0)) ;
2952 ERR1 (A, GrB_Matrix_assign_(A , A , NULL, A0, I, 0, J, 0, d0)) ;
2953 ERR1 (A, GrB_Matrix_assign_(A , A , NULL, A , I, 0, J, 0, d0)) ;
2954 ERR1 (A, GrB_Matrix_assign_(A , A , op0 , A , I, 0, J, 0, NULL)) ;
2955
2956 ERR1 (A0, GrB_Col_assign_(A0, NULL, NULL, v0, I, 0, 0, d0)) ; // column assign
2957 ERR1 (A, GrB_Col_assign_(A , v0 , NULL, v0, I, 0, 0, d0)) ;
2958 ERR1 (A, GrB_Col_assign_(A , v , NULL, v0, I, 0, 0, d0)) ;
2959 ERR1 (A, GrB_Col_assign_(A , v , NULL, v , I, 0, 0, d0)) ;
2960 ERR1 (A, GrB_Col_assign_(A , v , op0 , v , I, 0, 0, NULL)) ;
2961
2962 ERR1 (A0, GrB_Row_assign_(A0, NULL, NULL, v0, 0, J, 0, d0)) ; // row assign
2963 ERR1 (A, GrB_Row_assign_(A , v0 , NULL, v0, 0, J, 0, d0)) ;
2964 ERR1 (A, GrB_Row_assign_(A , v , NULL, v0, 0, J, 0, d0)) ;
2965 ERR1 (A, GrB_Row_assign_(A , v , NULL, v , 0, J, 0, d0)) ;
2966 ERR1 (A, GrB_Row_assign_(A , NULL, op0 , v , 0, J, 0, NULL)) ;
2967
2968 ERR1 (v0, GrB_Vector_assign_FP64_(v0, NULL, NULL, x, I, 0, d0)) ; // vector scalar
2969 ERR1 (v, GrB_Vector_assign_FP64_(v , v0 , NULL, x, I, 0, d0)) ;
2970 ERR1 (v, GrB_Vector_assign_FP64_(v , v , NULL, x, I, 0, d0)) ;
2971 ERR1 (v, GrB_Vector_assign_FP64_(v , v , op0 , x, I, 0, NULL)) ;
2972
2973 ERR1 (v0, GrB_Vector_assign_BOOL_(v0, NULL, NULL, (bool) 0, I, 0, d0)) ;
2974 ERR1 (v, GrB_Vector_assign_BOOL_(v , v0 , NULL, (bool) 0, I, 0, d0)) ;
2975 ERR1 (v, GrB_Vector_assign_BOOL_(v , v , NULL, (bool) 0, I, 0, d0)) ;
2976 ERR1 (v, GrB_Vector_assign_BOOL_(v , v , op0 , (bool) 0, I, 0, NULL)) ;
2977
2978 ERR1 (v0, GrB_Vector_assign_INT8_(v0, NULL, NULL, (int8_t) 0, I, 0, d0)) ;
2979 ERR1 (v, GrB_Vector_assign_INT8_(v , v0 , NULL, (int8_t) 0, I, 0, d0)) ;
2980 ERR1 (v, GrB_Vector_assign_INT8_(v , v , NULL, (int8_t) 0, I, 0, d0)) ;
2981 ERR1 (v, GrB_Vector_assign_INT8_(v , v , op0 , (int8_t) 0, I, 0, NULL)) ;
2982
2983 ERR1 (v0, GrB_Vector_assign_UINT8_(v0, NULL, NULL, (uint8_t) 0, I, 0, d0)) ;
2984 ERR1 (v, GrB_Vector_assign_UINT8_(v , v0 , NULL, (uint8_t) 0, I, 0, d0)) ;
2985 ERR1 (v, GrB_Vector_assign_UINT8_(v , v , NULL, (uint8_t) 0, I, 0, d0)) ;
2986 ERR1 (v, GrB_Vector_assign_UINT8_(v , v , NULL, (uint8_t) 0, I, 0, d0)) ;
2987
2988 ERR1 (v0, GrB_Vector_assign_INT16_(v0, NULL, NULL, (int16_t) 0, I, 0, d0)) ;
2989 ERR1 (v, GrB_Vector_assign_INT16_(v , v0 , NULL, (int16_t) 0, I, 0, d0)) ;
2990 ERR1 (v, GrB_Vector_assign_INT16_(v , v , NULL, (int16_t) 0, I, 0, d0)) ;
2991 ERR1 (v, GrB_Vector_assign_INT16_(v , v , op0 , (int16_t) 0, I, 0, NULL)) ;
2992
2993 ERR1 (v0, GrB_Vector_assign_UINT16_(v0, NULL, NULL, (uint16_t) 0, I, 0, d0)) ;
2994 ERR1 (v, GrB_Vector_assign_UINT16_(v , v0 , NULL, (uint16_t) 0, I, 0, d0)) ;
2995 ERR1 (v, GrB_Vector_assign_UINT16_(v , v , NULL, (uint16_t) 0, I, 0, d0)) ;
2996 ERR1 (v, GrB_Vector_assign_UINT16_(v , v , op0 , (uint16_t) 0, I, 0, NULL)) ;
2997
2998 ERR1 (v0, GrB_Vector_assign_INT32_(v0, NULL, NULL, (int32_t) 0, I, 0, d0)) ;
2999 ERR1 (v, GrB_Vector_assign_INT32_(v , v0 , NULL, (int32_t) 0, I, 0, d0)) ;
3000 ERR1 (v, GrB_Vector_assign_INT32_(v , v , NULL, (int32_t) 0, I, 0, d0)) ;
3001 ERR1 (v, GrB_Vector_assign_INT32_(v , v , op0 , (int32_t) 0, I, 0, NULL)) ;
3002
3003 ERR1 (v0, GrB_Vector_assign_UINT32_(v0, NULL, NULL, (uint32_t) 0, I, 0, d0)) ;
3004 ERR1 (v, GrB_Vector_assign_UINT32_(v , v0 , NULL, (uint32_t) 0, I, 0, d0)) ;
3005 ERR1 (v, GrB_Vector_assign_UINT32_(v , v , NULL, (uint32_t) 0, I, 0, d0)) ;
3006 ERR1 (v, GrB_Vector_assign_UINT32_(v , v , op0 , (uint32_t) 0, I, 0, NULL)) ;
3007
3008 ERR1 (v0, GrB_Vector_assign_INT64_(v0, NULL, NULL, (int64_t) 0, I, 0, d0)) ;
3009 ERR1 (v, GrB_Vector_assign_INT64_(v , v0 , NULL, (int64_t) 0, I, 0, d0)) ;
3010 ERR1 (v, GrB_Vector_assign_INT64_(v , v , NULL, (int64_t) 0, I, 0, d0)) ;
3011 ERR1 (v, GrB_Vector_assign_INT64_(v , v , op0 , (int64_t) 0, I, 0, NULL)) ;
3012
3013 ERR1 (v0, GrB_Vector_assign_UINT64_(v0, NULL, NULL, (uint64_t) 0, I, 0, d0)) ;
3014 ERR1 (v, GrB_Vector_assign_UINT64_(v , v0 , NULL, (uint64_t) 0, I, 0, d0)) ;
3015 ERR1 (v, GrB_Vector_assign_UINT64_(v , v , NULL, (uint64_t) 0, I, 0, d0)) ;
3016 ERR1 (v, GrB_Vector_assign_UINT64_(v , v , op0 , (uint64_t) 0, I, 0, NULL)) ;
3017
3018 ERR1 (v0, GrB_Vector_assign_FP32_(v0, NULL, NULL, (float) 0, I, 0, d0)) ;
3019 ERR1 (v, GrB_Vector_assign_FP32_(v , v0 , NULL, (float) 0, I, 0, d0)) ;
3020 ERR1 (v, GrB_Vector_assign_FP32_(v , v , NULL, (float) 0, I, 0, d0)) ;
3021 ERR1 (v, GrB_Vector_assign_FP32_(v , v , op0 , (float) 0, I, 0, NULL)) ;
3022
3023 ERR1 (v0, GrB_Vector_assign_UDT_(v0, NULL, NULL, (void *) X, I, 0, d0)) ;
3024 ERR1 (v, GrB_Vector_assign_UDT_(v , v0 , NULL, (void *) X, I, 0, d0)) ;
3025 ERR1 (v, GrB_Vector_assign_UDT_(v , v , NULL, (void *) X, I, 0, d0)) ;
3026 ERR1 (v, GrB_Vector_assign_UDT_(v , v , op0 , (void *) X, I, 0, NULL)) ;
3027
3028 ERR1 (A0, GrB_Matrix_assign_FP64_(A0, NULL, NULL, x, I, 0, J, 0, d0)) ; // matrix scalar
3029 ERR1 (A, GrB_Matrix_assign_FP64_(A , A0 , NULL, x, I, 0, J, 0, d0)) ;
3030 ERR1 (A, GrB_Matrix_assign_FP64_(A , A , NULL, x, I, 0, J, 0, d0)) ;
3031 ERR1 (A, GrB_Matrix_assign_FP64_(A , A , op0 , x, I, 0, J, 0, NULL)) ;
3032
3033 ERR1 (A0, GrB_Matrix_assign_BOOL_(A0, NULL, NULL, (bool) 0, I, 0, J, 0, d0)) ;
3034 ERR1 (A, GrB_Matrix_assign_BOOL_(A , A0 , NULL, (bool) 0, I, 0, J, 0, d0)) ;
3035 ERR1 (A, GrB_Matrix_assign_BOOL_(A , A , NULL, (bool) 0, I, 0, J, 0, d0)) ;
3036 ERR1 (A, GrB_Matrix_assign_BOOL_(A , A , op0 , (bool) 0, I, 0, J, 0, NULL)) ;
3037
3038 ERR1 (A0, GrB_Matrix_assign_INT8_(A0, NULL, NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
3039 ERR1 (A, GrB_Matrix_assign_INT8_(A , A0 , NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
3040 ERR1 (A, GrB_Matrix_assign_INT8_(A , A , NULL, (int8_t) 0, I, 0, J, 0, d0)) ;
3041 ERR1 (A, GrB_Matrix_assign_INT8_(A , A , op0 , (int8_t) 0, I, 0, J, 0, NULL)) ;
3042
3043 ERR1 (A0, GrB_Matrix_assign_UINT8_(A0, NULL, NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
3044 ERR1 (A, GrB_Matrix_assign_UINT8_(A , A0 , NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
3045 ERR1 (A, GrB_Matrix_assign_UINT8_(A , A , NULL, (uint8_t) 0, I, 0, J, 0, d0)) ;
3046 ERR1 (A, GrB_Matrix_assign_UINT8_(A , A , op0 , (uint8_t) 0, I, 0, J, 0, NULL)) ;
3047
3048 ERR1 (A0, GrB_Matrix_assign_INT16_(A0, NULL, NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
3049 ERR1 (A, GrB_Matrix_assign_INT16_(A , A0 , NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
3050 ERR1 (A, GrB_Matrix_assign_INT16_(A , A , NULL, (int16_t) 0, I, 0, J, 0, d0)) ;
3051 ERR1 (A, GrB_Matrix_assign_INT16_(A , A , op0 , (int16_t) 0, I, 0, J, 0, NULL)) ;
3052
3053 ERR1 (A0, GrB_Matrix_assign_UINT16_(A0, NULL, NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
3054 ERR1 (A, GrB_Matrix_assign_UINT16_(A , A0 , NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
3055 ERR1 (A, GrB_Matrix_assign_UINT16_(A , A , NULL, (uint16_t) 0, I, 0, J, 0, d0)) ;
3056 ERR1 (A, GrB_Matrix_assign_UINT16_(A , A , op0 , (uint16_t) 0, I, 0, J, 0, NULL)) ;
3057
3058 ERR1 (A0, GrB_Matrix_assign_INT32_(A0, NULL, NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
3059 ERR1 (A, GrB_Matrix_assign_INT32_(A , A0 , NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
3060 ERR1 (A, GrB_Matrix_assign_INT32_(A , A , NULL, (int32_t) 0, I, 0, J, 0, d0)) ;
3061 ERR1 (A, GrB_Matrix_assign_INT32_(A , A , op0 , (int32_t) 0, I, 0, J, 0, NULL)) ;
3062
3063 ERR1 (A0, GrB_Matrix_assign_UINT32_(A0, NULL, NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
3064 ERR1 (A, GrB_Matrix_assign_UINT32_(A , A0 , NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
3065 ERR1 (A, GrB_Matrix_assign_UINT32_(A , A , NULL, (uint32_t) 0, I, 0, J, 0, d0)) ;
3066 ERR1 (A, GrB_Matrix_assign_UINT32_(A , A , op0 , (uint32_t) 0, I, 0, J, 0, NULL)) ;
3067
3068 ERR1 (A0, GrB_Matrix_assign_INT64_(A0, NULL, NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
3069 ERR1 (A, GrB_Matrix_assign_INT64_(A , A0 , NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
3070 ERR1 (A, GrB_Matrix_assign_INT64_(A , A , NULL, (int64_t) 0, I, 0, J, 0, d0)) ;
3071 ERR1 (A, GrB_Matrix_assign_INT64_(A , A , op0 , (int64_t) 0, I, 0, J, 0, NULL)) ;
3072
3073 ERR1 (A0, GrB_Matrix_assign_UINT64_(A0, NULL, NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
3074 ERR1 (A, GrB_Matrix_assign_UINT64_(A , A0 , NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
3075 ERR1 (A, GrB_Matrix_assign_UINT64_(A , A , NULL, (uint64_t) 0, I, 0, J, 0, d0)) ;
3076 ERR1 (A, GrB_Matrix_assign_UINT64_(A , A , op0 , (uint64_t) 0, I, 0, J, 0, NULL)) ;
3077
3078 ERR1 (A0, GrB_Matrix_assign_FP32_(A0, NULL, NULL, (float) 0, I, 0, J, 0, d0)) ;
3079 ERR1 (A, GrB_Matrix_assign_FP32_(A , A0 , NULL, (float) 0, I, 0, J, 0, d0)) ;
3080 ERR1 (A, GrB_Matrix_assign_FP32_(A , A , NULL, (float) 0, I, 0, J, 0, d0)) ;
3081 ERR1 (A, GrB_Matrix_assign_FP32_(A , A , op0 , (float) 0, I, 0, J, 0, NULL)) ;
3082
3083 ERR1 (A0, GrB_Matrix_assign_UDT_(A0, NULL, NULL, (void *) X, I, 0, J, 0, d0)) ;
3084 ERR1 (A, GrB_Matrix_assign_UDT_(A , A0 , NULL, (void *) X, I, 0, J, 0, d0)) ;
3085 ERR1 (A, GrB_Matrix_assign_UDT_(A , A , NULL, (void *) X, I, 0, J, 0, d0)) ;
3086 ERR1 (A, GrB_Matrix_assign_UDT_(A , A , op0 , (void *) X, I, 0, J, 0, NULL)) ;
3087
3088 v0 = NULL ;
3089 A0 = NULL ;
3090 d0 = NULL ;
3091 op0 = Complex_plus ;
3092
3093 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3094
3095 ERR1 (v, GrB_Vector_assign_(v, z , NULL, v, I, 0, d0)) ; // vector assign
3096 ERR1 (v, GrB_Vector_assign_(v, v0, op0 , v, I, 0, d0)) ;
3097 ERR1 (v, GrB_Vector_assign_(v, v0, op0 , z, I, 0, d0)) ;
3098 ERR1 (z, GrB_Vector_assign_(z, v0, o2 , v, I, 0, d0)) ;
3099 ERR1 (v, GrB_Vector_assign_(v, v0, o2 , z, I, 0, d0)) ;
3100 ERR1 (v, GrB_Vector_assign_(v, v0, NULL, z, I, 0, d0)) ;
3101
3102 ERR1 (A, GrB_Matrix_assign_(A, Z , NULL, A, I, 0, J, 0, d0)) ; // matrix assign
3103 ERR1 (A, GrB_Matrix_assign_(A, A0, op0 , A, I, 0, J, 0, d0)) ;
3104 ERR1 (A, GrB_Matrix_assign_(A, A0, op0 , Z, I, 0, J, 0, d0)) ;
3105 ERR1 (Z, GrB_Matrix_assign_(Z, A0, o2 , A, I, 0, J, 0, d0)) ;
3106 ERR1 (A, GrB_Matrix_assign_(A, A0, o2 , Z, I, 0, J, 0, d0)) ;
3107 ERR1 (A, GrB_Matrix_assign_(A, A0, NULL, Z, I, 0, J, 0, d0)) ;
3108
3109 ERR1 (A, GrB_Col_assign_(A, z , NULL, v, I, 0, 0, d0)) ; // column assign
3110 ERR1 (A, GrB_Col_assign_(A, v0, op0 , v, I, 0, 0, d0)) ;
3111 ERR1 (A, GrB_Col_assign_(A, v0, op0 , z, I, 0, 0, d0)) ;
3112 ERR1 (Z, GrB_Col_assign_(Z, v0, o2 , v, I, 0, 0, d0)) ;
3113 ERR1 (A, GrB_Col_assign_(A, v0, o2 , z, I, 0, 0, d0)) ;
3114 ERR1 (A, GrB_Col_assign_(A, v0, NULL, z, I, 0, 0, d0)) ;
3115
3116 ERR1 (A, GrB_Row_assign_(A, z , NULL, v, 0, J, 0, d0)) ; // row assign
3117 ERR1 (A, GrB_Row_assign_(A, v0, op0 , v, 0, J, 0, d0)) ;
3118 ERR1 (A, GrB_Row_assign_(A, v0, op0 , z, 0, J, 0, d0)) ;
3119 ERR1 (Z, GrB_Row_assign_(Z, v0, o2 , v, 0, J, 0, d0)) ;
3120 ERR1 (A, GrB_Row_assign_(A, v0, o2 , z, 0, J, 0, d0)) ;
3121 ERR1 (A, GrB_Row_assign_(A, v0, NULL, z, 0, J, 0, d0)) ;
3122
3123 // vector scalar and matrix-scalar
3124 if (Complex == GxB_FC64)
3125 {
3126 OK (GrB_Vector_assign_FP64_(v, z , NULL, x, I, 0, d0)) ;
3127 OK (GrB_Vector_assign_FP64_(v, v0, op0 , x, I, 0, d0)) ;
3128 OK (GrB_Vector_assign_FP64_(z, v0, o2 , x, I, 0, d0)) ;
3129 OK (GrB_Matrix_assign_FP64_(A, A0, op0 , x, I, 0, J, 0, d0)) ;
3130 OK (GrB_Matrix_assign_FP64_(Z, A0, o2 , x, I, 0, J, 0, d0)) ;
3131 }
3132 else
3133 {
3134 ERR1 (v, GrB_Vector_assign_FP64_(v, z , NULL, x, I, 0, d0)) ;
3135 ERR1 (v, GrB_Vector_assign_FP64_(v, v0, op0 , x, I, 0, d0)) ;
3136 ERR1 (z, GrB_Vector_assign_FP64_(z, v0, o2 , x, I, 0, d0)) ;
3137 ERR1 (A, GrB_Matrix_assign_FP64_(A, A0, op0 , x, I, 0, J, 0, d0)) ;
3138 ERR1 (Z, GrB_Matrix_assign_FP64_(Z, A0, o2 , x, I, 0, J, 0, d0)) ;
3139 }
3140
3141 expected = GrB_DOMAIN_MISMATCH ;
3142 ERR1 (v, GrB_Vector_assign_UDT_(v, v0, op0 ,(void *) &c, I, 0, d0)) ;
3143 ERR1 (v, GrB_Vector_assign_UDT_(v, v0, o2 ,(void *) &c, I, 0, d0)) ;
3144 ERR1 (v, GrB_Vector_assign_UDT_(v, v0, NULL,(void *) &c, I, 0, d0)) ;
3145
3146 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3147
3148 ERR1 (A, GrB_Matrix_assign_FP64_(A, Z , NULL, x, I, 0, J, 0, d0)) ;
3149
3150 expected = GrB_DOMAIN_MISMATCH ;
3151 ERR1 (A, GrB_Matrix_assign_UDT_(A, A0, op0 ,(void *) &c , I, 0, J, 0, d0)) ;
3152 ERR1 (A, GrB_Matrix_assign_UDT_(A, A0, o2 ,(void *) &c , I, 0, J, 0, d0)) ;
3153 ERR1 (A, GrB_Matrix_assign_UDT_(A, A0, NULL,(void *) &c , I, 0, J, 0, d0)) ;
3154
3155 expected = GrB_DIMENSION_MISMATCH ;
3156
3157 ERR1 (A, GrB_Matrix_assign_(A, NULL, NULL, A, I, 2, J, 3, d0)) ;
3158 ERR1 (A, GrB_Matrix_assign_(A, NULL, NULL, A, I, 2, J, 3, dtn)) ;
3159 ERR1 (A, GrB_Row_assign_(A , v , NULL, v , 0, J, 0, NULL)) ;
3160
3161 GrB_Vector v5 ;
3162 OK (GrB_Vector_new (&v5, GrB_BOOL, 5)) ;
3163 GxB_Matrix_fprint_(A, G3, NULL) ;
3164 GxB_Vector_fprint_(v5, G3, NULL) ;
3165 GxB_Vector_fprint_(v, G3, NULL) ;
3166 ERR1 (A, GrB_Col_assign_(A, v5 , NULL, v, GrB_ALL, 0, 0, NULL)) ; // column assign
3167 GrB_Matrix_error_(&err, A) ;
3168 printf ("mask wrong size:\n%s\n", err) ;
3169 OK (GrB_Vector_free_(&v5)) ;
3170
3171 // matrix assign, mask wrong size
3172 GrB_Matrix A5 ;
3173 OK (GrB_Matrix_new (&A5, GrB_BOOL, 5, 5)) ;
3174 GB_Matrix_check (A, "A", G3, NULL) ;
3175 GB_Matrix_check (A5, "A5", G3, NULL) ;
3176 ERR1 (A, GrB_Matrix_assign_(A, A5, NULL, A, GrB_ALL, 0, GrB_ALL, 0, NULL)) ;
3177 GrB_Matrix_error_(&err, A) ;
3178 printf ("mask wrong size:\n%s\n", err) ;
3179 OK (GrB_Matrix_free_(&A5)) ;
3180
3181 // change of op-2nd type
3182 int64_t I_0 = 0 ;
3183 int64_t J_0 = 0 ;
3184 double X_0 = 42 ;
3185 OK (GrB_Matrix_new (&A5, GrB_FP32, 5, 5)) ;
3186 OK (GrB_Matrix_assign_FP32 (A5, NULL, GrB_SECOND_FP32, 42,
3187 GrB_ALL, 0, GrB_ALL, 0, NULL)) ;
3188 GB_Matrix_check (A5, "A5 with 2nd:fp32", G3, NULL) ;
3189 OK (GrB_Matrix_assign_FP32 (A5, NULL, GrB_SECOND_BOOL, 42,
3190 GrB_ALL, 0, GrB_ALL, 0, NULL)) ;
3191 GB_Matrix_check (A5, "A5 with 2nd:bool", G3, NULL) ;
3192 OK (GrB_Matrix_nvals (&nvals, A5)) ;
3193 OK (GrB_Matrix_wait_(&A5)) ;
3194 CHECK (nvals == 25) ;
3195 GB_Matrix_check (A5, "A5 done", G3, NULL) ;
3196
3197 OK (GrB_Matrix_free_(&A5)) ;
3198
3199 //--------------------------------------------------------------------------
3200 // apply
3201 //--------------------------------------------------------------------------
3202
3203 printf ("GrB_apply----------------------------------------------------\n") ;
3204 expected = GrB_NULL_POINTER ;
3205
3206 ERR1 (v0, GrB_Vector_apply (v0, NULL, NULL, NULL, v0, d0)) ;
3207 ERR1 (v, GrB_Vector_apply (v , NULL, NULL, NULL, v0, d0)) ;
3208 ERR1 (v, GrB_Vector_apply (v , NULL, NULL, NULL, v , d0)) ;
3209
3210 ERR1 (A0, GrB_Matrix_apply (A0, NULL, NULL, NULL, A0, d0)) ;
3211 ERR1 (A, GrB_Matrix_apply (A , NULL, NULL, NULL, A0, d0)) ;
3212 ERR1 (A, GrB_Matrix_apply (A , NULL, NULL, NULL, A , d0)) ;
3213
3214 expected = GrB_UNINITIALIZED_OBJECT ;
3215
3216 v0 = vgunk ;
3217 A0 = Agunk ;
3218 d0 = dgunk ;
3219 op0 = op2gunk ;
3220
3221 ERR1 (v0, GrB_Vector_apply_(v0, NULL, NULL, op1gunk, v0, d0)) ;
3222 ERR1 (v, GrB_Vector_apply_(v , v0 , NULL, op1gunk, v0, d0)) ;
3223 ERR1 (v, GrB_Vector_apply_(v , v , NULL, op1gunk, v0, d0)) ;
3224 ERR1 (v, GrB_Vector_apply_(v , v , NULL, op1gunk, v , d0)) ;
3225 ERR1 (v, GrB_Vector_apply_(v , v , op0 , op1gunk, v , NULL)) ;
3226 ERR1 (v, GrB_Vector_apply_(v , v , NULL, op1gunk, v , NULL)) ;
3227
3228 ERR1 (A0, GrB_Matrix_apply_(A0, NULL, NULL, op1gunk, A0, d0)) ;
3229 ERR1 (A, GrB_Matrix_apply_(A , A0 , NULL, op1gunk, A0, d0)) ;
3230 ERR1 (A, GrB_Matrix_apply_(A , A , NULL, op1gunk, A0, d0)) ;
3231 ERR1 (A, GrB_Matrix_apply_(A , A , NULL, op1gunk, A , d0)) ;
3232 ERR1 (A, GrB_Matrix_apply_(A , A , op0 , op1gunk, A , NULL)) ;
3233 ERR1 (A, GrB_Matrix_apply_(A , A , NULL, op1gunk, A , NULL)) ;
3234
3235 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3236
3237 o2 = Complex_plus ;
3238 ERR1 (A, GrB_Matrix_apply_(A, Z , NULL, GrB_AINV_FP64, A, NULL)) ;
3239
3240 if (Complex == GxB_FC64)
3241 {
3242 OK (GrB_Matrix_apply_(A, NULL, o2 , GrB_AINV_FP64, A, NULL)) ;
3243 OK (GrB_Matrix_apply_(Z, NULL, NULL, GrB_AINV_FP64, Z, NULL)) ;
3244 OK (GrB_Matrix_apply_BinaryOp1st_INT32_(Z, NULL, NULL, o2, 1, Z, NULL)) ;
3245 OK (GrB_Matrix_apply_BinaryOp2nd_INT32_(Z, NULL, NULL, o2, Z, 1, NULL)) ;
3246 }
3247 else
3248 {
3249 ERR1 (A, GrB_Matrix_apply_(A, NULL, o2 , GrB_AINV_FP64, A, NULL)) ;
3250 ERR1 (Z, GrB_Matrix_apply_(Z, NULL, NULL, GrB_AINV_FP64, Z, NULL)) ;
3251 ERR1 (Z, GrB_Matrix_apply_BinaryOp1st_INT32_(Z, NULL, NULL, o2, 1, Z, NULL)) ;
3252 ERR1 (Z, GrB_Matrix_apply_BinaryOp2nd_INT32_(Z, NULL, NULL, o2, Z, 1, NULL)) ;
3253 }
3254
3255 ERR1 (A, GrB_Matrix_apply_(A, NULL, o2 , GrB_AINV_FP64, Z, NULL)) ;
3256 ERR1 (A, GrB_Matrix_apply_(A, NULL, NULL, GrB_AINV_FP64, Z, NULL)) ;
3257 ERR1 (Z, GrB_Matrix_apply_(Z, NULL, NULL, GrB_AINV_FP64, A, NULL)) ;
3258
3259 ERR1 (Z, GrB_Matrix_apply_BinaryOp1st_INT32_(Z, NULL, NULL, o2, 1, A, NULL)) ;
3260 ERR1 (Z, GrB_Matrix_apply_BinaryOp2nd_INT32_(Z, NULL, NULL, o2, A, 1, NULL)) ;
3261
3262 v0 = NULL ;
3263 A0 = NULL ;
3264 d0 = NULL ;
3265 op0 = NULL ;
3266
3267 expected = GrB_DIMENSION_MISMATCH ;
3268
3269 ERR1 (A, GrB_Matrix_apply_(A , NULL, NULL, GrB_AINV_FP64, C , d0)) ;
3270
3271 //--------------------------------------------------------------------------
3272 // select
3273 //--------------------------------------------------------------------------
3274
3275 printf ("GxB_select---------------------------------------------------\n") ;
3276 CHECK (selectop == NULL) ;
3277 OK (GxB_SelectOp_new (&selectop, fselect, GrB_FP64, GrB_FP64)) ;
3278 CHECK (selectop != NULL) ;
3279 OK (GB_SelectOp_check (selectop, "select op OK", G3, NULL)) ;
3280
3281 expected = GrB_NULL_POINTER ;
3282
3283 ERR1 (v0, GxB_Vector_select_(v0, NULL, NULL, NULL, v0, NULL, d0)) ;
3284 ERR1 (v, GxB_Vector_select_(v , NULL, NULL, NULL, v0, NULL, d0)) ;
3285 ERR1 (v, GxB_Vector_select_(v , NULL, NULL, NULL, v , NULL, d0)) ;
3286
3287 ERR1 (A0, GxB_Matrix_select_(A0, NULL, NULL, NULL, A0, NULL, d0)) ;
3288 ERR1 (A, GxB_Matrix_select_(A , NULL, NULL, NULL, A0, NULL, d0)) ;
3289 ERR1 (A, GxB_Matrix_select_(A , NULL, NULL, NULL, A , NULL, d0)) ;
3290
3291 CHECK (selectopgunk == NULL) ;
3292 OK (GxB_SelectOp_new (&selectopgunk, fselect, GrB_FP64, GrB_FP64)) ;
3293 CHECK (selectopgunk != NULL) ;
3294 selectopgunk->magic = 22309483 ;
3295 expected = GrB_UNINITIALIZED_OBJECT ;
3296 ERR (GB_SelectOp_check (selectopgunk, "select gunk", G3, NULL)) ;
3297
3298 expected = GrB_UNINITIALIZED_OBJECT ;
3299
3300 v0 = vgunk ;
3301 A0 = Agunk ;
3302 d0 = dgunk ;
3303 op0 = op2gunk ;
3304 sel0 = selectopgunk ;
3305
3306 ERR1 (v0, GxB_Vector_select_(v0, NULL, NULL, sel0, v0, NULL, d0)) ;
3307 ERR1 (v, GxB_Vector_select_(v , v0 , NULL, sel0, v0, NULL, d0)) ;
3308 ERR1 (v, GxB_Vector_select_(v , v , NULL, sel0, v0, NULL, d0)) ;
3309 ERR1 (v, GxB_Vector_select_(v , v , NULL, sel0, v , NULL, d0)) ;
3310 ERR1 (v, GxB_Vector_select_(v , v , op0 , sel0, v , NULL, NULL)) ;
3311 ERR1 (v, GxB_Vector_select_(v , v , NULL, sel0, v , NULL, NULL)) ;
3312
3313 ERR1 (A0, GxB_Matrix_select_(A0, NULL, NULL, sel0, A0, NULL, d0)) ;
3314 ERR1 (A, GxB_Matrix_select_(A , A0 , NULL, sel0, A0, NULL, d0)) ;
3315 ERR1 (A, GxB_Matrix_select_(A , A , NULL, sel0, A0, NULL, d0)) ;
3316 ERR1 (A, GxB_Matrix_select_(A , A , NULL, sel0, A , NULL, d0)) ;
3317 ERR1 (A, GxB_Matrix_select_(A , A , op0 , sel0, A , NULL, NULL)) ;
3318 ERR1 (A, GxB_Matrix_select_(A , A , NULL, sel0, A , NULL, NULL)) ;
3319
3320 expected = GrB_DOMAIN_MISMATCH ;
3321
3322 double thresh = 42 ;
3323
3324 GxB_Scalar Thunk = NULL ;
3325 OK (GxB_Scalar_new (&Thunk, GrB_FP64)) ;
3326 OK (GxB_Scalar_setElement_FP64 (Thunk, thresh)) ;
3327
3328 o2 = Complex_plus ;
3329 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3330 if (Complex == GxB_FC64)
3331 {
3332 OK (GxB_Matrix_select_(A, NULL, o2 , selectop, A, Thunk, NULL)) ;
3333 OK (GxB_Matrix_select_(Z, NULL, NULL, selectop, Z, Thunk, NULL)) ;
3334 }
3335 else
3336 {
3337 ERR1 (A, GxB_Matrix_select_(A, NULL, o2 , selectop, A, Thunk, NULL)) ;
3338 ERR1 (Z, GxB_Matrix_select_(Z, NULL, NULL, selectop, Z, Thunk, NULL)) ;
3339 }
3340
3341 ERR1 (A, GxB_Matrix_select_(A, Z , NULL, selectop, A, Thunk, NULL)) ;
3342 ERR1 (A, GxB_Matrix_select_(A, NULL, o2 , selectop, Z, Thunk, NULL)) ;
3343 ERR1 (A, GxB_Matrix_select_(A, NULL, NULL, selectop, Z, Thunk, NULL)) ;
3344 ERR1 (Z, GxB_Matrix_select_(Z, NULL, NULL, selectop, A, Thunk, NULL)) ;
3345
3346 v0 = NULL ;
3347 A0 = NULL ;
3348 d0 = NULL ;
3349 op0 = NULL ;
3350 sel0 = NULL ;
3351
3352 OK (GxB_SelectOp_free_(&selectop)) ;
3353 CHECK (selectop == NULL) ;
3354
3355 expected = GrB_DIMENSION_MISMATCH ;
3356
3357 ERR1 (A, GxB_Matrix_select_(A , NULL, NULL, GxB_TRIL, C , NULL, d0)) ;
3358
3359 OK (GxB_Scalar_free_(&Thunk)) ;
3360
3361 //--------------------------------------------------------------------------
3362 // reduce to scalar
3363 //--------------------------------------------------------------------------
3364
3365 printf ("GrB_reduce (to scalar)---------------------------------------\n") ;
3366 expected = GrB_NULL_POINTER ;
3367
3368 o2 = GrB_PLUS_FP32 ;
3369 m2 = GxB_TIMES_FP64_MONOID ;
3370
3371 // matrix to scalar
3372
3373 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m0, A0, d0)) ;
3374 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m0, A , d0)) ;
3375 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m2, A , d0)) ;
3376
3377 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m0, A0, d0)) ;
3378 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m0, A , d0)) ;
3379 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m2, A , d0)) ;
3380
3381 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m0, A0, d0)) ;
3382 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m0, A , d0)) ;
3383 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m2, A , d0)) ;
3384
3385 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m0, A0, d0)) ;
3386 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m0, A , d0)) ;
3387 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m2, A , d0)) ;
3388
3389 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m0, A0, d0)) ;
3390 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m0, A , d0)) ;
3391 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m2, A , d0)) ;
3392
3393 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m0, A0, d0)) ;
3394 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m0, A , d0)) ;
3395 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m2, A , d0)) ;
3396
3397 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m0, A0, d0)) ;
3398 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m0, A , d0)) ;
3399 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m2, A , d0)) ;
3400
3401 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m0, A0, d0)) ;
3402 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m0, A , d0)) ;
3403 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m2, A , d0)) ;
3404
3405 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m0, A0, d0)) ;
3406 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m0, A , d0)) ;
3407 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m2, A , d0)) ;
3408
3409 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m0, A0, d0)) ;
3410 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m0, A , d0)) ;
3411 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m2, A , d0)) ;
3412
3413 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m0, A0, d0)) ;
3414 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m0, A , d0)) ;
3415 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m2, A , d0)) ;
3416
3417 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m0, A0, d0)) ;
3418 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m0, A , d0)) ;
3419 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m2, A , d0)) ;
3420
3421 // vector to scalar
3422
3423 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m0, v0, d0)) ;
3424 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m0, v , d0)) ;
3425 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m2, v , d0)) ;
3426
3427 ERR (GrB_Vector_reduce_INT8_((int8_t *) NULL, op0, m0, v0, d0)) ;
3428 ERR (GrB_Vector_reduce_INT8_((int8_t *) NULL, op0, m0, v , d0)) ;
3429 ERR (GrB_Vector_reduce_INT8_((int8_t *) NULL, op0, m2, v , d0)) ;
3430
3431 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m0, v0, d0)) ;
3432 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m0, v , d0)) ;
3433 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m2, v , d0)) ;
3434
3435 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m0, v0, d0)) ;
3436 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m0, v , d0)) ;
3437 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m2, v , d0)) ;
3438
3439 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m0, v0, d0)) ;
3440 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m0, v , d0)) ;
3441 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m2, v , d0)) ;
3442
3443 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m0, v0, d0)) ;
3444 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m0, v , d0)) ;
3445 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m2, v , d0)) ;
3446
3447 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m0, v0, d0)) ;
3448 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m0, v , d0)) ;
3449 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m2, v , d0)) ;
3450
3451 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m0, v0, d0)) ;
3452 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m0, v , d0)) ;
3453 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m2, v , d0)) ;
3454
3455 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m0, v0, d0)) ;
3456 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m0, v , d0)) ;
3457 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m2, v , d0)) ;
3458
3459 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m0, v0, d0)) ;
3460 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m0, v , d0)) ;
3461 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m2, v , d0)) ;
3462
3463 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m0, v0, d0)) ;
3464 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m0, v , d0)) ;
3465 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m2, v , d0)) ;
3466
3467 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m0, v0, d0)) ;
3468 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m0, v , d0)) ;
3469 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m2, v , d0)) ;
3470
3471 expected = GrB_UNINITIALIZED_OBJECT ;
3472
3473 m0 = monoid_gunk ;
3474 v0 = vgunk ;
3475 A0 = Agunk ;
3476 op0 = op2gunk ;
3477
3478 // matrix to scalar
3479
3480 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m0, A0, d0)) ;
3481 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m0, A , d0)) ;
3482 ERR (GrB_Matrix_reduce_BOOL_((bool *) NULL, op0, m2, A , d0)) ;
3483
3484 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m0, A0, d0)) ;
3485 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m0, A , d0)) ;
3486 ERR (GrB_Matrix_reduce_INT8_((int8_t *) NULL, op0, m2, A , d0)) ;
3487
3488 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m0, A0, d0)) ;
3489 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m0, A , d0)) ;
3490 ERR (GrB_Matrix_reduce_UINT8_((uint8_t *) NULL, op0, m2, A , d0)) ;
3491
3492 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m0, A0, d0)) ;
3493 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m0, A , d0)) ;
3494 ERR (GrB_Matrix_reduce_INT16_((int16_t *) NULL, op0, m2, A , d0)) ;
3495
3496 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m0, A0, d0)) ;
3497 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m0, A , d0)) ;
3498 ERR (GrB_Matrix_reduce_UINT16_((uint16_t *) NULL, op0, m2, A , d0)) ;
3499
3500 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m0, A0, d0)) ;
3501 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m0, A , d0)) ;
3502 ERR (GrB_Matrix_reduce_INT32_((int32_t *) NULL, op0, m2, A , d0)) ;
3503
3504 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m0, A0, d0)) ;
3505 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m0, A , d0)) ;
3506 ERR (GrB_Matrix_reduce_UINT32_((uint32_t *) NULL, op0, m2, A , d0)) ;
3507
3508 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m0, A0, d0)) ;
3509 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m0, A , d0)) ;
3510 ERR (GrB_Matrix_reduce_INT64_((int64_t *) NULL, op0, m2, A , d0)) ;
3511
3512 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m0, A0, d0)) ;
3513 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m0, A , d0)) ;
3514 ERR (GrB_Matrix_reduce_UINT64_((uint64_t *) NULL, op0, m2, A , d0)) ;
3515
3516 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m0, A0, d0)) ;
3517 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m0, A , d0)) ;
3518 ERR (GrB_Matrix_reduce_FP32_((float *) NULL, op0, m2, A , d0)) ;
3519
3520 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m0, A0, d0)) ;
3521 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m0, A , d0)) ;
3522 ERR (GrB_Matrix_reduce_FP64_((double *) NULL, op0, m2, A , d0)) ;
3523
3524 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m0, A0, d0)) ;
3525 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m0, A , d0)) ;
3526 ERR (GrB_Matrix_reduce_UDT_((void *) NULL, op0, m2, A , d0)) ;
3527
3528 // vector to scalar
3529
3530 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m0, v0, d0)) ;
3531 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m0, v , d0)) ;
3532 ERR (GrB_Vector_reduce_BOOL_((bool *) NULL, op0, m2, v , d0)) ;
3533
3534 ERR (GrB_Vector_reduce_INT8 ((int8_t *) NULL, op0, m0, v0, d0)) ;
3535 ERR (GrB_Vector_reduce_INT8 ((int8_t *) NULL, op0, m0, v , d0)) ;
3536 ERR (GrB_Vector_reduce_INT8_((int8_t *) NULL, op0, m2, v , d0)) ;
3537
3538 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m0, v0, d0)) ;
3539 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m0, v , d0)) ;
3540 ERR (GrB_Vector_reduce_UINT8_((uint8_t *) NULL, op0, m2, v , d0)) ;
3541
3542 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m0, v0, d0)) ;
3543 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m0, v , d0)) ;
3544 ERR (GrB_Vector_reduce_INT16_((int16_t *) NULL, op0, m2, v , d0)) ;
3545
3546 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m0, v0, d0)) ;
3547 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m0, v , d0)) ;
3548 ERR (GrB_Vector_reduce_UINT16_((uint16_t *) NULL, op0, m2, v , d0)) ;
3549
3550 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m0, v0, d0)) ;
3551 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m0, v , d0)) ;
3552 ERR (GrB_Vector_reduce_INT32_((int32_t *) NULL, op0, m2, v , d0)) ;
3553
3554 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m0, v0, d0)) ;
3555 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m0, v , d0)) ;
3556 ERR (GrB_Vector_reduce_UINT32_((uint32_t *) NULL, op0, m2, v , d0)) ;
3557
3558 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m0, v0, d0)) ;
3559 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m0, v , d0)) ;
3560 ERR (GrB_Vector_reduce_INT64_((int64_t *) NULL, op0, m2, v , d0)) ;
3561
3562 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m0, v0, d0)) ;
3563 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m0, v , d0)) ;
3564 ERR (GrB_Vector_reduce_UINT64_((uint64_t *) NULL, op0, m2, v , d0)) ;
3565
3566 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m0, v0, d0)) ;
3567 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m0, v , d0)) ;
3568 ERR (GrB_Vector_reduce_FP32_((float *) NULL, op0, m2, v , d0)) ;
3569
3570 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m0, v0, d0)) ;
3571 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m0, v , d0)) ;
3572 ERR (GrB_Vector_reduce_FP64_((double *) NULL, op0, m2, v , d0)) ;
3573
3574 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m0, v0, d0)) ;
3575 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m0, v , d0)) ;
3576 ERR (GrB_Vector_reduce_UDT_((void *) NULL, op0, m2, v , d0)) ;
3577
3578 m0 = NULL ;
3579 v0 = NULL ;
3580 A0 = NULL ;
3581 op0 = NULL ;
3582 expected = GrB_DOMAIN_MISMATCH ;
3583 o2 = Complex_plus ;
3584
3585 if (Complex == GxB_FC64)
3586 {
3587 OK (GrB_Matrix_reduce_FP64 (&x, op0 , GxB_PLUS_FP64_MONOID , Z , d0)) ;
3588 OK (GrB_Matrix_reduce_FP64 (&x, op0 , Complex_plus_monoid , Z , d0)) ;
3589 OK (GrB_Matrix_reduce_FP64 (&x, op0 , Complex_plus_monoid , A , d0)) ;
3590 OK (GrB_Matrix_reduce_FP64 (&x, o2 , Complex_plus_monoid , Z , d0)) ;
3591 OK (GrB_Matrix_reduce_UDT (&c, o2 , Complex_plus_monoid , A , d0)) ;
3592 }
3593 else
3594 {
3595 ERR (GrB_Matrix_reduce_FP64 (&x, op0 , GxB_PLUS_FP64_MONOID , Z , d0)) ;
3596 ERR (GrB_Matrix_reduce_FP64 (&x, op0 , Complex_plus_monoid , Z , d0)) ;
3597 ERR (GrB_Matrix_reduce_FP64 (&x, op0 , Complex_plus_monoid , A , d0)) ;
3598 ERR (GrB_Matrix_reduce_FP64 (&x, o2 , Complex_plus_monoid , Z , d0)) ;
3599 ERR (GrB_Matrix_reduce_UDT (&c, o2 , Complex_plus_monoid , A , d0)) ;
3600 }
3601
3602 //--------------------------------------------------------------------------
3603 // reduce to vector
3604 //--------------------------------------------------------------------------
3605
3606 printf ("GrB_reduce (to vector)---------------------------------------\n") ;
3607 expected = GrB_NULL_POINTER ;
3608
3609 o2 = GrB_PLUS_FP64 ;
3610 m2 = GxB_TIMES_FP64_MONOID ;
3611
3612 ERR1 (v0, GrB_Matrix_reduce_BinaryOp_(v0, NULL, NULL, op0, A0, d0)) ; // reduce via op
3613 ERR1 (v0, GrB_Matrix_reduce_BinaryOp_(v0, NULL, NULL, o2 , A0, d0)) ;
3614 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v , NULL, NULL, o2 , A0, d0)) ;
3615
3616 ERR1 (v0, GrB_Matrix_reduce_Monoid_(v0, NULL, NULL, m0 , A0, d0)) ; // reduce via monoid
3617 ERR1 (v0, GrB_Matrix_reduce_Monoid_(v0, NULL, NULL, m2 , A0, d0)) ;
3618 ERR1 (v, GrB_Matrix_reduce_Monoid_(v , NULL, NULL, m2 , A0, d0)) ;
3619
3620 expected = GrB_UNINITIALIZED_OBJECT ;
3621
3622 m0 = monoid_gunk ;
3623 v0 = vgunk ;
3624 A0 = Agunk ;
3625 op0 = op2gunk ;
3626 d0 = dgunk ;
3627
3628 ERR1 (v0, GrB_Matrix_reduce_BinaryOp_(v0, v0 , op0 , op0, A0, d0)) ; // reduce via op
3629 ERR1 (v0, GrB_Matrix_reduce_BinaryOp_(v0, v0 , op0 , o2 , A0, d0)) ;
3630 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v , v0 , op0 , o2 , A0, d0)) ;
3631 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v , v , op0 , o2 , A0, d0)) ;
3632 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v , v , o2 , o2 , A0, d0)) ;
3633 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v , v , o2 , o2 , A , d0)) ;
3634
3635 ERR1 (v0, GrB_Matrix_reduce_Monoid_(v0, v0 , op0 , m0 , A0, d0)) ; // reduce via monoid
3636 ERR1 (v0, GrB_Matrix_reduce_Monoid_(v0, v0 , op0 , m2 , A0, d0)) ;
3637 ERR1 (v, GrB_Matrix_reduce_Monoid_(v , v0 , op0 , m2 , A0, d0)) ;
3638 ERR1 (v, GrB_Matrix_reduce_Monoid_(v , v , op0 , m2 , A0, d0)) ;
3639 ERR1 (v, GrB_Matrix_reduce_Monoid_(v , v , o2 , m2 , A0, d0)) ;
3640 ERR1 (v, GrB_Matrix_reduce_Monoid_(v , v , o2 , m2 , A , d0)) ;
3641
3642 m0 = NULL ;
3643 v0 = NULL ;
3644 A0 = NULL ;
3645 op0 = NULL ;
3646 d0 = NULL ;
3647
3648 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3649
3650 o2 = Complex_plus ;
3651 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v, z , NULL, GrB_PLUS_FP64, A, d0)) ;
3652 ERR1 (z, GrB_Matrix_reduce_BinaryOp_(z, NULL, NULL, GrB_PLUS_FP64, A, d0)) ;
3653 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v, NULL, o2 , GrB_PLUS_FP64, A, d0)) ;
3654 ERR1 (v, GrB_Matrix_reduce_BinaryOp_(v, NULL, NULL, GrB_PLUS_FP64, Z, d0)) ;
3655
3656 ERR1 (v, GrB_Matrix_reduce_Monoid_(v, z , NULL, GxB_PLUS_FP64_MONOID, A, d0)) ;
3657 ERR1 (z, GrB_Matrix_reduce_Monoid_(z, NULL, NULL, GxB_PLUS_FP64_MONOID, A, d0)) ;
3658 ERR1 (v, GrB_Matrix_reduce_Monoid_(v, NULL, o2 , GxB_PLUS_FP64_MONOID, A, d0)) ;
3659 ERR1 (v, GrB_Matrix_reduce_Monoid_(v, NULL, NULL, GxB_PLUS_FP64_MONOID, Z, d0)) ;
3660
3661 expected = GrB_DIMENSION_MISMATCH ;
3662
3663 ERR1 (v, GrB_Matrix_reduce_Monoid_(v, NULL, NULL, GxB_PLUS_FP64_MONOID, A, dtn)) ;
3664 ERR1 (v, GrB_Matrix_reduce_Monoid_(v, NULL, NULL, GxB_PLUS_FP64_MONOID, A, d0)) ;
3665
3666 //--------------------------------------------------------------------------
3667 // transpose
3668 //--------------------------------------------------------------------------
3669
3670 printf ("GrB_transpose------------------------------------------------\n") ;
3671 expected = GrB_NULL_POINTER ;
3672
3673 ERR (GrB_transpose (NULL, NULL, NULL, NULL, NULL)) ;
3674 ERR1 (A, GrB_transpose (A , NULL, NULL, NULL, NULL)) ;
3675
3676 expected = GrB_UNINITIALIZED_OBJECT ;
3677
3678 ERR1 (Agunk, GrB_transpose (Agunk, NULL , NULL , NULL , NULL )) ;
3679 ERR1 (A, GrB_transpose (A , Agunk, NULL , NULL , NULL )) ;
3680 ERR1 (A, GrB_transpose (A , A , op2gunk, NULL , NULL )) ;
3681 ERR1 (A, GrB_transpose (A , NULL , NULL , Agunk, NULL )) ;
3682 ERR1 (A, GrB_transpose (A , NULL , NULL , A , dgunk)) ;
3683
3684 expected = (Complex == GxB_FC64) ? GrB_DIMENSION_MISMATCH : GrB_DOMAIN_MISMATCH ;
3685
3686 o2 = Complex_plus ;
3687 ERR1 (A, GrB_transpose (A , Z , NULL, A, NULL)) ;
3688 ERR1 (A, GrB_transpose (A , NULL, NULL, Z, NULL)) ;
3689 ERR1 (A, GrB_transpose (A , NULL, NULL, Z, NULL)) ;
3690 ERR1 (Z, GrB_transpose (Z , NULL, NULL, A, NULL)) ;
3691 ERR1 (A, GrB_transpose (A , NULL, o2 , A, NULL)) ;
3692 ERR1 (A, GrB_transpose (A , NULL, o2 , Z, NULL)) ;
3693 ERR1 (Z, GrB_transpose (Z , NULL, o2 , A, NULL)) ;
3694
3695 expected = GrB_DIMENSION_MISMATCH ;
3696
3697 ERR1 (A, GrB_transpose (A , NULL, NULL, A, NULL)) ;
3698 ERR1 (C, GrB_transpose (C , NULL, NULL, A, dtn )) ;
3699
3700 //==========================================================================
3701 //=== internal functions ===================================================
3702 //==========================================================================
3703
3704 //--------------------------------------------------------------------------
3705 // Entry print
3706 //--------------------------------------------------------------------------
3707
3708 printf ("\n-------------- GB_entry_check:\n") ;
3709
3710 Context->where = "GB_entry_check (type, x, pr, f)" ;
3711
3712 expected = GrB_NULL_POINTER ;
3713
3714 ERR (GB_entry_check (NULL, NULL, 5, NULL)) ;
3715 ERR (GB_entry_check (NULL, X, 5, NULL)) ;
3716 OK (GB_entry_check (GrB_FP64, X, 5, NULL)) ;
3717 printf ("\n") ;
3718
3719 expected = GrB_UNINITIALIZED_OBJECT ;
3720
3721 ERR (GB_entry_check (Tgunk, X, 5, NULL)) ;
3722 printf ("\nAll GB_entry_check tests passed (errors expected)\n") ;
3723
3724 //--------------------------------------------------------------------------
3725 // Type check
3726 //--------------------------------------------------------------------------
3727
3728 printf ("\n-------------- GB_Type_check:\n") ;
3729
3730 Context->where = "GB_Type_check" ;
3731
3732 info = GB_Type_check (NULL, "null type", G1, ff) ;
3733 CHECK (info == GrB_NULL_POINTER) ;
3734
3735 expected = GrB_UNINITIALIZED_OBJECT ;
3736
3737 ERR (GB_Type_check (Tgunk, "Tgunk", G1, ff)) ;
3738
3739 CHECK (T == NULL) ;
3740 // test the function instead of the macro:
3741 #undef GrB_Type_new
3742 #undef GrM_Type_new
3743 OK (GRB (Type_new) (&T, sizeof (int))) ;
3744
3745 Context->where = "GB_Type_check" ;
3746 OK (GB_Type_check (T, "T ok (via function)", G3, ff)) ;
3747
3748 T->magic = GB_FREED ;
3749 ERR (GB_Type_check (T, "T freed", G1, ff)) ;
3750 T->magic = GB_MAGIC ;
3751
3752 expected = GrB_INVALID_OBJECT ;
3753
3754 T->code = 99 ;
3755 ERR (GB_Type_check (T, "T bad code", G1, ff)) ;
3756 T->code = GB_UDT_code ;
3757 T->magic = GB_MAGIC ;
3758 T->size = 0 ;
3759 ERR (GB_Type_check (T, "T bad size", G1, ff)) ;
3760 T->size = sizeof (int) ;
3761
3762 char *e = GB_code_string (9999) ;
3763 printf ("unknown code: [%s]\n", e) ;
3764 CHECK (strcmp (e, "unknown!") == 0) ;
3765
3766 OK (GB_Type_check (T, "type ok", G1, ff)) ;
3767 printf ("\nAll GB_Type_check tests passed (errors expected)\n") ;
3768
3769 //--------------------------------------------------------------------------
3770 // UnaryOp check
3771 //--------------------------------------------------------------------------
3772
3773 printf ("\n-------------- GB_UnaryOp_check:\n") ;
3774
3775 Context->where = "GB_UnaryOp_check" ;
3776
3777 info = GB_UnaryOp_check (NULL, "null unary op", G3, ff) ;
3778 CHECK (info == GrB_NULL_POINTER) ;
3779
3780 CHECK (op1b == NULL) ;
3781 // test the function instead of the macro:
3782 #undef GrB_UnaryOp_new
3783 #undef GrM_UnaryOp_new
3784 OK (GRB (UnaryOp_new) (&op1b, f1, GrB_FP64, GrB_UINT32)) ;
3785 CHECK (op1b != NULL) ;
3786 OK (GrB_UnaryOp_wait_(&op1b)) ;
3787
3788 Context->where = "GB_UnaryOp_check" ;
3789 OK (GB_UnaryOp_check (op1b, "op1b ok (via function)", G3, ff)) ;
3790
3791 expected = GrB_UNINITIALIZED_OBJECT ;
3792
3793 op1b->magic = GB_FREED ;
3794 ERR (GB_UnaryOp_check (op1b, "op1b freed", G1, ff)) ;
3795 op1b->magic = GB_MAGIC ;
3796
3797 expected = GrB_INVALID_OBJECT ;
3798
3799 op1b->function = NULL ;
3800 ERR (GB_UnaryOp_check (op1b, "op1b null func", G1, ff)) ;
3801 op1b->function = f1 ;
3802
3803 op1b->opcode = 1024 ;
3804 ERR (GB_UnaryOp_check (op1b, "op1b invalid opcode", G1, ff)) ;
3805 op1b->opcode = GB_USER_opcode ;
3806
3807 op1b->ztype = NULL ;
3808 ERR (GB_UnaryOp_check (op1b, "op1b invalid ztype", G1, ff)) ;
3809 op1b->ztype = GrB_FP64 ;
3810
3811 op1b->xtype = NULL ;
3812 ERR (GB_UnaryOp_check (op1b, "op1b invalid xtype", G1, ff)) ;
3813 op1b->xtype = GrB_UINT32 ;
3814
3815 printf ("\nAll GB_UnaryOp_check tests passed (errors expected)\n") ;
3816
3817 //--------------------------------------------------------------------------
3818 // BinaryOp check
3819 //--------------------------------------------------------------------------
3820
3821 printf ("\n-------------- GB_BinaryOp_check:\n") ;
3822
3823 Context->where = "GB_BinaryOp_check" ;
3824
3825 info = GB_BinaryOp_check (NULL, "null unary op", G3, ff) ;
3826 CHECK (info == GrB_NULL_POINTER) ;
3827
3828 CHECK (op2b == NULL) ;
3829 // test the function instead of the macro:
3830 #undef GrB_BinaryOp_new
3831 #undef GrM_BinaryOp_new
3832 OK (GRB (BinaryOp_new) (&op2b, f2, GrB_INT32, GrB_UINT8, GrB_INT16)) ;
3833 CHECK (op2b != NULL) ;
3834
3835 Context->where = "GB_BinaryOp_check" ;
3836 OK (GB_BinaryOp_check (op2b, "op2b ok (via function)", G3, ff)) ;
3837
3838 expected = GrB_UNINITIALIZED_OBJECT ;
3839
3840 op2b->magic = GB_FREED ;
3841 ERR (GB_BinaryOp_check (op2b, "op2b freed", G1, ff)) ;
3842 op2b->magic = GB_MAGIC ;
3843
3844 expected = GrB_INVALID_OBJECT ;
3845
3846 op2b->function = NULL ;
3847 ERR (GB_BinaryOp_check (op2b, "op2b null func", G1, ff)) ;
3848 op2b->function = f2 ;
3849
3850 op2b->opcode = 1024 ;
3851 ERR (GB_BinaryOp_check (op2b, "op2b invalid opcode", G1, ff)) ;
3852 op2b->opcode = GB_USER_opcode ;
3853
3854 op2b->ztype = NULL ;
3855 ERR (GB_BinaryOp_check (op2b, "op2b invalid ztype", G1, ff)) ;
3856 op2b->ztype = GrB_INT32 ;
3857
3858 op2b->xtype = NULL ;
3859 ERR (GB_BinaryOp_check (op2b, "op2b invalid xtype", G1, ff)) ;
3860 op2b->xtype = GrB_UINT8 ;
3861
3862 op2b->ytype = NULL ;
3863 ERR (GB_BinaryOp_check (op2b, "op2b invalid ytype", G1, ff)) ;
3864 op2b->ytype = GrB_UINT16 ;
3865
3866 printf ("\nAll GB_BinaryOp_check tests passed (errors expected)\n") ;
3867
3868 //--------------------------------------------------------------------------
3869 // SelectOp check
3870 //--------------------------------------------------------------------------
3871
3872 printf ("\n-------------- GB_SelectOp_check:\n") ;
3873
3874 Context->where = "GB_SelectOp_check" ;
3875
3876 info = GB_SelectOp_check (NULL, "null selectop", G3, ff) ;
3877 CHECK (info == GrB_NULL_POINTER) ;
3878
3879 CHECK (selectop == NULL) ;
3880 // test the function instead of the macro:
3881 #undef GxB_SelectOp_new
3882 #undef GxM_SelectOp_new
3883 OK (GXB (SelectOp_new) (&selectop, fselect, GrB_FP64, GrB_FP64)) ;
3884 CHECK (selectop != NULL) ;
3885
3886 Context->where = "GB_SelectOp_check" ;
3887 OK (GB_SelectOp_check (selectop, "user selectop ok (via function)", G3,
3888 ff)) ;
3889
3890 expected = GrB_UNINITIALIZED_OBJECT ;
3891
3892 selectop->magic = GB_FREED ;
3893 ERR (GB_SelectOp_check (selectop, "selectop freed", G1, ff)) ;
3894 selectop->magic = GB_MAGIC ;
3895
3896 expected = GrB_INVALID_OBJECT ;
3897
3898 selectop->function = NULL ;
3899 ERR (GB_SelectOp_check (selectop, "selectop invalid function", G1, ff)) ;
3900 selectop->function = fselect ;
3901
3902 selectop->opcode = 9999 ;
3903 ERR (GB_SelectOp_check (selectop, "selectop invalid opcode", G1, ff)) ;
3904 selectop->opcode = GB_USER_SELECT_opcode ;
3905
3906 selectop->xtype = Tgunk ;
3907 ERR (GB_SelectOp_check (selectop, "selectop invalid xtype", G1, ff)) ;
3908 selectop->xtype = GrB_FP64 ;
3909
3910 OK (GB_SelectOp_check (selectop, "user selectop ok", G3, ff)) ;
3911
3912 printf ("\nAll GB_SelectOp_check tests passed (errors expected)\n") ;
3913
3914 //--------------------------------------------------------------------------
3915 // Monoid check
3916 //--------------------------------------------------------------------------
3917
3918 printf ("\n-------------- GB_Monoid_check:\n") ;
3919
3920 Context->where = "GB_Monoid_check" ;
3921
3922 info = GB_Monoid_check (NULL, "null monoid", G3, ff) ;
3923 CHECK (info == GrB_NULL_POINTER) ;
3924
3925 CHECK (monoidb == NULL) ;
3926 OK (GrB_Monoid_new_INT32 (&monoidb, GrB_TIMES_INT32, (int) 1)) ;
3927 CHECK (monoidb != NULL) ;
3928
3929 Context->where = "GB_Monoid_check" ;
3930 OK (GB_Monoid_check (monoidb, "monoidb ok", G3, ff)) ;
3931
3932 expected = GrB_UNINITIALIZED_OBJECT ;
3933
3934 monoidb->magic = GB_FREED ;
3935 ERR (GB_Monoid_check (monoidb, "monoidb freed", G1, ff)) ;
3936 monoidb->magic = GB_MAGIC ;
3937
3938 expected = GrB_INVALID_OBJECT ;
3939
3940 monoidb->op = NULL ;
3941 ERR (GB_Monoid_check (monoidb, "monoidb invalid op", G1, ff)) ;
3942 monoidb->op = GrB_TIMES_INT32 ;
3943
3944 monoidb->op = GrB_EQ_INT32 ;
3945 ERR (GB_Monoid_check (monoidb, "monoidb invalid op domains", G1, ff)) ;
3946 monoidb->op = GrB_TIMES_INT32 ;
3947
3948 OK (GB_Monoid_check (Complex_plus_monoid, "complex plus monoid", G3, ff)) ;
3949 OK (GB_Monoid_check (Complex_times_monoid, "complex times monoid", G3, ff)) ;
3950
3951 printf ("\nAll GB_Monoid_check tests passed (errors expected)\n") ;
3952
3953 //--------------------------------------------------------------------------
3954 // Semiring check
3955 //--------------------------------------------------------------------------
3956
3957 printf ("\n-------------- GB_Semiring_check:\n") ;
3958
3959 Context->where = "GB_Semiring_check" ;
3960
3961 info = GB_Semiring_check (NULL, "null semiring", G3, ff) ;
3962 CHECK (info == GrB_NULL_POINTER) ;
3963
3964 CHECK (semiring2 == NULL) ;
3965 OK (GrB_Semiring_new (&semiring2, GxB_MAX_FP32_MONOID, GrB_TIMES_FP32)) ;
3966 CHECK (semiring2 != NULL) ;
3967
3968 Context->where = "GB_Semiring_check" ;
3969 OK (GB_Semiring_check (semiring2, "semiring2 ok", G3, ff)) ;
3970
3971 expected = GrB_UNINITIALIZED_OBJECT ;
3972
3973 semiring2->magic = GB_FREED ;
3974 ERR (GB_Semiring_check (semiring2, "semiring2 freed", G1, ff)) ;
3975 semiring2->magic = GB_MAGIC ;
3976
3977 expected = GrB_INVALID_OBJECT ;
3978
3979 semiring2->add = NULL ;
3980 ERR (GB_Semiring_check (semiring2, "semiring2 invalid add monoid", G1, ff)) ;
3981 semiring2->add = GxB_MAX_FP32_MONOID ;
3982
3983 semiring2->multiply = NULL ;
3984 ERR (GB_Semiring_check (semiring2, "semiring2 invalid mult", G1, ff)) ;
3985 semiring2->multiply = GrB_TIMES_FP32 ;
3986
3987 semiring2->multiply = GrB_TIMES_INT32 ;
3988 ERR (GB_Semiring_check (semiring2, "semiring2 invalid mix", G1, ff)) ;
3989 semiring2->multiply = GrB_TIMES_FP32 ;
3990
3991 printf ("\nAll GB_Semiring_check tests passed (errors expected)\n") ;
3992
3993 //--------------------------------------------------------------------------
3994 // Descriptor check
3995 //--------------------------------------------------------------------------
3996
3997 printf ("\n-------------- GB_Descriptor_check:\n") ;
3998
3999 Context->where = "GB_Descriptor_check" ;
4000
4001 info = GB_Descriptor_check (NULL, "null descriptor", G3, ff) ;
4002 CHECK (info == GrB_NULL_POINTER) ;
4003
4004 CHECK (descb == NULL) ;
4005 OK (GrB_Descriptor_new (&descb)) ;
4006 CHECK (descb != NULL) ;
4007
4008 Context->where = "GB_Descriptor_check" ;
4009 OK (GB_Descriptor_check (descb, "descb ok", G3, ff)) ;
4010
4011 expected = GrB_UNINITIALIZED_OBJECT ;
4012
4013 descb->magic = GB_FREED ;
4014 ERR (GB_Descriptor_check (descb, "descb freed", G1, ff)) ;
4015 descb->magic = GB_MAGIC ;
4016
4017 expected = GrB_INVALID_OBJECT ;
4018
4019 descb->out = 42 ;
4020 ERR (GB_Descriptor_check (descb, "descb invalid", G1, ff)) ;
4021 descb->out = GxB_DEFAULT ;
4022
4023 printf ("\nAll GB_Descriptor_check tests passed (errors expected)\n") ;
4024
4025 //--------------------------------------------------------------------------
4026 // Vector check
4027 //--------------------------------------------------------------------------
4028
4029 printf ("\n-------------- GB_Vector_check:\n") ;
4030 OK (GxB_Vector_fprint_(v, G3, ff)) ;
4031
4032 OK (GrB_Vector_free_(&v)) ;
4033 CHECK (v == NULL) ;
4034
4035 Context->where = "GB_Vector_check" ;
4036
4037 info = GB_Vector_check (NULL, "null vector", G3, ff) ;
4038 CHECK (info == GrB_NULL_POINTER) ;
4039
4040 CHECK (v == NULL) ;
4041 OK (GrB_Vector_new (&v, GrB_FP64, 10)) ;
4042 CHECK (v != NULL) ;
4043 CHECK (v->h == NULL) ;
4044
4045 Context->where = "GB_Vector_check" ;
4046 OK (GB_Vector_check (v, "v ok", G3, ff)) ;
4047
4048 OK (GrB_Vector_setElement_INT32 (v, 990, 0)) ;
4049 OK (GrB_Vector_setElement_INT32 (v, 991, 1)) ;
4050 OK (GrB_Vector_nvals (&nvals, v)) ;
4051 OK (GrB_Vector_wait_(&v)) ;
4052 CHECK (nvals == 2) ;
4053 OK (GxB_Vector_fprint (v, "v ok (might be bitmap)", G3, ff)) ;
4054 OK (GxB_Vector_Option_set (v, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
4055 OK (GxB_Vector_fprint (v, "v ok (sparse)", G3, ff)) ;
4056
4057 expected = GrB_INVALID_OBJECT ;
4058 CHECK (!GB_IS_FULL (v)) ;
4059 v->i [0] = 1 ;
4060 v->i [1] = 0 ;
4061 ERR (GxB_Vector_fprint (v, "v jumbled", G3, ff)) ;
4062 v->i [0] = 0 ;
4063 v->i [1] = 1 ;
4064 OK (GxB_Vector_fprint (v, "v fixed", G3, ff)) ;
4065
4066 expected = GrB_UNINITIALIZED_OBJECT ;
4067
4068 v->magic = GB_FREED ;
4069 ERR (GB_Vector_check (v, "v freed", G1, ff)) ;
4070 v->magic = GB_MAGIC ;
4071
4072 expected = GrB_INVALID_OBJECT ;
4073
4074 v->vdim = 2 ;
4075 int64_t *psave = v->p ;
4076 size_t p_size_save = v->p_size ;
4077 GB_Global_memtable_remove (v->p) ;
4078 v->p_size = 3 * sizeof (int64_t) ;
4079 v->p = mxMalloc (3 * sizeof (int64_t)) ;
4080 memset (v->p, 0, v->p_size) ;
4081 GB_Global_memtable_add (v->p, v->p_size) ;
4082 ERR (GB_Vector_check (v, "v invalid", G1, ff)) ;
4083 v->vdim = 1 ;
4084
4085 CHECK (!GB_IS_FULL (v)) ;
4086 v->p [0] = 1 ;
4087 ERR (GB_Vector_check (v, "v p[0] invalid", G1, ff)) ;
4088
4089 mxFree (v->p) ;
4090 GB_Global_memtable_remove (v->p) ;
4091 v->p = psave ;
4092 v->p_size = p_size_save ;
4093 GB_Global_memtable_add (v->p, v->p_size) ;
4094 psave = NULL ;
4095 OK (GB_Vector_check (v, "v OK now", G1, ff)) ;
4096
4097 printf ("\nAll GB_Vector_check tests passed (errors expected)\n") ;
4098
4099 //--------------------------------------------------------------------------
4100 // Matrix check
4101 //--------------------------------------------------------------------------
4102
4103 printf ("\n-------------- GB_Matrix_check:\n") ;
4104
4105 OK (GrB_Matrix_free_(&A)) ;
4106 CHECK (A == NULL) ;
4107
4108 Context->where = "GB_Matrix_check" ;
4109
4110 info = GB_Matrix_check (NULL, "null matrix", G3, ff) ;
4111 CHECK (info == GrB_NULL_POINTER) ;
4112
4113 CHECK (A == NULL) ;
4114 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 4)) ;
4115 CHECK (A != NULL) ;
4116
4117 Context->where = "GB_Matrix_check" ;
4118 OK (GB_Matrix_check (A, "A ok", G3, ff)) ;
4119 CHECK (A->h != NULL) ;
4120
4121 expected = GrB_UNINITIALIZED_OBJECT ;
4122
4123 A->magic = GB_FREED ;
4124 ERR (GB_Matrix_check (A, "A freed", G1, ff)) ;
4125 A->magic = GB_MAGIC ;
4126
4127 expected = GrB_INVALID_OBJECT ;
4128
4129 CHECK (!GB_IS_FULL (A)) ;
4130 A->p [0] = 1 ;
4131 ERR (GB_Matrix_check (A, "p[0] invalid", G1, ff)) ;
4132 A->p [0] = 0 ;
4133
4134 A->vlen = -1 ;
4135 ERR (GB_Matrix_check (A, "invalid dimensions", G1, ff)) ;
4136 A->vlen = 10 ;
4137
4138 A->type = NULL ;
4139 ERR (GB_Matrix_check (A, "invalid type", G1, ff)) ;
4140 A->type = GrB_FP64 ;
4141
4142 psave = A->p ;
4143 A->p = NULL ;
4144 ERR (GB_Matrix_check (A, "NULL Ap", G1, ff)) ;
4145 A->p = psave ;
4146
4147 CHECK (A->i == NULL) ;
4148
4149 OK (GrB_Matrix_free_(&A)) ;
4150 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 4)) ;
4151
4152 GrB_Index I00 [1] = { 0 } ;
4153 GrB_Index J00 [1] = { 0 } ;
4154 OK (GrB_Matrix_setElement_FP64 (A, 3.14159, 0, 0)) ;
4155 OK (GrB_Matrix_assign_BOOL (A, NULL, GrB_SECOND_FP64, true, I00, 1, J00, 1,
4156 NULL)) ;
4157 OK (GB_Matrix_check (A, "valid pending pi", G3, NULL)) ;
4158 OK (GrB_Matrix_nvals (&nvals, A)) ;
4159 OK (GrB_Matrix_wait_(&A)) ;
4160 CHECK (nvals == 1) ;
4161
4162 printf ("\n========================================== valid pi\n") ;
4163 OK (GB_Matrix_check (A, "valid pi", G3, NULL)) ;
4164 printf ("\n===================================================\n") ;
4165
4166 OK (GrB_Matrix_free_(&A)) ;
4167 OK (GrB_Matrix_new (&A, GrB_FP64, 10, 4)) ;
4168 OK (GxB_Matrix_Option_set_(A, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
4169 OK (GB_Matrix_check (A, "A empty", G3, NULL)) ;
4170
4171 // change the type of the pending tuples, forcing a wait
4172 OK (GrB_Matrix_assign_BOOL (A, NULL, GrB_SECOND_FP64, (bool) true,
4173 I00, 1, J00, 1, NULL)) ;
4174 OK (GB_Matrix_check (A, "with bool pending", G3, NULL)) ;
4175
4176 OK (GrB_Matrix_setElement_FP64 (A, 3.14159, 3, 3)) ;
4177 OK (GB_Matrix_check (A, "with pi pending", G3, NULL)) ;
4178
4179 AP = A->Pending ;
4180 CHECK (AP != NULL) ;
4181 CHECK (AP->n == 1) ;
4182 CHECK (AP->type == GrB_FP64) ;
4183
4184 OK (GrB_Matrix_setElement_FP64 (A, 9.0909, 2, 1)) ;
4185
4186 AP = A->Pending ;
4187 CHECK (AP != NULL) ;
4188 CHECK (AP->n == 2) ;
4189 CHECK (AP->type == GrB_FP64) ;
4190
4191 OK (GB_Matrix_check (A, "with pi and 9.0909 pending", G3, NULL)) ;
4192
4193 OK (GrB_Matrix_nvals (&nvals, A)) ;
4194 OK (GrB_Matrix_wait_(&A)) ;
4195 CHECK (nvals == 3) ;
4196
4197 Context->where = "GB_Matrix_check" ;
4198
4199 psave = A->i ;
4200 A->i = NULL ;
4201 ERR (GB_Matrix_check (A, "NULL Ai", G1, NULL)) ;
4202 A->i = psave ;
4203 OK (GB_Matrix_check (A, "valid pi", G0, NULL)) ;
4204
4205 CHECK (!GB_IS_FULL (A)) ;
4206 A->p [0] = 1 ;
4207 ERR (GB_Matrix_check (A, "Ap[0] invalid", G1, NULL)) ;
4208 A->p [0] = 0 ;
4209
4210 int64_t isave = A->p [1] ;
4211 A->p [1] = -1 ;
4212 ERR (GB_Matrix_check (A, "Ap[1] invalid", G1, NULL)) ;
4213 A->p [1] = isave ;
4214
4215 isave = A->p [4] ;
4216 A->p [4] += 999 ;
4217 ERR (GB_Matrix_check (A, "Ap[ncols] invalid", G1, NULL)) ;
4218 A->p [4] = isave ;
4219
4220 isave = A->nzombies ;
4221 A->nzombies = -1 ;
4222 ERR (GB_Matrix_check (A, "negative zombies", G1, NULL)) ;
4223 A->nzombies = isave ;
4224
4225 isave = A->nzombies ;
4226 A->nzombies = 1000 ;
4227 ERR (GB_Matrix_check (A, "too many zombies", G1, NULL)) ;
4228 A->nzombies = isave ;
4229
4230 isave = A->i [0] ;
4231 A->i [0] = -1 ;
4232 ERR (GB_Matrix_check (A, "row index invalid", G3, NULL)) ;
4233 A->i [0] = isave ;
4234
4235 isave = A->nzombies ;
4236 A->nzombies = 1 ;
4237 ERR (GB_Matrix_check (A, "bad zombies", G3, NULL)) ;
4238 A->nzombies = isave ;
4239
4240 AP = A->Pending ;
4241 CHECK (AP == NULL) ;
4242
4243 printf ("\n========================================== valid [pi 7.1]\n") ;
4244 OK (GrB_Matrix_setElement_FP64 (A, 7.1, 1, 0)) ;
4245 OK (GB_Matrix_check (A, "valid pending [pi 7.1]", G3, NULL)) ;
4246 printf ("\n===================================================\n") ;
4247
4248 Context->where = "GB_Matrix_check" ;
4249
4250 AP = A->Pending ;
4251 CHECK (AP != NULL) ;
4252 isave = AP->n ;
4253 AP->n = -1 ;
4254 ERR (GB_Matrix_check (A, "negative pending", G1, NULL)) ;
4255 AP->n = isave ;
4256
4257 AP = A->Pending ;
4258 CHECK (AP != NULL) ;
4259 psave = AP->i ;
4260 AP->i = NULL ;
4261 ERR (GB_Matrix_check (A, "missing pending", G3, NULL)) ;
4262 AP->i = psave ;
4263
4264 OK (GB_Matrix_check (A, "valid pending [pi 7.1]", G0, NULL)) ;
4265
4266 AP = A->Pending ;
4267 CHECK (AP != NULL) ;
4268 CHECK (AP->j != NULL) ;
4269 isave = AP->j [0] ;
4270 AP->j [0] = 1070 ;
4271 ERR (GB_Matrix_check (A, "bad pending tuple", G3, NULL)) ;
4272 AP->j [0] = isave ;
4273 OK (GB_Matrix_check (A, "valid pending [pi 7.1]", G0, NULL)) ;
4274
4275 printf ("\n====================================== valid [pi 7.1 11.4]\n") ;
4276 OK (GrB_Matrix_setElement_FP64 (A, 11.4, 0, 1)) ;
4277 OK (GB_Matrix_check (A, "valid pending [pi 7.1 11.4]", G3, NULL)) ;
4278 printf ("\n=========================================================\n") ;
4279
4280 Context->where = "GB_Matrix_check" ;
4281
4282 AP = A->Pending ;
4283 CHECK (AP != NULL) ;
4284 isave = AP->j [0] ;
4285 AP->j [0] = 2 ;
4286 ERR (GB_Matrix_check (A, "jumbled pending tuples", G3, ff)) ;
4287 ERR (GxB_Matrix_fprint (A, "jumbled pending tuples", G3, ff)) ;
4288 AP->j [0] = isave ;
4289 OK (GB_Matrix_check (A, "valid pending [pi 7.1 11.4]", G0, ff)) ;
4290
4291 AP = A->Pending ;
4292 CHECK (AP != NULL) ;
4293 CHECK (AP->op == NULL) ;
4294 AP->op = op2gunk ;
4295 ERR (GB_Matrix_check (A, "invalid operator", G3, NULL)) ;
4296 AP->op = NULL ;
4297
4298 OK (GB_Matrix_check (A, "valid pending [pi 7.1 11.4]", G3, NULL)) ;
4299 printf ("\n=========================================================\n") ;
4300
4301 printf ("\n###### get nvals; assemble the pending tuples ##### \n") ;
4302
4303 OK (GrB_Matrix_nvals (&nvals, A)) ;
4304 OK (GrB_Matrix_wait_(&A)) ;
4305
4306 Context->where = "GB_Matrix_check" ;
4307 printf ("\n====================================== valid [pi 7.1 11.4]\n") ;
4308 OK (GB_Matrix_check (A, "valid [pi 7 11.4]", G3, NULL)) ;
4309 printf ("\n=========================================================\n") ;
4310 CHECK (nvals == 5) ;
4311
4312 expected = GrB_INDEX_OUT_OF_BOUNDS ;
4313
4314 CHECK (!GB_IS_FULL (A)) ;
4315 CHECK (!GB_IS_BITMAP (A)) ;
4316 A->i [0] = 1 ;
4317 A->i [1] = 0 ;
4318
4319 info = GB_Matrix_check (A, "jumbled", G3, NULL) ;
4320 printf ("jumbled info %d\n", info) ;
4321 CHECK (info == GrB_INDEX_OUT_OF_BOUNDS) ;
4322
4323 info = GxB_Matrix_fprint (A, "jumbled", G3, ff) ;
4324 printf ("jumbled info %d\n", info) ;
4325 CHECK (info == GrB_INVALID_OBJECT) ;
4326
4327 CHECK (!GB_IS_FULL (A)) ;
4328 CHECK (!GB_IS_BITMAP (A)) ;
4329 A->i [0] = 0 ;
4330 A->i [1] = 1 ;
4331 OK (GB_Matrix_check (A, "OK", G3, NULL)) ;
4332 OK (GrB_Matrix_nvals (&nvals, A)) ;
4333 OK (GrB_Matrix_wait_(&A)) ;
4334 CHECK (nvals == 5) ;
4335
4336 AP = A->Pending ;
4337 CHECK (AP == NULL) ;
4338 CHECK (A->nzombies == 0) ;
4339 OK (GrB_Matrix_new (&Empty1, GrB_FP64, 1, 1)) ;
4340 I [0] = 0 ;
4341 J [0] = 0 ;
4342 OK (GxB_Matrix_subassign (A, NULL, NULL, Empty1, I, 1, J, 1, NULL)) ;
4343 OK (GB_Matrix_check (A, "valid zombie", G3, NULL)) ;
4344 OK (GrB_Matrix_setElement_INT32 (A, 99099, 0, 0)) ;
4345 OK (GB_Matrix_check (A, "no more zombie", G3, NULL)) ;
4346 OK (GrB_Matrix_nvals (&nvals, A)) ;
4347 OK (GrB_Matrix_wait_(&A)) ;
4348 CHECK (nvals == 5) ;
4349
4350 OK (GxB_Matrix_subassign (A, NULL, NULL, Empty1, I, 1, J, 1, NULL)) ;
4351 OK (GB_Matrix_check (A, "valid zombie", G3, NULL)) ;
4352 OK (GrB_Matrix_nvals (&nvals, A)) ;
4353 OK (GrB_Matrix_wait_(&A)) ;
4354 CHECK (nvals == 4) ;
4355 OK (GB_Matrix_check (A, "again no more zombie", G3, NULL)) ;
4356 OK (A->Pending == NULL && A->nzombies == 0) ;
4357
4358 expected = GrB_INVALID_OBJECT ;
4359
4360 OK (GB_Matrix_check (A, "valid, no pending", G3, NULL)) ;
4361
4362 // #define FREE_DEEP_COPY ;
4363 // #define GET_DEEP_COPY ;
4364
4365 CHECK (GB_IS_SPARSE (A)) ;
4366 OK (GxB_Matrix_Option_set_(A, GxB_SPARSITY_CONTROL, GxB_HYPERSPARSE)) ;
4367 CHECK (GB_IS_HYPERSPARSE (A)) ;
4368 OK (GB_Matrix_check (A, "A now hyper", G3, NULL)) ;
4369 CHECK (A->h != NULL) ;
4370
4371 OK (GxB_Matrix_Option_set_(A, GxB_HYPER_SWITCH, GxB_NEVER_HYPER)) ;
4372 OK (GxB_Matrix_Option_set_(A, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
4373 CHECK (A->h == NULL) ;
4374 bool A_is_hyper ;
4375 OK (GxB_Matrix_Option_get_(A, GxB_IS_HYPER, &A_is_hyper)) ; // historical
4376 CHECK (!A_is_hyper) ;
4377
4378 OK (GxB_Matrix_Option_set_(A, GxB_HYPER_SWITCH, GxB_ALWAYS_HYPER)) ;
4379 OK (GxB_Matrix_Option_set_(A, GxB_SPARSITY_CONTROL, GxB_HYPERSPARSE)) ;
4380 CHECK (A->h != NULL) ;
4381 OK (GxB_Matrix_Option_get_(A, GxB_IS_HYPER, &A_is_hyper)) ; // historical
4382 CHECK (A_is_hyper) ;
4383
4384 // make sure A->nvec_nonempty is valid
4385 CHECK (GB_IS_HYPERSPARSE (A)) ;
4386 if (A->nvec_nonempty < 0)
4387 {
4388 A->nvec_nonempty = GB_nvec_nonempty (A, NULL) ;
4389 }
4390
4391 // now make invalid. GB_Matrix_check requires it to be -1, or correct value
4392 CHECK (GB_IS_HYPERSPARSE (A)) ;
4393 isave = A->p [1] ;
4394 A->p [1] = 0 ;
4395 expected = GrB_INDEX_OUT_OF_BOUNDS ;
4396 ERR (GB_Matrix_check (A, "A with bad nvec_nonempty", G1, NULL)) ;
4397 expected = GrB_INVALID_OBJECT ;
4398 ERR (GxB_Matrix_fprint (A, "A", G1, ff)) ;
4399 CHECK (GB_IS_HYPERSPARSE (A)) ;
4400 A->p [1] = isave ;
4401 OK (GB_Matrix_check (A, "A fixed", G0, NULL)) ;
4402
4403 double hratio = 0.5;
4404 OK (GxB_Matrix_Option_set_(A, GxB_HYPER_SWITCH, hratio)) ;
4405
4406 double hratio2 = 0 ;
4407 OK (GxB_Matrix_Option_get_(A, GxB_HYPER_SWITCH, &hratio2)) ;
4408 CHECK (hratio == hratio2) ;
4409
4410 double bswitch [GxB_NBITMAP_SWITCH] ;
4411 for (int k = 0 ; k < GxB_NBITMAP_SWITCH ; k++)
4412 {
4413 bswitch [k] = (double) k / 16.0 ;
4414 }
4415 OK (GxB_Global_Option_set_(GxB_BITMAP_SWITCH, bswitch)) ;
4416
4417 double bswitch2 [GxB_NBITMAP_SWITCH] ;
4418 OK (GxB_Global_Option_get_(GxB_BITMAP_SWITCH, bswitch2)) ;
4419 for (int k = 0 ; k < GxB_NBITMAP_SWITCH ; k++)
4420 {
4421 CHECK (fabs (bswitch [k] - bswitch2 [k]) < 1e-5) ;
4422 }
4423
4424 OK (GxB_Global_Option_set_(GxB_BITMAP_SWITCH, NULL)) ;
4425 OK (GxB_Global_Option_get_(GxB_BITMAP_SWITCH, bswitch)) ;
4426 for (int k = 0 ; k < GxB_NBITMAP_SWITCH ; k++)
4427 {
4428 printf ("default bswitch [%d] = %g\n", k, bswitch [k]) ;
4429 }
4430
4431 OK (GxB_Matrix_Option_set_(A, GxB_FORMAT, GxB_BY_COL)) ;
4432 CHECK (GB_IS_HYPERSPARSE (A)) ;
4433 CHECK (A->is_csc) ;
4434
4435 GxB_Format_Value format = 0;
4436 OK (GxB_Matrix_Option_get_(A, GxB_FORMAT, &format)) ;
4437 CHECK (format == GxB_BY_COL) ;
4438
4439 OK (GxB_Matrix_Option_set_(A, GxB_FORMAT, GxB_BY_ROW)) ;
4440 CHECK (!A->is_csc) ;
4441
4442 OK (GxB_Matrix_Option_get_(A, GxB_FORMAT, &format)) ;
4443 CHECK (format == GxB_BY_ROW) ;
4444
4445 OK (GxB_Matrix_Option_set_(A, GxB_FORMAT, GxB_BY_COL)) ;
4446 CHECK (A->is_csc) ;
4447
4448 OK (GxB_Global_Option_set_(GxB_FORMAT, GxB_BY_ROW)) ;
4449 format = 99 ;
4450 OK (GxB_Global_Option_get_(GxB_FORMAT, &format)) ;
4451 CHECK (format == 0) ;
4452
4453 OK (GxB_Global_Option_set_(GxB_HYPER_SWITCH, 77.33f)) ;
4454 OK (GxB_Global_Option_get_(GxB_HYPER_SWITCH, &hratio)) ;
4455 printf ("%g\n", hratio) ;
4456 CHECK (hratio == 77.33f) ;
4457
4458 OK (GxB_Global_Option_set_(GxB_HYPER_SWITCH, GxB_HYPER_DEFAULT)) ;
4459 OK (GxB_Global_Option_get_(GxB_HYPER_SWITCH, &hratio)) ;
4460 CHECK (hratio == GxB_HYPER_DEFAULT) ;
4461
4462 expected = GrB_NULL_POINTER ;
4463 GrB_Matrix O_NULL = NULL ;
4464 ERR1 (O_NULL, GxB_Matrix_Option_set_(O_NULL, GxB_FORMAT, GxB_BY_COL)) ;
4465
4466 expected = GrB_NULL_POINTER ;
4467 ERR (GxB_Global_Option_get_(GxB_FORMAT, NULL)) ;
4468
4469 expected = GrB_NULL_POINTER ;
4470 ERR (GxB_Matrix_Option_get_(A, GxB_FORMAT, NULL)) ;
4471 GrB_Matrix_error_(&err, A) ;
4472 printf ("error expected (A format null):%s\n", err) ;
4473
4474 expected = GrB_NULL_POINTER ;
4475 ERR (GxB_Matrix_Option_get_(A, GxB_HYPER_SWITCH, NULL)) ;
4476 GrB_Matrix_error_(&err, A) ;
4477 printf ("error expected:%s\n", err) ;
4478
4479 ERR (GxB_Matrix_Option_get_(A, GxB_BITMAP_SWITCH, NULL)) ;
4480 GrB_Matrix_error_(&err, A) ;
4481 printf ("error expected:%s\n", err) ;
4482
4483 expected = GrB_NULL_POINTER ;
4484 ERR (GxB_Global_Option_get_(GxB_HYPER_SWITCH, NULL)) ;
4485 ERR (GxB_Global_Option_get_(GxB_BITMAP_SWITCH, NULL)) ;
4486
4487 expected = GrB_INVALID_VALUE ;
4488 ERR (GxB_Global_Option_get_(-1, NULL)) ;
4489
4490 ERR (GxB_Matrix_Option_get_(A, 999, NULL)) ;
4491 GrB_Matrix_error_(&err, A) ;
4492 printf ("error expected (bad field):%s\n", err) ;
4493
4494 ERR1 (A, GxB_Matrix_Option_set_(A, 999, GxB_BY_ROW)) ;
4495 GrB_Matrix_error_(&err, A) ;
4496 printf ("error expected:%s\n", err) ;
4497
4498 ERR (GxB_Global_Option_set_(999, GxB_BY_ROW)) ;
4499
4500 expected = GrB_INVALID_VALUE ;
4501 ERR (GxB_Global_Option_set_(GxB_FORMAT, 9999)) ;
4502
4503 ERR1 (A, GxB_Matrix_Option_set_(A, 999, GxB_BY_ROW)) ;
4504 GrB_Matrix_error_(&err, A) ;
4505 printf ("error expected:%s\n", err) ;
4506
4507 ERR1 (A, GxB_Matrix_Option_set_(A, GxB_FORMAT, 909090)) ;
4508 GrB_Matrix_error_(&err, A) ;
4509 printf ("error expected:%s\n", err) ;
4510
4511 CHECK (A != NULL) ;
4512 CHECK (A->is_csc) ;
4513
4514 OK (GxB_Matrix_Option_set_(A, GxB_SPARSITY_CONTROL, GxB_HYPERSPARSE)) ;
4515
4516 expected = GrB_INVALID_OBJECT ;
4517
4518 int64_t *Ah_save = A->h ;
4519 A->h = NULL ;
4520 ERR (GB_Matrix_check (A, "h invalid", G3, NULL)) ;
4521 A->h = Ah_save ;
4522 OK (GB_Matrix_check (A, "h restored", G1, NULL)) ;
4523
4524 int64_t nvec = A->nvec ;
4525 A->nvec = -1 ;
4526 ERR (GB_Matrix_check (A, "nvec invalid", G1, NULL)) ;
4527 A->nvec = nvec ;
4528 OK (GB_Matrix_check (A, "nvec restored", G1, NULL)) ;
4529
4530 CHECK (!GB_IS_FULL (A)) ;
4531 CHECK (A->h != NULL) ;
4532 int64_t jsave = A->h [0] ;
4533 A->h [0] = -1 ;
4534 ERR (GB_Matrix_check (A, "h[0] invalid", G1, NULL)) ;
4535 A->h [0] = jsave ;
4536 OK (GB_Matrix_check (A, "h[0] restored", G1, NULL)) ;
4537
4538 GrB_Matrix Eleven ;
4539 OK (GrB_Matrix_new (&Eleven, GrB_BOOL, 11, 11)) ;
4540 I [0] = 0 ;
4541 OK (GrB_Matrix_assign_BOOL (Eleven, NULL, NULL, (bool) true, I, 1, GrB_ALL, 0, NULL)) ;
4542 OK (GB_Matrix_check (Eleven, "Eleven", G2, NULL)) ;
4543
4544 if (!GB_IS_FULL (Eleven)) GB_Matrix_wait (Eleven, "Eleven", Context) ;
4545
4546 for (int pr = -4 ; pr <= 3 ; pr++)
4547 {
4548 OK (GxB_Matrix_fprint (Eleven, "Eleven", pr, NULL)) ;
4549 OK (GxB_Matrix_fprint (Eleven, "Eleven is OK", pr, ff)) ;
4550 OK (GxB_Matrix_fprint (Eleven, "Eleven", pr, ff)) ;
4551 }
4552
4553 OK (GB_convert_hyper_to_sparse (Eleven, Context)) ;
4554 int64_t nothing = 42 ;
4555 printf ("\nEleven invalid hypersparse:\n") ;
4556 GB_free_memory (&(Eleven->h), Eleven->h_size) ;
4557 Eleven->h = ¬hing ;
4558 Eleven->h_size = sizeof (int64_t) ;
4559 GB_Global_memtable_add (Eleven->h, 1 * sizeof (int64_t)) ;
4560 ERR (GB_Matrix_check (Eleven, "Eleven invalid", G2, NULL)) ;
4561 ERR (GxB_Matrix_fprint (Eleven, "Eleven", G2, NULL)) ;
4562 ERR (GxB_Matrix_fprint (Eleven, "Eleven invalid", G2, ff)) ;
4563 GB_Global_memtable_remove (Eleven->h) ;
4564 Eleven->h = NULL ;
4565
4566 OK (GrB_Matrix_free_(&Eleven)) ;
4567
4568 OK (GrB_Matrix_new (&Eleven, GrB_BOOL, 11, 11)) ;
4569 for (int64_t i = 0 ; i < 11 ; i++)
4570 {
4571 for (int64_t j = 0 ; j < 11 ; j++)
4572 {
4573 GrB_Matrix_setElement_BOOL (Eleven, true, i, j) ;
4574 }
4575 }
4576 OK (GrB_Matrix_nvals (&nvals, Eleven)) ;
4577 OK (GrB_Matrix_wait_(&Eleven)) ;
4578 CHECK (nvals == 121) ;
4579 OK (GB_Matrix_check (Eleven, "Eleven", G2, NULL)) ;
4580 OK (GrB_Matrix_free_(&Eleven)) ;
4581
4582 printf ("\nAll GB_Matrix_check tests passed (errors expected)\n") ;
4583
4584 //--------------------------------------------------------------------------
4585 // blocking vs non-blocking mode
4586 //--------------------------------------------------------------------------
4587
4588 OK (GrB_Matrix_setElement_FP64 (A, 32.4, 3, 2)) ;
4589 OK (GB_Matrix_check (A, "A with one pending", G3, NULL)) ;
4590 AP = A->Pending ;
4591 CHECK (AP != NULL) ;
4592 CHECK (AP->n == 1 && A->nzombies == 0) ;
4593 GB_Global_mode_set (GrB_BLOCKING) ;
4594 OK (GB_block (A, Context)) ;
4595 OK (GB_Matrix_check (A, "A with no pending", G3, NULL)) ;
4596 AP = A->Pending ;
4597 CHECK (AP == NULL) ;
4598 CHECK (A->nzombies == 0) ;
4599 OK (GrB_Matrix_setElement_FP64 (A, 99.4, 3, 3)) ;
4600 OK (GB_Matrix_check (A, "A blocking mode", G3, NULL)) ;
4601 GB_Global_mode_set (GrB_NONBLOCKING) ;
4602 AP = A->Pending ;
4603 CHECK (AP == NULL) ;
4604 CHECK (A->nzombies == 0) ;
4605
4606 printf ("\nAll blocking/nonblocking mode tests passed\n") ;
4607
4608 //--------------------------------------------------------------------------
4609 // restore all 'gunk' objects so they can be freed
4610 //--------------------------------------------------------------------------
4611
4612 // printf ("\n-------------- Restore gunk objects:\n") ;
4613
4614 expected = GrB_UNINITIALIZED_OBJECT ;
4615
4616 Context->where = "GB *_check" ;
4617
4618 ERR (GB_Type_check (Tgunk, "", G0, NULL)) ;
4619 ERR (GB_UnaryOp_check (op1gunk, "", G0, NULL)) ;
4620 ERR (GB_BinaryOp_check (op2gunk, "", G0, NULL)) ;
4621 ERR (GB_Monoid_check (monoid_gunk, "", G0, NULL)) ;
4622 ERR (GB_Semiring_check (semigunk, "", G0, NULL)) ;
4623 ERR (GB_Vector_check (vgunk, "", G0, NULL)) ;
4624 ERR (GB_Matrix_check (Agunk, "", G0, NULL)) ;
4625 ERR (GB_Descriptor_check (dgunk, "", G0, NULL)) ;
4626 GB_SelectOp_check (selectopgunk, "", G3, NULL) ;
4627 ERR (GB_SelectOp_check (selectopgunk, "", G0, NULL)) ;
4628
4629 ERR (GxB_Type_fprint (Tgunk, "crud", G0, ff)) ;
4630 ERR (GxB_UnaryOp_fprint (op1gunk, "crud", G0, ff)) ;
4631 ERR (GxB_BinaryOp_fprint (op2gunk, "crud", G0, ff)) ;
4632 ERR (GxB_Monoid_fprint (monoid_gunk, "crud", G0, ff)) ;
4633 ERR (GxB_Semiring_fprint (semigunk, "crud", G0, ff)) ;
4634 ERR (GxB_Vector_fprint (vgunk, "crud", G0, ff)) ;
4635 ERR (GxB_Matrix_fprint (Agunk, "crud", G0, ff)) ;
4636 ERR (GxB_Descriptor_fprint (dgunk, "crud", G0, ff)) ;
4637 GxB_SelectOp_fprint (selectopgunk, "crud", G3, ff) ;
4638 ERR (GxB_SelectOp_fprint (selectopgunk, "crud", G0, ff)) ;
4639
4640 #define REMAGIC(p) if (p != NULL) p->magic = GB_MAGIC ;
4641 REMAGIC (Tgunk)
4642 REMAGIC (op1gunk)
4643 REMAGIC (op2gunk)
4644 REMAGIC (monoid_gunk)
4645 REMAGIC (semigunk)
4646 REMAGIC (vgunk)
4647 REMAGIC (Agunk)
4648 REMAGIC (dgunk)
4649 REMAGIC (selectopgunk)
4650 #undef REMAGIC
4651
4652 OK (GB_Type_check (Tgunk, "", G0, NULL)) ;
4653 OK (GB_UnaryOp_check (op1gunk, "", G0, NULL)) ;
4654 OK (GB_BinaryOp_check (op2gunk, "", G0, NULL)) ;
4655 OK (GB_Monoid_check (monoid_gunk, "", G0, NULL)) ;
4656 OK (GB_Semiring_check (semigunk, "", G0, NULL)) ;
4657 OK (GB_Vector_check (vgunk, "", G0, NULL)) ;
4658 OK (GB_Matrix_check (Agunk, "", G0, NULL)) ;
4659 OK (GB_Descriptor_check (dgunk, "", G0, NULL)) ;
4660 OK (GB_SelectOp_check (selectopgunk, "", G0, NULL)) ;
4661
4662 OK (GxB_Type_fprint_(Tgunk, G0, ff)) ;
4663 OK (GxB_UnaryOp_fprint_(op1gunk, G0, ff)) ;
4664 OK (GxB_BinaryOp_fprint_(op2gunk, G0, ff)) ;
4665 OK (GxB_Monoid_fprint_(monoid_gunk, G0, ff)) ;
4666 OK (GxB_Semiring_fprint_(semigunk, G0, ff)) ;
4667 OK (GxB_Vector_fprint_(vgunk, G0, ff)) ;
4668 OK (GxB_Matrix_fprint_(Agunk, G0, ff)) ;
4669 OK (GxB_Descriptor_fprint_(dgunk, G0, ff)) ;
4670 OK (GxB_SelectOp_fprint_(selectopgunk, G0, ff)) ;
4671
4672 //--------------------------------------------------------------------------
4673 // GB_Descriptor_get
4674 //--------------------------------------------------------------------------
4675
4676 expected = GrB_INVALID_OBJECT ;
4677 dgunk->out = 999 ;
4678 x_bool = false ;
4679 Context->where = "GB_Descriptor_get" ;
4680 ERR (GB_Descriptor_get (dgunk, &x_bool, NULL, NULL, NULL, NULL, NULL, NULL,
4681 Context)) ;
4682 CHECK (x_bool == false) ;
4683 dgunk->out = GxB_DEFAULT ;
4684
4685 //--------------------------------------------------------------------------
4686 // Wathen
4687 //--------------------------------------------------------------------------
4688
4689 expected = GrB_INVALID_VALUE ;
4690 ERR (wathen (NULL, -1, -1, 0, 0, &x)) ;
4691
4692 //--------------------------------------------------------------------------
4693 // malloc wrappers
4694 //--------------------------------------------------------------------------
4695
4696 size_t nbytes ;
4697 pp = (GB_void *) &x ;
4698 pp = GB_malloc_memory (UINT64_MAX, 1, &nbytes) ;
4699 CHECK (pp == NULL) ;
4700 CHECK (nbytes == 0) ;
4701
4702 pp = (GB_void *) &x ;
4703 pp = GB_calloc_memory (UINT64_MAX, 1, &nbytes, NULL) ;
4704 CHECK (pp == NULL) ;
4705 CHECK (nbytes == 0) ;
4706
4707 ok = true ;
4708 pp = GB_realloc_memory (UINT64_MAX, 0, 1, NULL, &nbytes, &ok, NULL) ;
4709 CHECK (!ok) ;
4710 CHECK (nbytes == 0) ;
4711
4712 s = 1 ;
4713 ok = GB_size_t_multiply (&s, UINT64_MAX, 0) ;
4714 CHECK (ok) ;
4715 CHECK (s == 0) ;
4716
4717 s = 911 ;
4718 ok = GB_size_t_multiply (&s, UINT64_MAX/2, UINT64_MAX/2) ;
4719 CHECK (!ok) ;
4720 CHECK (s == 0) ;
4721
4722 ok = GB_size_t_multiply (&s,
4723 ((size_t) UINT32_MAX)+2,
4724 ((size_t) UINT32_MAX)+1) ;
4725 CHECK (!ok) ;
4726
4727 ok = GB_size_t_multiply (&s,
4728 ((size_t) UINT32_MAX)+1,
4729 ((size_t) UINT32_MAX)+1) ;
4730 CHECK (!ok) ;
4731
4732 ok = GB_size_t_multiply (&s,
4733 ((size_t) UINT32_MAX)/2,
4734 ((size_t) UINT32_MAX)/2) ;
4735 CHECK (ok) ;
4736 CHECK (s == (((size_t) UINT32_MAX)/2) * (((size_t) UINT32_MAX)/2)) ;
4737 Context->where = "GrB_error" ;
4738
4739 n = 1 ;
4740 ok = GB_Index_multiply (&n, INT64_MAX, 0) ;
4741 CHECK (ok) ;
4742 CHECK (n == 0) ;
4743
4744 n = 911 ;
4745 ok = GB_Index_multiply (&n, -1, -1) ;
4746 CHECK (!ok) ;
4747 CHECK (n == 0) ;
4748
4749 n = 911 ;
4750 ok = GB_Index_multiply (&n, 1, GxB_INDEX_MAX+1) ;
4751 CHECK (!ok) ;
4752 CHECK (n == 0) ;
4753
4754 ok = GB_Index_multiply (&n,
4755 ((GrB_Index) GxB_INDEX_MAX)+1,
4756 ((GrB_Index) GxB_INDEX_MAX)+1) ;
4757 CHECK (!ok) ;
4758
4759 ok = GB_Index_multiply (&n,
4760 ((GrB_Index) GxB_INDEX_MAX),
4761 ((GrB_Index) GxB_INDEX_MAX)) ;
4762 CHECK (!ok) ;
4763
4764 a = (GrB_Index) 16777216/2 ; // (2^24)/2
4765 b = (GrB_Index) 16777216 ;
4766 ok = GB_Index_multiply (&n, a, b) ;
4767 // printf ("%lld %lld n\n", n, a*b) ;
4768 CHECK (ok) ;
4769 CHECK (n == a*b)
4770
4771 //--------------------------------------------------------------------------
4772 // internal GB * routines
4773 //--------------------------------------------------------------------------
4774
4775 CHECK (A != NULL) ;
4776 Context->where = "GB_bix_alloc" ;
4777 info = GB_bix_alloc (A, GxB_INDEX_MAX+1, true, true, true, true, Context) ;
4778 CHECK (info == GrB_OUT_OF_MEMORY) ;
4779
4780 Context->where = "GB_ix_realloc" ;
4781
4782 CHECK (A != NULL) ;
4783 info = GB_ix_realloc (A, GxB_INDEX_MAX+1, true, Context) ;
4784 CHECK (info == GrB_OUT_OF_MEMORY) ;
4785
4786 OK (GB_Matrix_check (A, "A pattern 1", G3, NULL)) ;
4787 OK (GB_ix_realloc (A, 20, false, Context)) ;
4788 CHECK (info == GrB_SUCCESS) ;
4789 OK (GB_Matrix_check (A, "A pattern 2", G3, NULL)) ;
4790
4791 GB_bix_free (NULL) ;
4792 GB_ph_free (NULL) ;
4793
4794 GrB_Matrix_free_(&C) ;
4795 GrB_Matrix_free_(&B) ;
4796 CHECK (C == NULL) ;
4797 CHECK (B == NULL) ;
4798 OK (GrB_Matrix_new (&C, GrB_FP32, 1, 1)) ;
4799 OK (GB_Matrix_check (A, "A for shallow op", G3, NULL)) ;
4800 Context->where = "GB_shallow_op" ;
4801
4802 struct GB_Matrix_opaque Q_header ;
4803 GrB_Matrix Q = GB_clear_static_header (&Q_header) ;
4804 OK (GB_shallow_op (Q, true,
4805 GrB_AINV_FP32, NULL, NULL, false,
4806 C, Context)) ;
4807 OK (GB_Matrix_check (Q, "Q empty, float", G3, NULL)) ;
4808 GrB_Matrix_free_(&Q) ;
4809
4810 bool b1, b2 ;
4811 int64_t imin, imax ;
4812
4813 OK (GB_op_is_second (GrB_SECOND_FP64, NULL)) ;
4814
4815 //--------------------------------------------------------------------------
4816 // check for inputs aliased with outputs
4817 //--------------------------------------------------------------------------
4818
4819 printf ("free A:\n") ; GrB_Matrix_free_(&A) ;
4820 printf ("free B:\n") ; GrB_Matrix_free_(&B) ;
4821 printf ("free C:\n") ; GrB_Matrix_free_(&C) ;
4822 printf ("free E:\n") ; GrB_Matrix_free_(&E) ;
4823 printf ("free F:\n") ; GrB_Matrix_free_(&F) ;
4824 printf ("free v:\n") ; GrB_Vector_free_(&v) ;
4825 printf ("free u:\n") ; GrB_Vector_free_(&u) ;
4826 printf ("free z:\n") ; GrB_Vector_free_(&z) ;
4827
4828 #define NWHAT 12
4829 n = NWHAT ;
4830 nvals = 40 ;
4831 uvals = 4 ;
4832 GrB_Index ilist [NWHAT] = { 8, 9, 0, 1, 5, 6, 11, 3, 2, 10, 7, 4 } ;
4833 GrB_Index jlist [NWHAT] = { 0, 11, 1, 7, 8, 4, 2, 3, 5, 6, 10, 9 } ;
4834
4835 OK (random_matrix (&A, false, false, n, n, nvals, 0, false)) ;
4836 OK (GrB_Vector_new (&u, GrB_FP64, n)) ;
4837 OK (GrB_Vector_setElement_FP64 (u, (double) 3.4, 0)) ;
4838
4839 E = A ;
4840 GrB_Matrix_dup (&A, A) ;
4841 CHECK (GB_mx_isequal (A, E, 0)) ;
4842 GrB_Matrix_free_(&E) ;
4843
4844 z = u ;
4845 GrB_Vector_dup (&u, u) ;
4846 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) z, 0)) ;
4847 GrB_Vector_free_(&z) ;
4848
4849 for (int what = 0 ; what <= 2 ; what++)
4850 {
4851
4852 GrB_Matrix Amask ;
4853 GrB_Vector umask ;
4854 switch (what)
4855 {
4856 case 0: Amask = NULL ; umask = NULL ; break ;
4857 case 1: Amask = A ; umask = u ; break ;
4858 case 2:
4859 OK (random_matrix (&Amask, false, false, n, n, nvals, 0, false)) ;
4860 OK (random_matrix (&F, false, false, n, 1, uvals, 0, false)) ;
4861 // vectors cannot be hypersparse
4862 OK (GxB_Matrix_Option_set_(F, GxB_SPARSITY_CONTROL, GxB_SPARSE)) ;
4863 // vectors cannot be CSC: this is a hack just for brutal testing
4864 OK (GxB_Matrix_Option_set_(F, GxB_FORMAT, GxB_BY_COL)) ;
4865 umask = (GrB_Vector) F ;
4866 F = NULL ;
4867 default:
4868 break ;
4869 }
4870
4871 CHECK (umask == NULL || GB_VECTOR_OK (umask)) ;
4872
4873 //----------------------------------------------------------------------
4874 // GrB_mxm, GrB_vxm, and GrB_mxv
4875 //----------------------------------------------------------------------
4876
4877 OK (GrB_Matrix_dup (&B, A)) ;
4878 OK (GrB_mxm (B, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4879 OK (GrB_mxm (A, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4880 OK (GxB_Matrix_fprint (A, "A ok", G3, ff)) ;
4881 OK (GxB_Matrix_fprint (B, "B ok", G3, ff)) ;
4882 if (Amask != NULL)
4883 {
4884 OK (GxB_Matrix_fprint (Amask, "Amask ok", G3, ff)) ;
4885 }
4886
4887 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4888 GrB_Matrix_free_(&B) ;
4889
4890 OK (GrB_Vector_dup (&v, u)) ;
4891 OK (GrB_vxm (v, umask, NULL, GxB_PLUS_TIMES_FP64, u, A, NULL)) ;
4892
4893 OK (GrB_vxm (u, umask, NULL, GxB_PLUS_TIMES_FP64, u, A, NULL)) ;
4894 OK (GxB_Vector_fprint (u, "u ok", G3, ff)) ;
4895 OK (GxB_Vector_fprint (v, "v ok", G3, ff)) ;
4896 if (umask != NULL)
4897 {
4898 OK (GxB_Vector_fprint (umask, "umask ok", G3, ff)) ;
4899 }
4900
4901 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4902 GrB_Vector_free_(&v) ;
4903
4904 OK (GrB_Vector_dup (&v, u)) ;
4905 OK (GrB_mxv (v, umask, NULL, GxB_PLUS_TIMES_FP64, A, u, NULL)) ;
4906 OK (GrB_mxv (u, umask, NULL, GxB_PLUS_TIMES_FP64, A, u, NULL)) ;
4907 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4908 GrB_Vector_free_(&v) ;
4909
4910 //----------------------------------------------------------------------
4911 // GrB_eWiseMult
4912 //----------------------------------------------------------------------
4913
4914 OK (GrB_Vector_dup (&v, u)) ;
4915 OK (GrB_Vector_eWiseMult_Semiring_(v, umask, NULL, GxB_PLUS_TIMES_FP64, u, u, NULL)) ;
4916 OK (GrB_Vector_eWiseMult_Semiring_(u, umask, NULL, GxB_PLUS_TIMES_FP64, u, u, NULL)) ;
4917 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4918 GrB_Vector_free_(&v) ;
4919
4920 OK (GrB_Vector_dup (&v, u)) ;
4921 OK (GrB_Vector_eWiseMult_Monoid_(v, umask, NULL, GxB_PLUS_FP64_MONOID, u, u, NULL)) ;
4922 OK (GrB_Vector_eWiseMult_Monoid_(u, umask, NULL, GxB_PLUS_FP64_MONOID, u, u, NULL)) ;
4923 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4924 GrB_Vector_free_(&v) ;
4925
4926 OK (GrB_Vector_dup (&v, u)) ;
4927 OK (GrB_Vector_eWiseMult_BinaryOp_(v, umask, NULL, GrB_PLUS_FP64, u, u, NULL)) ;
4928 OK (GrB_Vector_eWiseMult_BinaryOp_(u, umask, NULL, GrB_PLUS_FP64, u, u, NULL)) ;
4929 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4930 GrB_Vector_free_(&v) ;
4931
4932 OK (GrB_Matrix_dup (&B, A)) ;
4933 OK (GrB_Matrix_eWiseMult_Semiring_(B, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4934 OK (GrB_Matrix_eWiseMult_Semiring_(A, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4935 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4936 GrB_Matrix_free_(&B) ;
4937
4938 OK (GrB_Matrix_dup (&B, A)) ;
4939 OK (GrB_Matrix_eWiseMult_Monoid_(B, Amask, NULL, GxB_PLUS_FP64_MONOID, A, A, NULL)) ;
4940 OK (GrB_Matrix_eWiseMult_Monoid_(A, Amask, NULL, GxB_PLUS_FP64_MONOID, A, A, NULL)) ;
4941 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4942 GrB_Matrix_free_(&B) ;
4943
4944 OK (GrB_Matrix_dup (&B, A)) ;
4945 OK (GrB_Matrix_eWiseMult_BinaryOp_(B, Amask, NULL, GrB_PLUS_FP64, A, A, NULL)) ;
4946 OK (GrB_Matrix_eWiseMult_BinaryOp_(A, Amask, NULL, GrB_PLUS_FP64, A, A, NULL)) ;
4947 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4948 GrB_Matrix_free_(&B) ;
4949
4950 //----------------------------------------------------------------------
4951 // GrB_eWiseAdd
4952 //----------------------------------------------------------------------
4953
4954 OK (GrB_Vector_dup (&v, u)) ;
4955 OK (GrB_Vector_eWiseAdd_Semiring_(v, umask, NULL, GxB_PLUS_TIMES_FP64, u, u, NULL)) ;
4956 OK (GrB_Vector_eWiseAdd_Semiring_(u, umask, NULL, GxB_PLUS_TIMES_FP64, u, u, NULL)) ;
4957 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4958 GrB_Vector_free_(&v) ;
4959
4960 OK (GrB_Vector_dup (&v, u)) ;
4961 OK (GrB_Vector_eWiseAdd_Monoid_(v, umask, NULL, GxB_PLUS_FP64_MONOID, u, u, NULL)) ;
4962 OK (GrB_Vector_eWiseAdd_Monoid_(u, umask, NULL, GxB_PLUS_FP64_MONOID, u, u, NULL)) ;
4963 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4964 GrB_Vector_free_(&v) ;
4965
4966 OK (GrB_Vector_dup (&v, u)) ;
4967 OK (GrB_Vector_eWiseAdd_BinaryOp_(v, umask, NULL, GrB_PLUS_FP64, u, u, NULL)) ;
4968 OK (GrB_Vector_eWiseAdd_BinaryOp_(u, umask, NULL, GrB_PLUS_FP64, u, u, NULL)) ;
4969 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
4970 GrB_Vector_free_(&v) ;
4971
4972 OK (GrB_Matrix_dup (&B, A)) ;
4973 OK (GrB_Matrix_eWiseAdd_Semiring_(B, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4974 OK (GrB_Matrix_eWiseAdd_Semiring_(A, Amask, NULL, GxB_PLUS_TIMES_FP64, A, A, NULL)) ;
4975 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4976 GrB_Matrix_free_(&B) ;
4977
4978 OK (GrB_Matrix_dup (&B, A)) ;
4979 OK (GrB_Matrix_eWiseAdd_Monoid_(B, Amask, NULL, GxB_PLUS_FP64_MONOID, A, A, NULL)) ;
4980 OK (GrB_Matrix_eWiseAdd_Monoid_(A, Amask, NULL, GxB_PLUS_FP64_MONOID, A, A, NULL)) ;
4981 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4982 GrB_Matrix_free_(&B) ;
4983
4984 OK (GrB_Matrix_dup (&B, A)) ;
4985 OK (GrB_Matrix_eWiseAdd_BinaryOp_(B, Amask, NULL, GrB_PLUS_FP64, A, A, NULL)) ;
4986 OK (GrB_Matrix_eWiseAdd_BinaryOp_(A, Amask, NULL, GrB_PLUS_FP64, A, A, NULL)) ;
4987 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
4988 GrB_Matrix_free_(&B) ;
4989
4990 //----------------------------------------------------------------------
4991 // GrB_extract
4992 //----------------------------------------------------------------------
4993
4994 printf ("\nGrB_extract ============================================\n");
4995
4996 OK (GrB_Vector_dup (&v, u)) ;
4997 GB_Vector_check (u, "start u ", G3, NULL) ;
4998 GB_Vector_check (v, "start v ", G3, NULL) ;
4999 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5000
5001 OK (GrB_Vector_extract_(u, umask, NULL, u, GrB_ALL, n, NULL)) ;
5002 GB_Vector_check (u, "u to check", G3, NULL) ;
5003 GB_Vector_check (v, "v to check", G3, NULL) ;
5004 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5005 GrB_Vector_free_(&v) ;
5006
5007 OK (GrB_Matrix_dup (&B, A)) ;
5008 OK (GrB_Matrix_extract_(B, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5009 OK (GrB_Matrix_extract_(A, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5010 CHECK (GB_mx_isequal (A, B, 0)) ;
5011 GrB_Matrix_free_(&B) ;
5012
5013 OK (GrB_Vector_dup (&v, u)) ;
5014 OK (GrB_Col_extract_(v, umask, NULL, A, GrB_ALL, n, 0, NULL)) ;
5015 OK (GrB_Col_extract_(u, umask, NULL, A, GrB_ALL, n, 0, NULL)) ;
5016 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5017 GrB_Vector_free_(&v) ;
5018
5019 //----------------------------------------------------------------------
5020 // GxB_subassign
5021 //----------------------------------------------------------------------
5022
5023 OK (GrB_Matrix_dup (&B, A)) ;
5024 OK (GxB_Matrix_subassign (B, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5025 OK (GxB_Matrix_subassign (A, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5026
5027 GB_Matrix_wait (A, "A", Context) ;
5028 GB_Matrix_wait (B, "B", Context) ;
5029 CHECK (GB_mx_isequal (A, B, 0)) ;
5030 GrB_Matrix_free_(&B) ;
5031
5032 OK (GrB_Matrix_dup (&B, A)) ;
5033 OK (GxB_Matrix_subassign (B, Amask, NULL, A, ilist, n, jlist, n, NULL));
5034 OK (GxB_Matrix_subassign (A, Amask, NULL, A, ilist, n, jlist, n, NULL));
5035 GB_Matrix_wait (A, "A", Context) ;
5036 GB_Matrix_wait (B, "B", Context) ;
5037 CHECK (GB_mx_isequal (A, B, 0)) ;
5038 GrB_Matrix_free_(&B) ;
5039
5040 OK (GrB_Vector_dup (&v, u)) ;
5041 OK (GxB_Vector_subassign (v, umask, NULL, u, GrB_ALL, n, NULL)) ;
5042 OK (GxB_Vector_subassign (u, umask, NULL, u, GrB_ALL, n, NULL)) ;
5043 GB_Matrix_wait ((GrB_Matrix) u, "u", Context) ;
5044 GB_Matrix_wait ((GrB_Matrix) v, "v", Context) ;
5045 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5046 GrB_Vector_free_(&v) ;
5047
5048 OK (GrB_Vector_dup (&v, u)) ;
5049 OK (GxB_Vector_subassign (v, umask, NULL, u, ilist, n, NULL)) ;
5050 OK (GxB_Vector_subassign (u, umask, NULL, u, ilist, n, NULL)) ;
5051 GB_Matrix_wait ((GrB_Matrix) v, "v", Context) ;
5052 GB_Matrix_wait ((GrB_Matrix) u, "u", Context) ;
5053
5054 OK (GxB_Vector_fprint_(v, G3, NULL)) ;
5055 OK (GxB_Vector_fprint_(u, G3, NULL)) ;
5056 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5057 GrB_Vector_free_(&v) ;
5058
5059 //----------------------------------------------------------------------
5060 // GrB_assign
5061 //----------------------------------------------------------------------
5062
5063 OK (GrB_Matrix_dup (&B, A)) ;
5064 OK (GrB_Matrix_assign_(B, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5065 OK (GrB_Matrix_assign_(A, Amask, NULL, A, GrB_ALL, n, GrB_ALL, n, NULL)) ;
5066 CHECK (GB_mx_isequal (A, B, 0)) ;
5067 GrB_Matrix_free_(&B) ;
5068
5069 OK (GrB_Matrix_dup (&B, A)) ;
5070 OK (GrB_Matrix_assign_(B, Amask, NULL, A, ilist, n, jlist, n, NULL)) ;
5071 OK (GrB_Matrix_assign_(A, Amask, NULL, A, ilist, n, jlist, n, NULL)) ;
5072 if (!GB_IS_FULL (B)) GB_Matrix_wait (B, "B", Context) ;
5073 if (!GB_IS_FULL (A)) GB_Matrix_wait (A, "A", Context) ;
5074 CHECK (GB_mx_isequal (A, B, 0)) ;
5075 GrB_Matrix_free_(&B) ;
5076
5077 OK (GrB_Vector_dup (&v, u)) ;
5078 OK (GrB_Vector_assign_(v, umask, NULL, u, GrB_ALL, n, NULL)) ;
5079 OK (GrB_Vector_assign_(u, umask, NULL, u, GrB_ALL, n, NULL)) ;
5080 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5081 GrB_Vector_free_(&v) ;
5082
5083 OK (GrB_Vector_dup (&v, u)) ;
5084 OK (GrB_Vector_assign_(v, umask, NULL, u, ilist, n, NULL)) ;
5085 OK (GrB_Vector_assign_(u, umask, NULL, u, ilist, n, NULL)) ;
5086 if (!GB_IS_FULL (v)) GB_Matrix_wait ((GrB_Matrix) v, "v", Context) ;
5087 if (!GB_IS_FULL (u)) GB_Matrix_wait ((GrB_Matrix) u, "u", Context) ;
5088 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5089 GrB_Vector_free_(&v) ;
5090
5091 //----------------------------------------------------------------------
5092 // GrB_apply
5093 //----------------------------------------------------------------------
5094
5095 OK (GrB_Matrix_dup (&B, A)) ;
5096 OK (GrB_Matrix_apply_(B, Amask, NULL, GrB_AINV_FP64, A, NULL)) ;
5097 OK (GrB_Matrix_apply_(A, Amask, NULL, GrB_AINV_FP64, A, NULL)) ;
5098 CHECK (GB_mx_isequal (A, B, 1e-14)) ;
5099 GrB_Matrix_free_(&B) ;
5100
5101 OK (GrB_Vector_dup (&v, u)) ;
5102 OK (GrB_Vector_apply_(v, umask, NULL, GrB_AINV_FP64, u, NULL)) ;
5103 OK (GrB_Vector_apply_(u, umask, NULL, GrB_AINV_FP64, u, NULL)) ;
5104 OK (GxB_Vector_fprint_(v, G3, NULL)) ;
5105 OK (GxB_Vector_fprint_(u, G3, NULL)) ;
5106 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 1e-14)) ;
5107 GrB_Vector_free_(&v) ;
5108
5109 //----------------------------------------------------------------------
5110 // GxB_select
5111 //----------------------------------------------------------------------
5112
5113 OK (GrB_Matrix_dup (&B, A)) ;
5114 OK (GxB_Matrix_select_(B, Amask, NULL, GxB_NONZERO, A, NULL, NULL)) ;
5115 OK (GxB_Matrix_select_(A, Amask, NULL, GxB_NONZERO, A, NULL, NULL)) ;
5116 CHECK (GB_mx_isequal (A, B, 0)) ;
5117 GrB_Matrix_free_(&B) ;
5118
5119 OK (GrB_Vector_dup (&v, u)) ;
5120 OK (GxB_Vector_select_(v, umask, NULL, GxB_NONZERO, u, NULL, NULL)) ;
5121 OK (GxB_Vector_select_(u, umask, NULL, GxB_NONZERO, u, NULL, NULL)) ;
5122 CHECK (GB_mx_isequal ((GrB_Matrix) u, (GrB_Matrix) v, 0)) ;
5123 GrB_Vector_free_(&v) ;
5124
5125 //----------------------------------------------------------------------
5126 // GrB_transepose
5127 //----------------------------------------------------------------------
5128
5129 OK (GrB_Matrix_dup (&B, A)) ;
5130
5131 OK (GrB_transpose (B, Amask, NULL, A, NULL)) ;
5132 OK (GrB_transpose (A, Amask, NULL, A, NULL)) ;
5133 GrB_Index ignore ;
5134 OK (GrB_Matrix_wait (&A)) ;
5135 OK (GrB_Matrix_wait (&B)) ;
5136 CHECK (GB_mx_isequal (A, B, 0)) ;
5137 GrB_Matrix_free_(&B) ;
5138
5139 if (what == 2)
5140 {
5141 GrB_Matrix_free_(&Amask) ;
5142 GrB_Vector_free_(&umask) ;
5143 }
5144 }
5145
5146 //--------------------------------------------------------------------------
5147 // nthreads
5148 //--------------------------------------------------------------------------
5149
5150 printf ("\n----------------------------- nthreads\n") ;
5151
5152 int nthreads ;
5153
5154 OK (GxB_Global_Option_set_(GxB_NTHREADS, 42)) ;
5155 OK (GxB_Global_Option_get_(GxB_NTHREADS, &nthreads)) ;
5156 CHECK (nthreads == 42) ;
5157
5158 OK (GxB_Desc_set (desc, GxB_NTHREADS, 43)) ;
5159 OK (GxB_Desc_get (desc, GxB_NTHREADS, &nthreads)) ;
5160 CHECK (nthreads == 43) ;
5161
5162 OK (GxB_Desc_set (desc, GxB_DESCRIPTOR_NTHREADS, 44)) ;
5163 OK (GxB_Desc_get (desc, GxB_DESCRIPTOR_NTHREADS, &nthreads)) ;
5164 CHECK (nthreads == 44) ;
5165
5166 //--------------------------------------------------------------------------
5167 // import/export
5168 //--------------------------------------------------------------------------
5169
5170 printf ("\n----------------------------- import/export\n") ;
5171 OK (GxB_Matrix_fprint (A, "A to import/export", GxB_COMPLETE, stdout)) ;
5172 GrB_Index *Ap, *Ai, *Aj, *Ah, nrows, ncols, nvecs ;
5173 double *Ax ;
5174 GrB_Type atype ;
5175 bool jumbled, is_uniform ;
5176 int64_t Ap_size, Aj_size, Ai_size, Ax_size, Ah_size, Ab_size ;
5177
5178 OK (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5179 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5180 &jumbled, desc)) ;
5181
5182 OK (GxB_Type_fprint (atype, "type of A", GxB_COMPLETE, stdout)) ;
5183 printf ("Ax_size %llu\n", Ax_size) ;
5184 for (int64_t i = 0 ; i < ((int64_t) nrows) ; i++)
5185 {
5186 printf ("exported row %lld\n", j) ;
5187 for (int64_t p = Ap [i] ; p < ((int64_t) (Ap [i+1])) ; p++)
5188 {
5189 printf (" col %lld value %g\n", Aj [p], Ax [p]) ;
5190 }
5191 }
5192 OK (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5193 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform, jumbled, desc)) ;
5194
5195 OK (GxB_Matrix_fprint (A, "A imported", GxB_COMPLETE, stdout)) ;
5196
5197 expected = GrB_NULL_POINTER ;
5198
5199
5200
5201
5202 ERR (GxB_Matrix_export_CSR (NULL, &atype, &nrows, &ncols,
5203 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5204 &jumbled, desc)) ;
5205
5206 ERR (GxB_Matrix_export_CSR (&A, NULL, &nrows, &ncols,
5207 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5208 &jumbled, desc)) ;
5209
5210 ERR (GxB_Matrix_export_CSR (&A, &atype, NULL, &ncols,
5211 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5212 &jumbled, desc)) ;
5213
5214 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, NULL,
5215 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5216 &jumbled, desc)) ;
5217
5218 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5219 NULL, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5220 &jumbled, desc)) ;
5221
5222 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5223 &Ap, NULL, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5224 &jumbled, desc)) ;
5225
5226 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5227 &Ap, &Aj, NULL, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5228 &jumbled, desc)) ;
5229
5230 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5231 &Ap, &Aj, &Ax, NULL, &Aj_size, &Ax_size, &is_uniform,
5232 &jumbled, desc)) ;
5233
5234 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5235 &Ap, &Aj, &Ax, &Ap_size, NULL, &Ax_size, &is_uniform,
5236 &jumbled, desc)) ;
5237
5238 ERR (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5239 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, NULL, &is_uniform,
5240 &jumbled, desc)) ;
5241
5242
5243 ERR (GxB_Matrix_export_CSC (NULL, &atype, &nrows, &ncols,
5244 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5245 &jumbled, desc)) ;
5246
5247 ERR (GxB_Matrix_export_CSC (&A, NULL, &nrows, &ncols,
5248 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5249 &jumbled, desc)) ;
5250
5251 ERR (GxB_Matrix_export_CSC (&A, &atype, NULL, &ncols,
5252 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5253 &jumbled, desc)) ;
5254
5255 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, NULL,
5256 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5257 &jumbled, desc)) ;
5258
5259 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5260 NULL, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5261 &jumbled, desc)) ;
5262
5263 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5264 &Ap, NULL, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5265 &jumbled, desc)) ;
5266
5267 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5268 &Ap, &Ai, NULL, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5269 &jumbled, desc)) ;
5270
5271 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5272 &Ap, &Ai, &Ax, NULL, &Ai_size, &Ax_size, &is_uniform,
5273 &jumbled, desc)) ;
5274
5275 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5276 &Ap, &Ai, &Ax, &Ap_size, NULL, &Ax_size, &is_uniform,
5277 &jumbled, desc)) ;
5278
5279 ERR (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5280 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, NULL, &is_uniform,
5281 &jumbled, desc)) ;
5282
5283
5284
5285 ERR (GxB_Matrix_export_HyperCSR (NULL, &atype, &nrows, &ncols,
5286 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5287 &nvec, &jumbled, desc)) ;
5288
5289 ERR (GxB_Matrix_export_HyperCSR (&A, NULL, &nrows, &ncols,
5290 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5291 &nvec, &jumbled, desc)) ;
5292
5293 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, NULL, &ncols,
5294 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5295 &nvec, &jumbled, desc)) ;
5296
5297 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, NULL,
5298 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5299 &nvec, &jumbled, desc)) ;
5300
5301 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5302 NULL, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5303 &nvec, &jumbled, desc)) ;
5304
5305 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5306 &Ap, NULL, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5307 &nvec, &jumbled, desc)) ;
5308
5309 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5310 &Ap, &Ah, NULL, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5311 &nvec, &jumbled, desc)) ;
5312
5313 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5314 &Ap, &Ah, &Aj, NULL, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5315 &nvec, &jumbled, desc)) ;
5316
5317 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5318 &Ap, &Ah, &Aj, &Ax, NULL, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5319 &nvec, &jumbled, desc)) ;
5320
5321 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5322 &Ap, &Ah, &Aj, &Ax, &Ap_size, NULL, &Aj_size, &Ax_size, &is_uniform,
5323 &nvec, &jumbled, desc)) ;
5324
5325 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5326 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, NULL, &Ax_size, &is_uniform,
5327 &nvec, &jumbled, desc)) ;
5328
5329 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5330 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, NULL, &is_uniform,
5331 &nvec, &jumbled, desc)) ;
5332
5333 ERR (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5334 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5335 NULL, &jumbled, desc)) ;
5336
5337
5338
5339
5340
5341 ERR (GxB_Matrix_export_HyperCSC (NULL, &atype, &nrows, &ncols,
5342 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5343 &nvec, &jumbled, desc)) ;
5344
5345 ERR (GxB_Matrix_export_HyperCSC (&A, NULL, &nrows, &ncols,
5346 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5347 &nvec, &jumbled, desc)) ;
5348
5349 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, NULL, &ncols,
5350 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5351 &nvec, &jumbled, desc)) ;
5352
5353 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, NULL,
5354 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5355 &nvec, &jumbled, desc)) ;
5356
5357 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5358 NULL, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5359 &nvec, &jumbled, desc)) ;
5360
5361 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5362 &Ap, NULL, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5363 &nvec, &jumbled, desc)) ;
5364
5365 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5366 &Ap, &Ah, NULL, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5367 &nvec, &jumbled, desc)) ;
5368
5369 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5370 &Ap, &Ah, &Ai, NULL, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5371 &nvec, &jumbled, desc)) ;
5372
5373 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5374 &Ap, &Ah, &Ai, &Ax, NULL, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5375 &nvec, &jumbled, desc)) ;
5376
5377 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5378 &Ap, &Ah, &Ai, &Ax, &Ap_size, NULL, &Ai_size, &Ax_size, &is_uniform,
5379 &nvec, &jumbled, desc)) ;
5380
5381 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5382 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, NULL, &Ax_size, &is_uniform,
5383 &nvec, &jumbled, desc)) ;
5384
5385 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5386 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, NULL, &is_uniform,
5387 &nvec, &jumbled, desc)) ;
5388
5389 ERR (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5390 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5391 NULL, &jumbled, desc)) ;
5392
5393
5394 OK (GB_Matrix_check (A, "A still OK", G1, NULL)) ;
5395
5396 OK (GxB_Matrix_export_CSR (&A, &atype, &nrows, &ncols,
5397 &Ap, &Aj, &Ax, &Ap_size, &Aj_size, &Ax_size, &is_uniform,
5398 &jumbled, desc)) ;
5399
5400
5401 ERR (GxB_Matrix_import_CSR (NULL, atype, nrows, ncols,
5402 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5403 jumbled, desc)) ;
5404
5405 ERR (GxB_Matrix_import_CSR (&A, NULL, nrows, ncols,
5406 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5407 jumbled, desc)) ;
5408
5409 ERR (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5410 NULL, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5411 jumbled, desc)) ;
5412
5413 ERR (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5414 &Ap, NULL, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5415 jumbled, desc)) ;
5416
5417 ERR (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5418 &Ap, &Aj, NULL, Ap_size, Aj_size, Ax_size, is_uniform,
5419 jumbled, desc)) ;
5420
5421 expected = GrB_INVALID_VALUE ;
5422
5423 ERR (GxB_Matrix_import_CSR (&A, atype, INT64_MAX, ncols,
5424 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5425 jumbled, desc)) ;
5426
5427 ERR (GxB_Matrix_import_CSR (&A, atype, nrows, INT64_MAX,
5428 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5429 jumbled, desc)) ;
5430
5431 ERR (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5432 &Ap, &Aj, &Ax, Ap_size, Aj_size, INT64_MAX, is_uniform,
5433 jumbled, desc)) ;
5434
5435
5436 expected = GrB_NULL_POINTER ;
5437
5438 OK (GxB_Matrix_import_CSR (&A, atype, nrows, ncols,
5439 &Ap, &Aj, &Ax, Ap_size, Aj_size, Ax_size, is_uniform,
5440 jumbled, desc)) ;
5441
5442 OK (GB_Matrix_check (A, "A also OK", G1, NULL)) ;
5443
5444 OK (GxB_Matrix_export_CSC (&A, &atype, &nrows, &ncols,
5445 &Ap, &Ai, &Ax, &Ap_size, &Ai_size, &Ax_size, &is_uniform,
5446 &jumbled, desc)) ;
5447
5448
5449
5450 ERR (GxB_Matrix_import_CSC (NULL, atype, nrows, ncols,
5451 &Ap, &Ai, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5452 jumbled, desc)) ;
5453
5454 ERR (GxB_Matrix_import_CSC (&A, atype, nrows, ncols,
5455 NULL, &Ai, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5456 jumbled, desc)) ;
5457
5458 ERR (GxB_Matrix_import_CSC (&A, atype, nrows, ncols,
5459 &Ap, NULL, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5460 jumbled, desc)) ;
5461
5462 ERR (GxB_Matrix_import_CSC (&A, atype, nrows, ncols,
5463 &Ap, &Ai, NULL, Ap_size, Ai_size, Ax_size, is_uniform,
5464 jumbled, desc)) ;
5465
5466 expected = GrB_INVALID_VALUE ;
5467
5468 ERR (GxB_Matrix_import_CSC (&A, atype, INT64_MAX, ncols,
5469 &Ap, &Ai, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5470 jumbled, desc)) ;
5471
5472 ERR (GxB_Matrix_import_CSC (&A, atype, nrows, INT64_MAX,
5473 &Ap, &Ai, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5474 jumbled, desc)) ;
5475
5476 ERR (GxB_Matrix_import_CSC (&A, atype, nrows, ncols,
5477 &Ap, &Ai, &Ax, Ap_size, Ai_size, INT64_MAX, is_uniform,
5478 jumbled, desc)) ;
5479
5480
5481 expected = GrB_NULL_POINTER ;
5482
5483 OK (GxB_Matrix_import_CSC (&A, atype, nrows, ncols,
5484 &Ap, &Ai, &Ax, Ap_size, Ai_size, Ax_size, is_uniform,
5485 jumbled, desc)) ;
5486
5487 OK (GB_Matrix_check (A, "A here too OK", G1, NULL)) ;
5488
5489 OK (GxB_Matrix_export_HyperCSR (&A, &atype, &nrows, &ncols,
5490 &Ap, &Ah, &Aj, &Ax, &Ap_size, &Ah_size, &Aj_size, &Ax_size, &is_uniform,
5491 &nvecs, &jumbled, desc)) ;
5492
5493
5494
5495 ERR (GxB_Matrix_import_HyperCSR (NULL, atype, nrows, ncols,
5496 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5497 nvecs, jumbled, desc)) ;
5498
5499 ERR (GxB_Matrix_import_HyperCSR (&A, NULL, nrows, ncols,
5500 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5501 nvecs, jumbled, desc)) ;
5502
5503 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5504 NULL, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5505 nvecs, jumbled, desc)) ;
5506
5507 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5508 &Ap, NULL, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5509 nvecs, jumbled, desc)) ;
5510
5511 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5512 &Ap, &Ah, NULL, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5513 nvecs, jumbled, desc)) ;
5514
5515 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5516 &Ap, &Ah, &Aj, NULL, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5517 nvecs, jumbled, desc)) ;
5518
5519
5520 expected = GrB_INVALID_VALUE ;
5521
5522 ERR (GxB_Matrix_import_HyperCSR (&A, atype, INT64_MAX, ncols,
5523 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5524 nvecs, jumbled, desc)) ;
5525
5526 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, INT64_MAX,
5527 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5528 nvecs, jumbled, desc)) ;
5529
5530 ERR (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5531 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, INT64_MAX, is_uniform,
5532 nvecs, jumbled, desc)) ;
5533
5534
5535
5536 expected = GrB_NULL_POINTER ;
5537
5538 OK (GxB_Matrix_import_HyperCSR (&A, atype, nrows, ncols,
5539 &Ap, &Ah, &Aj, &Ax, Ap_size, Ah_size, Aj_size, Ax_size, is_uniform,
5540 nvecs, jumbled, desc)) ;
5541
5542 OK (GB_Matrix_check (A, "A yet still OK", G1, NULL)) ;
5543
5544 OK (GxB_Matrix_export_HyperCSC (&A, &atype, &nrows, &ncols,
5545 &Ap, &Ah, &Ai, &Ax, &Ap_size, &Ah_size, &Ai_size, &Ax_size, &is_uniform,
5546 &nvecs, &jumbled, desc)) ;
5547
5548
5549
5550 ERR (GxB_Matrix_import_HyperCSC (NULL, atype, nrows, ncols,
5551 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5552 nvecs, jumbled, desc)) ;
5553
5554 ERR (GxB_Matrix_import_HyperCSC (&A, NULL, nrows, ncols,
5555 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5556 nvecs, jumbled, desc)) ;
5557
5558 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5559 NULL, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5560 nvecs, jumbled, desc)) ;
5561
5562 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5563 &Ap, NULL, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5564 nvecs, jumbled, desc)) ;
5565
5566 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5567 &Ap, &Ah, NULL, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5568 nvecs, jumbled, desc)) ;
5569
5570 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5571 &Ap, &Ah, &Ai, NULL, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5572 nvecs, jumbled, desc)) ;
5573
5574 expected = GrB_INVALID_VALUE ;
5575
5576 ERR (GxB_Matrix_import_HyperCSC (&A, atype, INT64_MAX, ncols,
5577 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5578 nvecs, jumbled, desc)) ;
5579
5580 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, INT64_MAX,
5581 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5582 nvecs, jumbled, desc)) ;
5583
5584 ERR (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5585 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, INT64_MAX, is_uniform,
5586 nvecs, jumbled, desc)) ;
5587
5588 expected = GrB_NULL_POINTER ;
5589
5590 OK (GxB_Matrix_import_HyperCSC (&A, atype, nrows, ncols,
5591 &Ap, &Ah, &Ai, &Ax, Ap_size, Ah_size, Ai_size, Ax_size, is_uniform,
5592 nvecs, jumbled, desc)) ;
5593
5594 OK (GB_Matrix_check (A, "A yet again OK", G1, NULL)) ;
5595
5596 //--------------------------------------------------------------------------
5597 // vector import/export
5598 //--------------------------------------------------------------------------
5599
5600 nvals = 99 ;
5601 OK (GxB_Vector_fprint (u, "u to import/export", GxB_COMPLETE, stdout)) ;
5602 GrB_Type utype ;
5603 OK (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax,
5604 &Ai_size, &Ax_size, &is_uniform,
5605 &nvals, &jumbled, desc)) ;
5606
5607 OK (GxB_Type_fprint (utype, "type of u", GxB_COMPLETE, stdout)) ;
5608 printf ("nvals %llu\n", nvals) ;
5609 CHECK (nvals != 99) ;
5610 for (int64_t p = 0 ; p < ((int64_t) nvals) ; p++)
5611 {
5612 int64_t i = Ai [p] ;
5613 double x = Ax [p] ;
5614 CHECK (i >= 0 && i < n) ;
5615 printf (" col %lld value %g\n", Ai [p], Ax [p]) ;
5616 }
5617 OK (GxB_Vector_import_CSC (&u, utype, n, &Ai, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5618 OK (GxB_Vector_fprint (u, "u imported", GxB_COMPLETE, stdout)) ;
5619
5620 expected = GrB_NULL_POINTER ;
5621
5622 ERR (GxB_Vector_export_CSC (NULL, &utype, &n, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5623 ERR (GxB_Vector_export_CSC (&u, NULL, &n, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5624 ERR (GxB_Vector_export_CSC (&u, &utype, NULL, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5625 ERR (GxB_Vector_export_CSC (&u, &utype, &n, NULL, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5626 ERR (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, NULL, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5627 ERR (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax, NULL, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5628 ERR (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax, &Ai_size, NULL, &is_uniform, &nvals, &jumbled, desc)) ;
5629 ERR (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, NULL, &jumbled, desc)) ;
5630 // ERR (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, NULL, desc)) ;
5631
5632 OK (GB_Vector_check (u, "u still OK", G1, NULL)) ;
5633
5634 OK (GxB_Vector_export_CSC (&u, &utype, &n, &Ai, &Ax, &Ai_size, &Ax_size, &is_uniform, &nvals, &jumbled, desc)) ;
5635
5636 ERR (GxB_Vector_import_CSC (NULL, utype, n, &Ai, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5637 ERR (GxB_Vector_import_CSC (&u, NULL, n, &Ai, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5638 ERR (GxB_Vector_import_CSC (&u, utype, n, NULL, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5639 ERR (GxB_Vector_import_CSC (&u, utype, n, &Ai, NULL, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5640
5641 expected = GrB_INVALID_VALUE ;
5642 ERR (GxB_Vector_import_CSC (&u, utype, INT64_MAX, &Ai, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5643 ERR (GxB_Vector_import_CSC (&u, utype, n, &Ai, &Ax, INT64_MAX, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5644
5645 expected = GrB_NULL_POINTER ;
5646
5647 OK (GxB_Vector_import_CSC (&u, utype, n, &Ai, &Ax, Ai_size, Ax_size, is_uniform, nvals, jumbled, desc)) ;
5648
5649 OK (GB_Vector_check (u, "u still OK", G3, NULL)) ;
5650
5651 //--------------------------------------------------------------------------
5652 // free all
5653 //--------------------------------------------------------------------------
5654
5655 // this is also done by FREE_ALL, but the list is meant to be
5656 // accurate, so nmalloc should be zero at the check below
5657
5658 nmalloc = GB_Global_nmalloc_get ( ) ;
5659 printf ("\n\nfree all: nmalloc %d\n", nmalloc) ;
5660
5661 GrB_Matrix_free_(&Empty1) ; CHECK (Empty1 == NULL) ;
5662 GrB_Vector_free_(&v) ; CHECK (v == NULL) ;
5663 GrB_Vector_free_(&u) ; CHECK (u == NULL) ;
5664 GrB_Matrix_free_(&A) ; CHECK (A == NULL) ;
5665 GrB_Vector_free_(&u) ; CHECK (u == NULL) ;
5666 GrB_Vector_free_(&z) ; CHECK (z == NULL) ;
5667 GrB_Vector_free_(&h) ; CHECK (h == NULL) ;
5668 GrB_Matrix_free_(&B) ; CHECK (B == NULL) ;
5669 GrB_Matrix_free_(&C) ; CHECK (C == NULL) ;
5670 GrB_Matrix_free_(&E) ; CHECK (E == NULL) ;
5671 GrB_Matrix_free_(&F) ; CHECK (F == NULL) ;
5672 GrB_Matrix_free_(&Z) ; CHECK (Z == NULL) ;
5673 GrB_Matrix_free_(&H) ; CHECK (H == NULL) ;
5674 GrB_Type_free_(&T) ; CHECK (T == NULL) ;
5675 GrB_Matrix_free_(&Agunk) ; CHECK (Agunk == NULL) ;
5676 GrB_Type_free_(&Tgunk) ; CHECK (Tgunk == NULL) ;
5677 GrB_UnaryOp_free_(&op1gunk) ; CHECK (op1gunk == NULL) ;
5678 GrB_BinaryOp_free_(&op2gunk) ; CHECK (op2gunk == NULL) ;
5679 GrB_BinaryOp_free_(&op3) ; CHECK (op3 == NULL) ;
5680 GrB_UnaryOp_free_(&op1b) ; CHECK (op1b == NULL) ;
5681 GrB_BinaryOp_free_(&op2b) ; CHECK (op2b == NULL) ;
5682 GrB_Semiring_free_(&semiring2) ; CHECK (semiring2 == NULL) ;
5683 GrB_Descriptor_free_(&descb) ; CHECK (descb == NULL) ;
5684 GrB_Vector_free_(&vb) ; CHECK (vb == NULL) ;
5685 GrB_Monoid_free_(&monoidb) ; CHECK (monoidb == NULL) ;
5686 GrB_Monoid_free_(&monoid_gunk) ; CHECK (monoid_gunk == NULL) ;
5687 GrB_Semiring_free_(&semigunk) ; CHECK (semigunk == NULL) ;
5688 GrB_Vector_free_(&vgunk) ; CHECK (vgunk == NULL) ;
5689 GrB_Matrix_free_(&Aempty) ; CHECK (Aempty == NULL) ;
5690 GrB_Vector_free_(&vempty) ; CHECK (vempty == NULL) ;
5691 GrB_Descriptor_free_(&desc) ; CHECK (desc == NULL) ;
5692 GrB_Descriptor_free_(&dtn) ; CHECK (dtn == NULL) ;
5693 GrB_Descriptor_free_(&dnt) ; CHECK (dnt == NULL) ;
5694 GrB_Descriptor_free_(&dtt) ; CHECK (dtt == NULL) ;
5695 GrB_Descriptor_free_(&dgunk) ; CHECK (dgunk == NULL) ;
5696 GxB_SelectOp_free_(&selectop) ; CHECK (selectop == NULL) ;
5697 GxB_SelectOp_free_(&selectopgunk) ; CHECK (selectopgunk == NULL) ;
5698
5699 nmalloc = GB_Global_nmalloc_get ( ) ;
5700 printf ("nmalloc %d before complex_finalize\n", nmalloc) ;
5701 Complex_finalize ( ) ;
5702 nmalloc = GB_Global_nmalloc_get ( ) ;
5703 printf ("nmalloc %d done\n", nmalloc) ;
5704 GrB_finalize ( ) ;
5705 nmalloc = GB_Global_nmalloc_get ( ) ;
5706 printf ("nmalloc %d all freed\n", nmalloc) ;
5707
5708 FREE_ALL ;
5709 nmalloc = GB_Global_nmalloc_get ( ) ;
5710 printf ("nmalloc %d all freed\n", nmalloc) ;
5711 int64_t nblocks = GB_Global_free_pool_nblocks_total ( ) ;
5712 printf ("nblocks in free_pool %ld\n", nblocks) ;
5713 GrB_finalize ( ) ;
5714 nmalloc = GB_Global_nmalloc_get ( ) ;
5715 printf ("nmalloc %d after finalize\n", nmalloc) ;
5716 CHECK (nmalloc == 0) ;
5717 nblocks = GB_Global_free_pool_nblocks_total ( ) ;
5718 CHECK (nblocks == 0) ;
5719
5720 printf ("\ncheck errlog.txt for errors tested\n") ;
5721 printf ("All error-handling tests passed"
5722 " (all errors above were expected)\n") ;
5723 fprintf (f, "\nAll error-handling tests passed"
5724 " (all errors above were expected)\n") ;
5725 fclose (f) ;
5726 fclose (ff) ;
5727 }
5728
5729