File: GB_mex_test25.c

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (110 lines) | stat: -rw-r--r-- 4,184 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//------------------------------------------------------------------------------
// GB_mex_test25: more simple tests
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#include "GB_mex.h"
#include "GB_mex_errors.h"
#include "../Source/get_set/GB_get_set.h"

#define FREE_ALL ;
#define GET_DEEP_COPY ;
#define FREE_DEEP_COPY ;

void mexFunction
(
    int nargout,
    mxArray *pargout [ ],
    int nargin,
    const mxArray *pargin [ ]
)
{

    //--------------------------------------------------------------------------
    // startup GraphBLAS
    //--------------------------------------------------------------------------

    GrB_Info info ;
    bool malloc_debug = GB_mx_get_global (true) ;

    //--------------------------------------------------------------------------
    // GrB_Vector size
    //--------------------------------------------------------------------------

    GrB_Vector v ;
    uint64_t nmax = GrB_INDEX_MAX + 1 ;
    uint64_t nvals ;

    for (uint64_t n = nmax - 5 ; n <= nmax ; n++)
    {
        printf ("n %lu, nmax %lu, (n == nmax): %d\n", n, nmax, n == nmax) ;
        OK (GrB_Vector_new (&v, GrB_BOOL, n)) ;
        OK (GrB_assign (v, NULL, NULL, true, GrB_ALL, n, NULL)) ;
        OK (GxB_print (v, 1)) ;
        OK (GrB_Vector_nvals (&nvals, v)) ;
        CHECK (nvals == n) ;
        OK (GrB_Vector_free (&v)) ;
    }

    GrB_Matrix A ;
    uint64_t n = (GrB_INDEX_MAX + 1) / 2 ;
    OK (GrB_Matrix_new (&A, GrB_BOOL, n, 2)) ;
    OK (GrB_assign (A, NULL, NULL, true, GrB_ALL, n, GrB_ALL, 2, NULL)) ;
    OK (GxB_print (A, 1)) ;
    OK (GrB_Matrix_nvals (&nvals, A)) ;
    printf ("nvals (A) %lu\n", nvals) ;
    CHECK (nvals == INT64_MAX) ;
    OK (GrB_Matrix_free (&A)) ;

    //--------------------------------------------------------------------------
    // GxB_Context_error
    //--------------------------------------------------------------------------

    const char *s = NULL ;
    OK (GrB_error (&s, GxB_CONTEXT_WORLD)) ;
    CHECK (s != NULL) ;
    CHECK (strlen (s) == 0) ;
    printf ("GxB_Context_error [%s] ok\n", s) ;
    OK (GxB_Context_wait (GxB_CONTEXT_WORLD, GrB_COMPLETE)) ;

    //--------------------------------------------------------------------------
    // report object sizes
    //--------------------------------------------------------------------------

    printf ("%4d: sizeof (struct GB_Type_opaque)\n",
             (int) sizeof (struct GB_Type_opaque)) ;
    printf ("%4d: sizeof (struct GB_UnaryOp_opaque)\n",
             (int) sizeof (struct GB_UnaryOp_opaque)) ;
    printf ("%4d: sizeof (struct GB_BinaryOp_opaque)\n",
             (int) sizeof (struct GB_BinaryOp_opaque)) ;
    printf ("%4d: sizeof (struct GB_SelectOp_opaque)\n",
             (int) sizeof (struct GB_SelectOp_opaque)) ;
    printf ("%4d: sizeof (struct GB_Monoid_opaque)\n",
             (int) sizeof (struct GB_Monoid_opaque)) ;
    printf ("%4d: sizeof (struct GB_Semiring_opaque)\n",
             (int) sizeof (struct GB_Semiring_opaque)) ;
    printf ("%4d: sizeof (struct GB_Scalar_opaque)\n",
             (int) sizeof (struct GB_Scalar_opaque)) ;
    printf ("%4d: sizeof (struct GB_Vector_opaque)\n",
             (int) sizeof (struct GB_Vector_opaque)) ;
    printf ("%4d: sizeof (struct GB_Matrix_opaque)\n",
             (int) sizeof (struct GB_Matrix_opaque)) ;
    printf ("%4d: sizeof (struct GB_Descriptor_opaque)\n",
             (int) sizeof (struct GB_Descriptor_opaque)) ;
    printf ("%4d: sizeof (struct GB_Context_opaque)\n",
             (int) sizeof (struct GB_Context_opaque)) ;
    printf ("%4d: sizeof (struct GB_Global_opaque)\n",
             (int) sizeof (struct GB_Global_opaque)) ;

    //--------------------------------------------------------------------------
    // finalize GraphBLAS
    //--------------------------------------------------------------------------

    GB_mx_put_global (true) ;
    printf ("\nGB_mex_test25:  all tests passed\n\n") ;
}