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
|
function test162
%TEST162 test C<M>=A*B with very sparse M
% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
% SPDX-License-Identifier: Apache-2.0
semiring.add = 'plus' ;
semiring.multiply = 'times' ;
semiring.class = 'double' ;
rng ('default') ;
d = 0.02 ;
n = 1000 ;
A = sprand (n, n, d) ;
A (1:257,1) = rand (257, 1) ;
B = sprand (n, n, d) ;
B (1,1) = 1 ;
M = logical (sprand (n, n, 0.002)) ;
Cin = sparse (n, n) ;
C1 = double (M) .* (A*B) ;
C2 = GB_mex_mxm (Cin, M, [ ], semiring, A, B, [ ]) ;
GB_spec_compare (C1, C2) ;
clear A B M
n = 80 ;
A.matrix = sparse (rand (n)) ; A.sparsity = 4 ; % A is bitmap
B.matrix = sparse (rand (n)) ; B.sparsity = 4 ; % B is bitmap
M.matrix = logical (sprand (n, n, 0.5)) ; M.sparsity = 2 ; % M is sparse
desc.mask = 'complement' ;
Cin = sparse (n, n) ;
C1 = double (~(M.matrix)) .* (A.matrix*B.matrix) ;
C2 = GB_mex_mxm (Cin, M, [ ], semiring, A, B, desc) ;
GB_spec_compare (C1, C2) ;
M.sparsity = 4 ; % make M bitmap
M.matrix (1:64, 1:64) = 0 ; % clear the leading 64-by-64 tile
C1 = double (M.matrix) .* (A.matrix*B.matrix) ;
C2 = GB_mex_mxm (Cin, M, [ ], semiring, A, B, [ ]) ;
GB_spec_compare (C1, C2) ;
fprintf ('test162: all tests passed\n') ;
|