1function test167 2%TEST167 test C<M>=A*B with very sparse M, different types of A and B 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7rng ('default') ; 8 9semiring.add = 'plus' ; 10semiring.multiply = 'times' ; 11semiring.class = 'double' ; 12 13d = 0.02 ; 14n = 1000 ; 15 16A.matrix = 100 * sprand (n, n, d) ; 17A.matrix (1:257,1) = rand (257, 1) ; 18 19B.matrix = 100 * sprand (n, n, d) ; 20B.matrix (1,1) = 1 ; 21M = logical (sprand (n, n, 0.002)) ; 22Cin.matrix = sparse (n, n) ; 23 24[~, ~, ~, types, ~, ~,] = GB_spec_opsall ; 25types = types.all ; 26 27for k = 1:length (types) 28 29 type = types {k} ; 30 semiring.class = type ; 31 A.class = type ; 32 B.class = type ; 33 Cin.class = type ; 34 fprintf ('%s ', type) ; 35 36 C2 = GB_mex_mxm (Cin, M, [ ], semiring, A, B, [ ]) ; 37 38 if (isequal (type, 'double')) 39 A2 = GB_spec_matrix (A) ; 40 B2 = GB_spec_matrix (B) ; 41 C1 = double (M) .* (A2.matrix * B2.matrix) ; 42 err = norm (C1 - C2.matrix, 1) / norm (C1, 1) ; 43 assert (err < 1e-12) ; 44 % C1 = GB_spec_mxm (Cin, M, [ ], semiring, A, B, [ ]) ; 45 % GB_spec_compare (C1, C2) ; 46 end 47end 48 49fprintf ('\ntest167: all tests passed\n') ; 50 51