1function [C_replace Mask_comp Atrans Btrans Mask_struct descriptor] = ...
2    GB_spec_descriptor (descriptor)
3%GB_SPEC_DESCRIPTOR return components of a descriptor
4%
5% Returns the components of the descriptor struct.  Defaults are used if not
6% present, or if the descriptor itself is empty.
7%
8% desc fields:
9%
10% outp:  'default' or 'replace'
11% mask:  'default', 'complement', 'structural', or 'structural complement'
12% inp0:  'default' or 'tran'
13% inp1:  'default' or 'tran'
14
15% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
16% SPDX-License-Identifier: Apache-2.0
17
18if (isempty (descriptor))
19    descriptor = struct ;
20end
21
22if (~isfield (descriptor, 'outp'))
23    % use 'replace' to clear C before writing to it on output via the mask.
24    % See GB_spec_mask.m for details.
25    descriptor.outp = 'default' ;
26end
27if (~isfield (descriptor, 'mask'))
28    % default is to use Mask, not ~Mask if 'complement'
29    descriptor.mask = 'default' ;
30end
31if (~isfield (descriptor, 'inp0'))
32    % default is to use A, or A' if 'tran'
33    descriptor.inp0 = 'default' ;
34end
35if (~isfield (descriptor, 'inp1'))
36    % default is to use B, or B' if 'tran'
37    descriptor.inp1 = 'default' ;
38end
39
40C_replace = isequal (descriptor.outp, 'replace') ;
41Atrans    = isequal (descriptor.inp0, 'tran') ;
42Btrans    = isequal (descriptor.inp1, 'tran') ;
43
44switch (descriptor.mask)
45    case {'complement'}
46        Mask_comp = true ;
47        Mask_struct = false ;
48    case {'structural'}
49        Mask_comp = false ;
50        Mask_struct = true ;
51    case {'structural complement'}
52        Mask_comp = true ;
53        Mask_struct = true ;
54    otherwise
55        Mask_comp = false ;
56        Mask_struct = false ;
57    end
58end
59
60
61