1function gbtest27
2%GBTEST27 test conversion to full
3
4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
5% SPDX-License-Identifier: GPL-3.0-or-later
6
7types = gbtest_types ;
8
9rng ('default') ;
10for k1 = 1:length (types)
11
12    atype = types {k1} ;
13    A = 100 * sprand (3, 3, 0.5) ;
14    H = full (A, 'double', GrB (0)) ;
15    assert (norm (H-A,1) == 0)
16    B = A ;
17    B (A == 0) = 1 ; %#ok<*SPRIX>
18    H = full (A, 'double', GrB (1)) ;
19    assert (norm (H-B,1) == 0)
20
21    F = rand (3) ;
22    H = full (F, 'double', GrB (0)) ;
23    assert (norm (H-F,1) == 0)
24    assert (isa (H, 'GrB'))
25
26    H = GrB (A, atype) ;
27    G = full (H) ;
28    assert (GrB.entries (G) == prod (size (G))) ;
29
30    for k2 = 1:length (types)
31
32        gtype = types {k2} ;
33        G = full (H, gtype) ;
34        K = full (G, atype) ;
35        for id = [0 1 inf]
36            C = full (H, gtype, id) ; %#ok<*NASGU>
37        end
38
39        assert (GrB.entries (G) == prod (size (G))) ; %#ok<*PSIZE>
40    end
41end
42
43fprintf ('gbtest27: all tests passed\n') ;
44
45