File: test172.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 (55 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (3)
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
function test172
%TEST172 eWiseMult with M bitmap/full

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

rng ('default') ;

fprintf ('test172:\n') ;

n = 500 ;

    A = GB_spec_random (n, n, 0.05, 1, 'double') ;
    A.sparsity = 2 ;    % sparse

    B = GB_spec_random (n, n, 0.05, 1, 'double') ;
    B.sparsity = 2 ;    % sparse

    M = GB_spec_random (n, n, 0.1, 1, 'double') ;
    M.matrix (1,1) = 1 ;
    M.pattern (1,1) = true ;
    M.sparsity = 4 ;    % bitmap

    Cin = sparse (n,n) ;

    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', A, B, [ ]) ;
    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', A, B, [ ]) ;
    C3 = spones (M.matrix) .* (A.matrix .* B.matrix) ;
    GB_spec_compare (C1, C2) ;
    GB_spec_compare (C1, C3) ;

    A2 = A ;
    B2 = B ;

    A2.matrix (:,1) = sprand (n, 1, 0.9) ;
    A2.pattern = logical (A2.matrix) ;

    B2.matrix (:,1) = sprand (n, 1, 0.01) ;
    B2.matrix (1,1) = 3 ;
    B2.pattern = logical (B2.matrix) ;

    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', A2, B2, [ ]) ;
    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', A2, B2, [ ]) ;
    C3 = spones (M.matrix) .* (A2.matrix .* B2.matrix) ;
    GB_spec_compare (C1, C2) ;
    GB_spec_compare (C1, C3) ;

    C1 = GB_spec_Matrix_eWiseMult (Cin, M, [ ], 'times', B2, A2, [ ]) ;
    C2 = GB_mex_Matrix_eWiseMult  (Cin, M, [ ], 'times', B2, A2, [ ]) ;
    C3 = spones (M.matrix) .* (B2.matrix .* A2.matrix) ;
    GB_spec_compare (C1, C2) ;
    GB_spec_compare (C1, C3) ;

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