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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function K = tabular_kernel(fg, self)
Daniel@0 2 % TABULAR_KERNEL Make a table-based local kernel (discrete potential)
Daniel@0 3 % K = tabular_kernel(fg, self)
Daniel@0 4 %
Daniel@0 5 % fg is a factor graph
Daniel@0 6 % self is the number of a representative domain
Daniel@0 7 %
Daniel@0 8 % Use 'set_params_kernel' to adjust the following fields
Daniel@0 9 % table - a q[1]xq[2]x... array, where q[i] is the number of values for i'th node
Daniel@0 10 % in this domain [default: random values from [0,1], which need not sum to 1]
Daniel@0 11
Daniel@0 12
Daniel@0 13 if nargin==0
Daniel@0 14 % This occurs if we are trying to load an object from a file.
Daniel@0 15 K = init_fields;
Daniel@0 16 K = class(K, 'tabular_kernel');
Daniel@0 17 return;
Daniel@0 18 elseif isa(fg, 'tabular_kernel')
Daniel@0 19 % This might occur if we are copying an object.
Daniel@0 20 K = fg;
Daniel@0 21 return;
Daniel@0 22 end
Daniel@0 23 K = init_fields;
Daniel@0 24
Daniel@0 25 ns = fg.node_sizes;
Daniel@0 26 dom = fg.doms{self};
Daniel@0 27 % we don't store the actual domain since it may vary due to parameter tieing
Daniel@0 28 K.sz = ns(dom);
Daniel@0 29 K.table = myrand(K.sz);
Daniel@0 30
Daniel@0 31 K = class(K, 'tabular_kernel');
Daniel@0 32
Daniel@0 33
Daniel@0 34 %%%%%%%
Daniel@0 35
Daniel@0 36
Daniel@0 37 function K = init_fields()
Daniel@0 38 % This ensures we define the fields in the same order
Daniel@0 39 % no matter whether we load an object from a file,
Daniel@0 40 % or create it from scratch. (Matlab requires this.)
Daniel@0 41
Daniel@0 42 K.table = [];
Daniel@0 43 K.sz = [];
Daniel@0 44
Daniel@0 45