File: GB_mex_test12.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 (90 lines) | stat: -rw-r--r-- 2,840 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
//------------------------------------------------------------------------------
// GB_mex_test12: 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"

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

typedef double mytype ;
#define MYTYPE_DEFN "typedef double mytype ;"

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

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

    GrB_Info info ;
    bool malloc_debug = GB_mx_get_global (true) ;

    //--------------------------------------------------------------------------
    // assign_scalar
    //--------------------------------------------------------------------------

    GrB_Matrix A ;
    GrB_Vector v ;
    GrB_Scalar scalar ;
    GrB_Type MyType ; 
    OK (GrB_Type_new (&MyType, sizeof (mytype))) ;
    OK (GxB_print (MyType, 3)) ;
    OK (GrB_Matrix_new (&A, MyType, 3, 3)) ;
    OK (GrB_Vector_new (&v, MyType, 3)) ;
    OK (GrB_Scalar_new (&scalar, GrB_FP32)) ;
    OK (GrB_Scalar_setElement (scalar, 3.1416)) ;

    GrB_Info expected = GrB_DOMAIN_MISMATCH ;
    const char *error ;

    ERR (GrB_Matrix_assign_Scalar_(A, NULL, NULL, scalar,
        GrB_ALL, 3, GrB_ALL, 3, NULL)) ;
    OK (GrB_Matrix_error (&error, A)) ;
    printf ("expected: %s\n", error) ;

    ERR (GxB_Matrix_subassign_Scalar_(A, NULL, NULL, scalar,
        GrB_ALL, 3, GrB_ALL, 3, NULL)) ;
    OK (GrB_Matrix_error (&error, A)) ;
    printf ("expected: %s\n", error) ;

    ERR (GrB_Vector_assign_Scalar_(v, NULL, NULL, scalar, GrB_ALL, 3, NULL)) ;
    OK (GrB_Vector_error (&error, v)) ;
    printf ("expected: %s\n", error) ;

    ERR (GxB_Vector_subassign_Scalar_(v, NULL, NULL, scalar, GrB_ALL, 3, NULL));
    OK (GrB_Vector_error (&error, v)) ;
    printf ("expected: %s\n", error) ;

    GrB_free (&A) ;
    GrB_free (&v) ;
    GrB_free (&MyType) ;
    GrB_free (&scalar) ;

    //--------------------------------------------------------------------------
    // GB_as_if_full
    //--------------------------------------------------------------------------

    CHECK (!GB_as_if_full (NULL)) ;

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

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