1function gbtest62 2%GBTEST62 test ldivide, rdivide, mldivide, mrdivide 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: GPL-3.0-or-later 6 7rng ('default') ; 8 9n = 10 ; 10for trial = 1:40 11 12 fprintf ('.') ; 13 14 A = 100 * rand (n) ; 15 B = 100 * rand (n) ; 16 b = rand (n, 1) ; 17 18 r = rand ; 19 s = GrB (r) ; 20 21 GA = GrB (A) ; 22 GB = GrB (B) ; 23 24 C0 = A ./ r ; 25 C1 = GA ./ s ; 26 assert (isequal (C0, C1)) ; 27 28 C0 = A / r ; 29 C1 = GA / s ; 30 assert (isequal (C0, C1)) ; 31 32 C0 = A ./ 0 ; 33 C1 = GA ./ 0 ; 34 assert (isequal (C0, C1)) ; 35 36 C0 = A / 0 ; 37 C1 = GA / 0 ; 38 assert (isequal (C0, C1)) ; 39 40 C0 = 0 .\ A ; 41 C1 = 0 .\ GA ; 42 assert (isequal (C0, C1)) ; 43 44 C0 = 0 \ A ; 45 C1 = 0 \ GA ; 46 assert (isequal (C0, C1)) ; 47 48 C0 = 2 ./ r ; 49 C1 = GrB (2) ./ s ; 50 assert (isequal (C0, C1)) ; 51 52 C0 = 2 ./ A ; 53 C1 = 2 ./ GA ; 54 assert (isequal (C0, C1)) ; 55 56 C0 = 2 .\ r ; 57 C1 = GrB (2) .\ s ; 58 assert (isequal (C0, C1)) ; 59 60 C0 = 2 \ r ; 61 C1 = GrB (2) \ s ; 62 assert (isequal (C0, C1)) ; 63 64 C0 = A ./ B ; 65 C1 = GA ./ GB ; 66 assert (isequal (C0, C1)) ; 67 68 C0 = A .\ B ; 69 C1 = GA .\ GB ; 70 assert (isequal (C0, C1)) ; 71 72 x = A \ b ; 73 y = GA \ b ; 74 assert (norm (x - y) < 1e-12) ; 75 76 x = b' / A ; 77 y = b' / GA ; 78 assert (norm (x - y) < 1e-12) ; 79 80 A = sprand (n, n, 0.5) ; 81 B = rand * A ; 82 GA = GrB (A) ; 83 GB = GrB (B) ; 84 85 C0 = A ./ B ; 86 C1 = GA ./ GB ; 87 assert (isequal (GrB.prune (C0, nan), GrB.prune (C1, nan))) ; 88 89 C0 = A .\ B ; 90 C1 = GA .\ GB ; 91 assert (isequal (GrB.prune (C0, nan), GrB.prune (C1, nan))) ; 92 93end 94 95fprintf ('\ngbtest62: all tests passed\n') ; 96 97