File: gbtest96.m

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (100 lines) | stat: -rw-r--r-- 2,379 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
function gbtest96
%GBTEST96 test GrB.optype

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

fprintf ('Table of types of binary operators when inputs types are\n') ;
fprintf ('are mixed (the type of C for C=A+B, for example).\n') ;
fprintf ('\nLegend:\n') ;

types = gbtest_types ;
order = [ 3:11 2 1 12:13 ] ;
for k = order
    type = types {k} ;
    fprintf ('%2s : %s\n', gbterse (type), type) ;
end

fprintf ('\n   : ') ;
for k2 = order
    btype = types {k2} ;
    fprintf ('%2s ', gbterse (btype)) ;
end
fprintf ('\n') ;

fprintf ('---:---------------------------------------\n') ;

for k1 = order
    atype = types {k1} ;
    fprintf ('%2s : ', gbterse (atype)) ;
    for k2 = order
        btype = types {k2} ;
        ctype = GrB.optype (atype, btype) ;
        fprintf ('%2s ', gbterse (ctype)) ;

        c2 = GrB.optype (btype, atype) ;
        assert (isequal (c2, ctype)) ;

        A = GrB (1, atype) ;
        B = GrB (1, btype) ;
        c2 = GrB.optype (A, B) ;
        assert (isequal (c2, ctype)) ;

        if (isequal (atype, 'single complex'))
            A = complex (single (1)) ;
        elseif (isequal (atype, 'double complex'))
            A = complex (double (1)) ;
        else
            A = cast (1, atype) ;
        end

        c2 = GrB.optype (A, B) ;
        assert (isequal (c2, ctype)) ;

        if (isequal (btype, 'single complex'))
            B = complex (single (1)) ;
        elseif (isequal (btype, 'double complex'))
            B = complex (double (1)) ;
        else
            B = cast (1, btype) ;
        end

        c2 = GrB.optype (A, B) ;
        assert (isequal (c2, ctype)) ;

    end
    fprintf ('\n') ;
end

function s = gbterse(type)
switch (type)
    case { 'double' }
        s = 'd ' ;
    case { 'single' }
        s = 's ' ;
    case { 'logical' }
        s = 'b ' ;
    case { 'int8' }
        s = 'i1' ;
    case { 'int16' }
        s = 'i2' ;
    case { 'int32' }
        s = 'i4' ;
    case { 'int64' }
        s = 'i8' ;
    case { 'uint8' }
        s = 'u1' ;
    case { 'uint16' }
        s = 'u2' ;
    case { 'uint32' }
        s = 'u4' ;
    case { 'uint64' }
        s = 'u8' ;
    case { 'single complex' }
        s = 'c ' ;
    case { 'double complex' }
        s = 'z ' ;
    otherwise
        error ('invalid type') ;
end