1function test112 2%TEST112 test row/col scale 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7fprintf ('test112: row/col scale\n') ; 8 9rng ('default') ; 10 11n = 2000 ; 12 13 D = spdiags (rand (n,1), 0, n, n) ; 14 A = sprand (n, n, 0.1) ; 15 B = sprand (n, n, 0.1) ; 16 p = randperm (n) ; 17 P = D (p,:) ; 18 19 % both diag 20 fprintf ('\nboth diag:\n') ; 21 C1 = D*D ; 22 C2 = GB_mex_AxB (D, D) ; 23 assert (norm (C1-C2,1) < 1e-14) ; 24 25 % row scale 26 fprintf ('\nA is diag:\n') ; 27 C1 = D*B ; 28 C2 = GB_mex_AxB (D, B) ; 29 assert (norm (C1-C2,1) < 1e-14) ; 30 31 % col scale 32 fprintf ('\nB is diag:\n') ; 33 C1 = A*D ; 34 C2 = GB_mex_AxB (A, D) ; 35 assert (norm (C1-C2,1) < 1e-14) ; 36 37 % regular 38 fprintf ('\nneither diag:\n') ; 39 C1 = A*B ; 40 C2 = GB_mex_AxB (A, B) ; 41 assert (norm (C1-C2,1) < 1e-14) ; 42 43 % permute 44 fprintf ('\ncol permutation:\n') ; 45 C1 = A*P ; 46 C2 = GB_mex_AxB (A, P) ; 47 assert (norm (C1-C2,1) < 1e-14) ; 48 49 % permute 50 fprintf ('\nrow permutation:\n') ; 51 C1 = P*B ; 52 C2 = GB_mex_AxB (P, B) ; 53 assert (norm (C1-C2,1) < 1e-14) ; 54 55fprintf ('test112: all tests passed\n') ; 56