0001 function num = num_elems( mdl );
0002
0003
0004
0005
0006
0007 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0008
0009 if ~isfield(mdl,'type') && isfield(mdl,'elems')
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);