1function C = sprand (arg1, arg2, arg3)
2%SPRAND sparse uniformly distributed random matrix.
3% C = sprand (A) is a matrix with the same pattern as A, but with
4%   uniformly distributed random entries.  This usage is identical to
5%   C = GrB.random (A).
6%
7% C = sprand (m,n,d) is a random m-by-n matrix with about m*n*d uniformly
8%   distributed values.  If d == inf, C is a full matrix. To use this
9%   function instead of the built-in sprand, use C = sprand (m,n,GrB(d)),
10%   for example, or C = GrB.random (m,n,d).
11%
12% For additional options, see GrB.random.
13% The rc parameter for C = sprand (m,n,d,rc) is not supported.
14% The entries in C will greater than zero and less than one.
15% C is returned as a double GraphBLAS matrix.
16%
17% See also GrB/sprandn, GrB/sprandsym, GrB.random.
18
19% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
20% SPDX-License-Identifier: GPL-3.0-or-later
21
22if (nargin == 1)
23    % C = sprand (G)
24    G = arg1.opaque ;
25    C = GrB (gb_random (G)) ;
26elseif (nargin == 3)
27    % C = sprand (m, n, d)
28    m = gb_get_scalar (arg1) ;
29    n = gb_get_scalar (arg2) ;
30    d = gb_get_scalar (arg3) ;
31    C = GrB (gb_random (m, n, d)) ;
32else
33    % the 'rc' input option is not supported
34    error ('usage: sprand(A) or sprand(m,n,d)') ;
35end
36
37