num_nodes

PURPOSE ^

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

SYNOPSIS ^

function num = num_nodes( mdl );

DESCRIPTION ^

 NUM_NODES: number of elemnts in a (fwd or inv model or image)
 n_nodes = num_nodes( mdl );

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function num = num_nodes( mdl );
0002 % NUM_NODES: number of elemnts in a (fwd or inv model or image)
0003 % n_nodes = num_nodes( mdl );
0004 
0005 % $Id: num_nodes.html 2819 2011-09-07 16:43:11Z aadler $
0006 
0007 if isstr(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0008 
0009 switch mdl.type
0010   case 'image';      fmdl = mdl.fwd_model;
0011   case 'inv_model';  fmdl = mdl.fwd_model;
0012   case 'fwd_model';  fmdl = mdl;
0013   otherwise;
0014       error('can''t process model of type %s', mdl.type );
0015 end
0016 
0017 num = size(fmdl.nodes,1);
0018 
0019 function do_unit_test
0020    mdl = mk_common_model('a2c2',8);
0021    ne = num_nodes( mdl );
0022    ok='fail'; if ne==41; ok='ok'; end; fprintf('test1: %10s\n',ok);
0023 
0024    ne = num_nodes( mdl.fwd_model );
0025    ok='fail'; if ne==41; ok='ok'; end; fprintf('test2: %10s\n',ok);
0026 
0027    ne = num_nodes( mk_image( mdl ));
0028    ok='fail'; if ne==41; ok='ok'; end; fprintf('test3: %10s\n',ok);
0029 
0030    mdl = mk_common_model('n3r2',16);
0031    ne = num_nodes( mk_image( mdl ));
0032    ok='fail'; if ne==252; ok='ok'; end; fprintf('test4: %10s\n',ok);

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005