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