File: gbtest51.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 (79 lines) | stat: -rw-r--r-- 1,996 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
function gbtest51
%GBTEST51 test GrB.tricount and concatenate

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

files =  {
'./matrix/2blocks'
'./matrix/ash219'
'./matrix/bcsstk01'
'./matrix/bcsstk16'
'./matrix/eye3'
'./matrix/fs_183_1'
'./matrix/ibm32a'
'./matrix/ibm32b'
'./matrix/lp_afiro'
'./matrix/mbeacxc'
'./matrix/t1'
'./matrix/t2'
'./matrix/west0067' } ;
nfiles = length (files) ;

% the files in ./matrix that do not have a .mtx filename are zero-based.
desc.base = 'zero-based' ;

valid_count = [
           0
           0
         160
     1512964
           0
         863
           0
           0
           0
           0
           2
           0
         120 ] ;

[filepath, name, ext] = fileparts (mfilename ('fullpath')) ; %#ok<*ASGLU>

for k = 1:nfiles
    % fprintf ('--------------------------load file:\n') ;
    filename = files {k} ;
    T = load (fullfile (filepath, filename)) ;
    nz = size (T, 1) ;
    X = ones (nz,1) ;
    G = GrB.build (int64 (T (:,1)), int64 (T (:,2)), X, desc) ;
    A = sparse (T (:,1)+1, T (:,2)+1, X) ;
    assert (isequal (A,G))

    % fprintf ('--------------------------construct G:\n') ;
    [m, n] = size (G) ;
    if (m ~= n)
        G = [GrB(m,m) G ; G' GrB(n,n)] ; %#ok<*AGROW>   (concatenate)
    elseif (~issymmetric (G))
        G = G + G' ;
    end

    % fprintf ('--------------------------tricount (G):\n') ;
    c = GrB.tricount (G) ;
    % fprintf ('triangle count: %-30s : # triangles %d\n', filename, c) ;
    assert (c == valid_count (k)) ;

    % fprintf ('--------------------------convert G to by-row:\n') ;
    G = GrB (G, 'by row') ;

    % fprintf ('--------------------------tricount (G):\n') ;
    c = GrB.tricount (G) ;
    assert (c == valid_count (k)) ;
end

% fprintf ('--------------------------tricount (G, ''check''):\n') ;
c = GrB.tricount (G, 'check') ;
assert (c == valid_count (end)) ;

fprintf ('\ngbtest51: all tests passed\n') ;