1function test195 2%TEST195 test all variants of saxpy3 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7k = 3 ; 8n = 4 ; 9m = 200 ; 10desc.axb = 'hash' ; 11desc_s.axb = 'hash' ; desc_s.mask = 'structural' ; 12dnot.axb = 'hash' ; dnot.mask = 'complement' ; 13dnot_s.axb = 'hash' ; dnot_s.mask = 'structural complement' ; 14 15semiring.multiply = 'times' ; 16semiring.add = 'plus' ; 17semiring.class = 'double' ; 18 19for asparsity = [1 2 4 8] 20 fprintf ('\nA: %s ', GB_sparsity (asparsity)) ; 21 for bsparsity = [1 2 4 8] 22 fprintf ('\n B: %s ', GB_sparsity (bsparsity)) ; 23 for msparsity = [1 2 4 8] 24 fprintf ('\n M: %s ', GB_sparsity (msparsity)) ; 25 for da = [0.01 .1 inf] 26 A = GB_spec_random (m, k, da) ; A.sparsity = asparsity ; 27 for db = [0.01 .1 inf] 28 B = GB_spec_random (k, n, db) ; B.sparsity = bsparsity ; 29 for dm = [0.01 .1 inf] 30 fprintf ('.') ; 31 M = GB_spec_random (m, n, dm) ; M.sparsity = msparsity ; 32 M.matrix = spones (M.matrix) ; 33 C0 = sparse (n, n) ; 34 35 % C = A*B 36 C0 = A.matrix * B.matrix ; 37 C1 = GB_spec_mxm (C0, [ ], [ ], semiring, A, B, desc) ; 38 C2 = GB_mex_mxm (C0, [ ], [ ], semiring, A, B, desc) ; 39 GB_spec_compare (C1, C2, 0, 1e-12) ; 40 err = norm (C0 - C2.matrix, 1) ; 41 assert (err < 1e-12) ; 42 43 % C<M> = A*B 44 C0 = (A.matrix * B.matrix) .* M.matrix ; 45 C1 = GB_spec_mxm (C0, M, [ ], semiring, A, B, desc) ; 46 C2 = GB_mex_mxm (C0, M, [ ], semiring, A, B, desc) ; 47 GB_spec_compare (C1, C2, 0, 1e-12) ; 48 err = norm (C0 - C2.matrix, 1) ; 49 assert (err < 1e-12) ; 50 51 % C<!M> = A*B 52 C0 = (A.matrix * B.matrix) .* (1 - M.matrix) ; 53 C1 = GB_spec_mxm (C0, M, [ ], semiring, A, B, dnot) ; 54 C2 = GB_mex_mxm (C0, M, [ ], semiring, A, B, dnot) ; 55 GB_spec_compare (C1, C2, 0, 1e-12) ; 56 err = norm (C0 - C2.matrix, 1) ; 57 assert (err < 1e-12) ; 58 59 % C<M,struct> = A*B 60 C0 = (A.matrix * B.matrix) .* M.matrix ; 61 C1 = GB_spec_mxm (C0, M, [ ], semiring, A, B, desc_s) ; 62 C2 = GB_mex_mxm (C0, M, [ ], semiring, A, B, desc_s) ; 63 GB_spec_compare (C1, C2, 0, 1e-12) ; 64 err = norm (C0 - C2.matrix, 1) ; 65 assert (err < 1e-12) ; 66 67 % C<!M,struct> = A*B 68 C0 = (A.matrix * B.matrix) .* (1 - M.matrix) ; 69 C1 = GB_spec_mxm (C0, M, [ ], semiring, A, B, dnot_s) ; 70 C2 = GB_mex_mxm (C0, M, [ ], semiring, A, B, dnot_s) ; 71 GB_spec_compare (C1, C2, 0, 1e-12) ; 72 err = norm (C0 - C2.matrix, 1) ; 73 assert (err < 1e-12) ; 74 75 end 76 end 77 end 78 end 79 end 80end 81 82fprintf ('\ntest195: all tests passed\n') ; 83