wolffd@0: function K = tabular_kernel(fg, self) wolffd@0: % TABULAR_KERNEL Make a table-based local kernel (discrete potential) wolffd@0: % K = tabular_kernel(fg, self) wolffd@0: % wolffd@0: % fg is a factor graph wolffd@0: % self is the number of a representative domain wolffd@0: % wolffd@0: % Use 'set_params_kernel' to adjust the following fields wolffd@0: % table - a q[1]xq[2]x... array, where q[i] is the number of values for i'th node wolffd@0: % in this domain [default: random values from [0,1], which need not sum to 1] wolffd@0: wolffd@0: wolffd@0: if nargin==0 wolffd@0: % This occurs if we are trying to load an object from a file. wolffd@0: K = init_fields; wolffd@0: K = class(K, 'tabular_kernel'); wolffd@0: return; wolffd@0: elseif isa(fg, 'tabular_kernel') wolffd@0: % This might occur if we are copying an object. wolffd@0: K = fg; wolffd@0: return; wolffd@0: end wolffd@0: K = init_fields; wolffd@0: wolffd@0: ns = fg.node_sizes; wolffd@0: dom = fg.doms{self}; wolffd@0: % we don't store the actual domain since it may vary due to parameter tieing wolffd@0: K.sz = ns(dom); wolffd@0: K.table = myrand(K.sz); wolffd@0: wolffd@0: K = class(K, 'tabular_kernel'); wolffd@0: wolffd@0: wolffd@0: %%%%%%% wolffd@0: wolffd@0: wolffd@0: function K = init_fields() wolffd@0: % This ensures we define the fields in the same order wolffd@0: % no matter whether we load an object from a file, wolffd@0: % or create it from scratch. (Matlab requires this.) wolffd@0: wolffd@0: K.table = []; wolffd@0: K.sz = []; wolffd@0: wolffd@0: