wolffd@0: function K = tabular_kernel(sz, table) wolffd@0: % TABULAR_KERNEL Make a table-based local kernel (discrete potential) wolffd@0: % K = tabular_kernel(sz, table) wolffd@0: % wolffd@0: % sz(i) is the number of values the i'th member of this kernel can have wolffd@0: % table is an optional array of size sz[1] x sz[2] x... [default: random] 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(sz, 'tabular_kernel') wolffd@0: % This might occur if we are copying an object. wolffd@0: K = sz; wolffd@0: return; wolffd@0: end wolffd@0: K = init_fields; wolffd@0: wolffd@0: if nargin < 2, table = myrand(sz); end wolffd@0: wolffd@0: K.sz = sz; wolffd@0: K.table = table; 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.sz = []; wolffd@0: K.table = []; wolffd@0: wolffd@0: wolffd@0: