1function test172
2%TEST172 eWiseMult with M bitmap/full
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7rng ('default') ;
8
9fprintf ('test172:\n') ;
10
11n = 500 ;
12
13    A = GB_spec_random (n, n, 0.05, 1, 'double') ;
14    A.sparsity = 2 ;    % sparse
15
16    B = GB_spec_random (n, n, 0.05, 1, 'double') ;
17    B.sparsity = 2 ;    % sparse
18
19    M = GB_spec_random (n, n, 0.1, 1, 'double') ;
20    M.matrix (1,1) = 1 ;
21    M.pattern (1,1) = true ;
22    M.sparsity = 4 ;    % bitmap
23
24    Cin = sparse (n,n) ;
25
26    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', A, B, [ ]) ;
27    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', A, B, [ ]) ;
28    C3 = spones (M.matrix) .* (A.matrix .* B.matrix) ;
29    GB_spec_compare (C1, C2) ;
30    GB_spec_compare (C1, C3) ;
31
32    A2 = A ;
33    B2 = B ;
34
35    A2.matrix (:,1) = sprand (n, 1, 0.9) ;
36    A2.pattern = logical (A2.matrix) ;
37
38    B2.matrix (:,1) = sprand (n, 1, 0.01) ;
39    B2.matrix (1,1) = 3 ;
40    B2.pattern = logical (B2.matrix) ;
41
42    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', A2, B2, [ ]) ;
43    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', A2, B2, [ ]) ;
44    C3 = spones (M.matrix) .* (A2.matrix .* B2.matrix) ;
45    GB_spec_compare (C1, C2) ;
46    GB_spec_compare (C1, C3) ;
47
48    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', B2, A2, [ ]) ;
49    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', B2, A2, [ ]) ;
50    C3 = spones (M.matrix) .* (B2.matrix .* A2.matrix) ;
51    GB_spec_compare (C1, C2) ;
52    GB_spec_compare (C1, C3) ;
53
54fprintf ('test172: all tests passed\n') ;
55
56