1function A = GB_spec_random (m, n, d, scale, type, is_csc,is_hyper,hyper_switch)
2%GB_SPEC_RANDOM generate random matrix
3%
4% A = GB_spec_random (m, n, d, scale, type, is_csc, is_hyper, hyper_switch)
5%
6% m,n,d: parameters to sprandn (m,n,d)
7% m,n: defaults to 4
8% d: defaults to 0.5.  If d = inf, A is fully populated.
9% scale: a double scalar, defaults to 1.0
10% type: a string; defaults to 'double'
11% is_csc: true for CSC, false for CSR; defaults to true
12% is_hyper: false for non-hypersparse, true for hypersparse, default false
13
14% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
15% SPDX-License-Identifier: Apache-2.0
16
17if (nargin < 1)
18    m = 4 ;
19end
20
21if (nargin < 2)
22    n = 4 ;
23end
24
25if (nargin < 3)
26    d = 0.5 ;
27end
28
29if (nargin < 4)
30    scale = 1 ;
31end
32
33if (nargin < 5)
34    type = 'double' ;
35end
36
37if (nargin >= 6)
38    A.is_csc = is_csc ;
39end
40
41if (nargin >= 7 && ~isempty (is_hyper))
42    A.is_hyper = is_hyper ;
43end
44
45if (nargin >= 8)
46    A.hyper_switch = hyper_switch ;
47end
48
49if (isinf (d))
50    A.matrix = scale * sparse (rand (m, n)) ;
51else
52    A.matrix = scale * sprandn (m, n, d) ;
53end
54
55if (contains (type, 'complex'))
56    if (isinf (d))
57        A.matrix = A.matrix + 1i * scale * sparse (rand (m, n)) ;
58    else
59        A.matrix = A.matrix + 1i * scale * sprandn (m, n, d) ;
60    end
61end
62
63A.class = type ;
64A.pattern = logical (spones (A.matrix)) ;
65
66