1function test145 2%TEST145 test dot4 3% GB_AxB_dot4 computes C+=A'*B when C is dense. 4 5% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 6% SPDX-License-Identifier: Apache-2.0 7 8fprintf ('test145 -------------------- C+=A''*B when C is dense, with dot4\n') ; 9 10rng ('default') ; 11 12A = sparse (rand (4)) ; 13B = sparse (rand (4)) ; 14C = sparse (rand (4)) ; 15AT = A' ; 16BT = B' ; 17 18semiring.add = 'plus' ; 19semiring.multiply = 'div' ; 20semiring.class = 'double' ; 21[mult_op add_op id] = GB_spec_semiring (semiring) ; 22 23dnn = struct ('axb', 'dot') ; 24dtn = struct ('axb', 'dot', 'inp0', 'tran') ; 25dnt = struct ('axb', 'dot', 'inp1', 'tran') ; 26dtt = struct ('axb', 'dot', 'inp0', 'tran', 'inp1', 'tran') ; 27 28C2 = GB_mex_mxm (C, [ ], add_op, semiring, A, B, dnn) ; 29C1 = GB_spec_mxm (C, [ ], add_op, semiring, A, B, dnn) ; 30GB_spec_compare (C1, C2) ; 31 32C2 = GB_mex_mxm (C, [ ], add_op, semiring, AT, B, dtn) ; 33C1 = GB_spec_mxm (C, [ ], add_op, semiring, AT, B, dtn) ; 34GB_spec_compare (C1, C2) ; 35 36C2 = GB_mex_mxm (C, [ ], add_op, semiring, A, BT, dnt) ; 37C1 = GB_spec_mxm (C, [ ], add_op, semiring, A, BT, dnt) ; 38GB_spec_compare (C1, C2) ; 39 40C2 = GB_mex_mxm (C, [ ], add_op, semiring, AT, BT, dtt) ; 41C1 = GB_spec_mxm (C, [ ], add_op, semiring, AT, BT, dtt) ; 42GB_spec_compare (C1, C2) ; 43 44X = 1./A ; 45C1 = X*B ; 46 47C2 = GB_mex_rdiv (A, B, 1003) ; 48assert (norm (C1-C2,1) < 1e-5) 49 50C2 = GB_mex_rdiv2 (A, B, false, false, 1003, 0) ; 51assert (norm (C1-C2,1) < 1e-5) 52 53C2 = GB_mex_rdiv2 (AT, B, true, false, 1003, 0) ; 54assert (norm (C1-C2,1) < 1e-5) 55 56C2 = GB_mex_rdiv2 (A, BT, false, true, 1003, 0) ; 57assert (norm (C1-C2,1) < 1e-5) 58 59C2 = GB_mex_rdiv2 (AT, BT, true, true, 1003, 0) ; 60assert (norm (C1-C2,1) < 1e-5) 61 62% update C in place with dot4: 63X = 1./B ; 64C1 = A*X + pi ; 65 66C2 = GB_mex_rdiv2 (A, B, false, false, 1003, 1, pi) ; 67assert (norm (C1-C2,1) < 1e-5) 68 69C2 = GB_mex_rdiv2 (AT, B, true, false, 1003, 1, pi) ; 70assert (norm (C1-C2,1) < 1e-5) 71 72C2 = GB_mex_rdiv2 (A, BT, false, true, 1003, 1, pi) ; 73assert (norm (C1-C2,1) < 1e-5) 74 75fprintf ('test145: all tests passed\n') ; 76