wolffd@0: function engine = set_params(engine, varargin) wolffd@0: % SET_PARAMS Set the parameters (fields) for a belprop_inf_engine object wolffd@0: % engine = set_params(engine, name/value pairs) wolffd@0: % wolffd@0: % The following optional arguments can be specified in the form of name/value pairs: wolffd@0: % e.g., engine = set_params(engine, 'tol', 1e-2, 'max_iter', 10) wolffd@0: % wolffd@0: % max_iter - max. num. loopy iterations wolffd@0: % momentum - weight assigned to old message in convex combination wolffd@0: % tol - tolerance used to assess convergence wolffd@0: % maximize - 1 means use max-product, 0 means use sum-product wolffd@0: wolffd@0: args = varargin{1}; wolffd@0: nargs = length(args); wolffd@0: for i=1:2:nargs wolffd@0: switch args{i}, wolffd@0: case 'max_iter', engine.max_iter = args{i+1}; wolffd@0: case 'momentum', engine.momentum = args{i+1}; wolffd@0: case 'tol', engine.tol = args{i+1}; wolffd@0: case 'maximize', engine.maximize = args{i+1}; wolffd@0: otherwise, wolffd@0: error(['invalid argument name ' args{i}]); wolffd@0: end wolffd@0: end