Daniel@0: function K = tabular_kernel(sz, table) Daniel@0: % TABULAR_KERNEL Make a table-based local kernel (discrete potential) Daniel@0: % K = tabular_kernel(sz, table) Daniel@0: % Daniel@0: % sz(i) is the number of values the i'th member of this kernel can have Daniel@0: % table is an optional array of size sz[1] x sz[2] x... [default: random] Daniel@0: Daniel@0: if nargin==0 Daniel@0: % This occurs if we are trying to load an object from a file. Daniel@0: K = init_fields; Daniel@0: K = class(K, 'tabular_kernel'); Daniel@0: return; Daniel@0: elseif isa(sz, 'tabular_kernel') Daniel@0: % This might occur if we are copying an object. Daniel@0: K = sz; Daniel@0: return; Daniel@0: end Daniel@0: K = init_fields; Daniel@0: Daniel@0: if nargin < 2, table = myrand(sz); end Daniel@0: Daniel@0: K.sz = sz; Daniel@0: K.table = table; Daniel@0: Daniel@0: K = class(K, 'tabular_kernel'); Daniel@0: Daniel@0: Daniel@0: %%%%%%% Daniel@0: Daniel@0: Daniel@0: function K = init_fields() Daniel@0: % This ensures we define the fields in the same order Daniel@0: % no matter whether we load an object from a file, Daniel@0: % or create it from scratch. (Matlab requires this.) Daniel@0: Daniel@0: K.sz = []; Daniel@0: K.table = []; Daniel@0: Daniel@0: Daniel@0: