1function C = expand (scalar, S, type)
2%GRB.EXPAND expand a scalar into a matrix.
3% C = GrB.expand (scalar, S) expands the scalar into a matrix with the
4% same size and pattern as S, as C = scalar*spones(S).  C has the same
5% type as the scalar.  C = GrB.expand (scalar, S, type) allows the type of
6% C to be specified.  The numerical values of S are ignored; only the
7% pattern of S is used.
8%
9% Example:
10%   A = sprand (4, 4, 0.5)
11%   C1 = pi * spones (A)
12%   C2 = GrB.expand (pi, A)
13%   C3 = GrB.expand (pi, A, 'single complex')
14%
15% See also GrB.assign.
16
17% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
18% SPDX-License-Identifier: GPL-3.0-or-later
19
20if (isobject (scalar))
21    % do not use gb_get_scalar, to keep it sparse
22    scalar = scalar.opaque ;
23end
24
25if (~gb_isscalar (scalar))
26    error ('first input must be a scalar') ;
27end
28
29if (isobject (S))
30    S = S.opaque ;
31end
32
33if (nargin < 3)
34    type = gbtype (scalar) ;
35end
36
37C = GrB (gb_expand (scalar, S, type)) ;
38
39