annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_kernel/tabular_kernel.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function K = tabular_kernel(sz, table)
wolffd@0 2 % TABULAR_KERNEL Make a table-based local kernel (discrete potential)
wolffd@0 3 % K = tabular_kernel(sz, table)
wolffd@0 4 %
wolffd@0 5 % sz(i) is the number of values the i'th member of this kernel can have
wolffd@0 6 % table is an optional array of size sz[1] x sz[2] x... [default: random]
wolffd@0 7
wolffd@0 8 if nargin==0
wolffd@0 9 % This occurs if we are trying to load an object from a file.
wolffd@0 10 K = init_fields;
wolffd@0 11 K = class(K, 'tabular_kernel');
wolffd@0 12 return;
wolffd@0 13 elseif isa(sz, 'tabular_kernel')
wolffd@0 14 % This might occur if we are copying an object.
wolffd@0 15 K = sz;
wolffd@0 16 return;
wolffd@0 17 end
wolffd@0 18 K = init_fields;
wolffd@0 19
wolffd@0 20 if nargin < 2, table = myrand(sz); end
wolffd@0 21
wolffd@0 22 K.sz = sz;
wolffd@0 23 K.table = table;
wolffd@0 24
wolffd@0 25 K = class(K, 'tabular_kernel');
wolffd@0 26
wolffd@0 27
wolffd@0 28 %%%%%%%
wolffd@0 29
wolffd@0 30
wolffd@0 31 function K = init_fields()
wolffd@0 32 % This ensures we define the fields in the same order
wolffd@0 33 % no matter whether we load an object from a file,
wolffd@0 34 % or create it from scratch. (Matlab requires this.)
wolffd@0 35
wolffd@0 36 K.sz = [];
wolffd@0 37 K.table = [];
wolffd@0 38
wolffd@0 39
wolffd@0 40