annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@tabular_kernel/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(sz, table)
Daniel@0 2 % TABULAR_KERNEL Make a table-based local kernel (discrete potential)
Daniel@0 3 % K = tabular_kernel(sz, table)
Daniel@0 4 %
Daniel@0 5 % sz(i) is the number of values the i'th member of this kernel can have
Daniel@0 6 % table is an optional array of size sz[1] x sz[2] x... [default: random]
Daniel@0 7
Daniel@0 8 if nargin==0
Daniel@0 9 % This occurs if we are trying to load an object from a file.
Daniel@0 10 K = init_fields;
Daniel@0 11 K = class(K, 'tabular_kernel');
Daniel@0 12 return;
Daniel@0 13 elseif isa(sz, 'tabular_kernel')
Daniel@0 14 % This might occur if we are copying an object.
Daniel@0 15 K = sz;
Daniel@0 16 return;
Daniel@0 17 end
Daniel@0 18 K = init_fields;
Daniel@0 19
Daniel@0 20 if nargin < 2, table = myrand(sz); end
Daniel@0 21
Daniel@0 22 K.sz = sz;
Daniel@0 23 K.table = table;
Daniel@0 24
Daniel@0 25 K = class(K, 'tabular_kernel');
Daniel@0 26
Daniel@0 27
Daniel@0 28 %%%%%%%
Daniel@0 29
Daniel@0 30
Daniel@0 31 function K = init_fields()
Daniel@0 32 % This ensures we define the fields in the same order
Daniel@0 33 % no matter whether we load an object from a file,
Daniel@0 34 % or create it from scratch. (Matlab requires this.)
Daniel@0 35
Daniel@0 36 K.sz = [];
Daniel@0 37 K.table = [];
Daniel@0 38
Daniel@0 39
Daniel@0 40