0001 function num = num_elems( mdl );
0002
0003
0004
0005
0006
0007 if isstr(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 ok='fail'; if ne==64; ok='ok'; end; fprintf('test1: %10s\n',ok);
0028
0029 ne = num_elems( mdl.fwd_model );
0030 ok='fail'; if ne==64; ok='ok'; end; fprintf('test2: %10s\n',ok);
0031
0032 ne = num_elems( mk_image( mdl ));
0033 ok='fail'; if ne==64; ok='ok'; end; fprintf('test3: %10s\n',ok);
0034
0035 mdl = mk_common_model('n3r2',16);
0036 ne = num_elems( mk_image( mdl ));
0037 ok='fail'; if ne==828; ok='ok'; end; fprintf('test4: %10s\n',ok);