File: test240.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: 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 (80 lines) | stat: -rw-r--r-- 1,986 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
function test240
%TEST240 test GrB_mxm: dot4, saxpy4, saxpy5

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

[binops, ~, add_ops, types, ~, ~] = GB_spec_opsall ;
mult_ops = binops.all ;
types = types.all ;

fprintf ('test240 -------- GrB_mxm dot4 and saxpy5\n') ;

rng ('default') ;
GB_builtin_complex_set (true) ;

dnn = struct ;
dtn = struct ( 'inp0', 'tran' ) ;
dnt = struct ( 'inp1', 'tran' ) ;
dtt = struct ( 'inp0', 'tran', 'inp1', 'tran' ) ;

monoid.opname = 'plus' ;
monoid.optype = 'double' ;
semiring.add = monoid ;
semiring.multiply = 'times' ;
semiring.class = 'double' ;

n = 200 ;
is_csc = true ;
A = GB_spec_random (n, n, 0.5, 100, 'double', is_csc) ;
A.sparsity = 2 ;    % A is sparse

% test dot4
for k = 1:32
    % C += A'*B
    B = rand (n, k) ;
    F = rand (n, k) ;
    C1 = GB_mex_mxm_update (F, semiring, A, B, dtn) ;
    C2 = F + A.matrix'*B ;
    GB_spec_compare (C1, C2, 0, 1e-12) ;
end

% test saxpy5: A full, B sparse
for k = 1:32
    % C += A*B
    B = rand (k, n) ;
    F = rand (k, n) ;
    C1 = GB_mex_mxm_update (F, semiring, B, A, [ ]) ;
    C2 = F + B*A.matrix ;
    GB_spec_compare (C1, C2, 0, 1e-12) ;
end

% test saxpy5: A full, B sparse, with typecasting
A2 = A ;
A2.class = 'single' ;
for k = 1:32
    % C += A*B
    B = rand (k, n) ;
    F = rand (k, n) ;
    C1 = GB_mex_mxm_update (F, semiring, B, A2, [ ]) ;
    C2 = F + B*A.matrix ;
    GB_spec_compare (C1, C2, 0, 1e-5) ;
end

% test saxpy5: A iso bitmap, B sparse
A.sparsity = 4 ;    % A is bitmap
A.iso = true ;      % A is bitmap
A.matrix = pi * spones (A.matrix) ;
for k = 1:32
    % C += A*B
    B = GB_spec_random (n, k, 0.5, 100, 'double', is_csc) ;
    B.sparsity = 2 ;    % B is sparse
    F = rand (n, k) ;
    C1 = GB_mex_mxm_update (F, semiring, A, B, [ ]) ;
    C2 = F + A.matrix * B.matrix ;
    GB_spec_compare (C1, C2, 0, 1e-12) ;
end

% GB_mex_burble (0) ;
fprintf ('\ntest240: all tests passed\n') ;