1function testc8
2%TESTC8 test complex eWiseAdd and eWiseMult
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: Apache-2.0
6
7fprintf ('testc8: test complex eWiseAdd and eWiseMult\n') ;
8
9rng ('default')
10seed = 1 ;
11for m = [1 5 10 100]
12    for n = [1 5 10 100]
13
14        for trials = 1:100
15
16            A = GB_mex_random (m, n, 10*(m+n), 1, seed) ; seed = seed + 1 ;
17            B = GB_mex_random (m, n, 10*(m+n), 1, seed) ; seed = seed + 1 ;
18            S = GB_mex_complex (sparse (m,n)) ;
19
20            C1 = GB_mex_complex (A + B) ;
21            C2 = GB_mex_Matrix_eWiseAdd (S, [], [], 'plus', A, B, []) ;
22            assert (isequal (C1, C2.matrix)) ;
23
24            if (n == 1)
25                C2 = GB_mex_Vector_eWiseAdd (S, [], [], 'plus', A, B, []) ;
26                assert (isequal (C1, C2.matrix)) ;
27            end
28
29            C1 = GB_mex_complex (A .* B) ;
30            C2 = GB_mex_Matrix_eWiseMult (S, [], [], 'times', A, B, []) ;
31            % drop explicit zeros from C2.matrix:
32            assert (isequal (C1, 1*C2.matrix)) ;
33
34            if (n == 1)
35                C2 = GB_mex_Vector_eWiseMult (S, [], [], 'times', A, B, []) ;
36                assert (isequal (C1, 1*C2.matrix)) ;
37            end
38        end
39    end
40end
41
42fprintf ('testc8: all complex eWise tests passed\n') ;
43
44