num_elems

PURPOSE ^

NUM_ELEMS: number of elemnts in a (fwd or inv model or image)

SYNOPSIS ^

function num = num_elems( mdl );

DESCRIPTION ^

 NUM_ELEMS: number of elemnts in a (fwd or inv model or image)
 num_elems = num_elems( mdl );

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function num = num_elems( mdl );
0002 % NUM_ELEMS: number of elemnts in a (fwd or inv model or image)
0003 % num_elems = num_elems( mdl );
0004 
0005 % $Id: num_elems.m 5112 2015-06-14 13:00:41Z aadler $
0006 
0007 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0008 
0009 if ~isfield(mdl,'type') && isfield(mdl,'elems') % Set default for this case
0010    mdl.type = 'fwd_model';
0011 end
0012 
0013 switch mdl.type
0014   case 'image';      fmdl = mdl.fwd_model;
0015   case 'inv_model';  fmdl = mdl.fwd_model;
0016   case 'fwd_model';  fmdl = mdl;
0017   otherwise;
0018       error('can''t process model of type %s', mdl.type );
0019 end
0020 
0021 num = size(fmdl.elems,1);
0022 
0023 
0024 function do_unit_test
0025    mdl = mk_common_model('a2c2',8);
0026    ne = num_elems( mdl );
0027    unit_test_cmp('test1',ne, 64);
0028 
0029    ne = num_elems( mdl.fwd_model );
0030    unit_test_cmp('test2',ne, 64);
0031 
0032    ne = num_elems( mk_image( mdl ));
0033    unit_test_cmp('test3',ne, 64);
0034 
0035    mdl = mk_common_model('n3r2',[16,2]);
0036    ne = num_elems( mk_image( mdl ));
0037    unit_test_cmp('test4',ne, 828);

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005