Mercurial > hg > camir-ismir2012
comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/HHMM/mk_hhmm_topo.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc4b1211e677 |
---|---|
1 function [intra, inter, Qnodes, Fnodes, Onode] = mk_hhmm_topo(D, all_Q_to_Qs, Ops, F1) | |
2 % MK_HHMM_TOPO Make Hierarchical HMM topology | |
3 % function [intra, inter, Qnodes, Fnodes, Onode] = mk_hhmm_topo(D, all_Q_to_Qs, Ops, F1) | |
4 % | |
5 % D is the depth of the hierarchy | |
6 % If all_Q_to_Qs = 1, level i connects to all levels below, else just to i+1 [0] | |
7 % Ops are the Q parents of the observed node [Qnodes(end)] | |
8 % If F1=1, level 1 can finish (restart), else there is no F1->Q1 arc [0] | |
9 | |
10 Qnodes = 1:D; | |
11 | |
12 if nargin < 2, all_Q_to_Qs = 1; end | |
13 if nargin < 3, Ops = Qnodes(D); end | |
14 if nargin < 4, F1 = 0; end | |
15 | |
16 if F1 | |
17 Fnodes = 2*D:-1:D+1; % must number from bottom to top | |
18 Onode = 2*D+1; | |
19 ss = 2*D+1; | |
20 else | |
21 Fnodes = [-1 (2*D)-1:-1:D+1]; % Fnodes(1) is a dummy index | |
22 Onode = 2*D; | |
23 ss = 2*D; | |
24 end | |
25 | |
26 intra = zeros(ss); | |
27 intra(Ops, Onode) = 1; | |
28 for d=1:D-1 | |
29 if all_Q_to_Qs | |
30 intra(Qnodes(d), Qnodes(d+1:end)) = 1; | |
31 else | |
32 intra(Qnodes(d), Qnodes(d+1)) = 1; | |
33 end | |
34 end | |
35 for d=D:-1:3 | |
36 intra(Fnodes(d), Fnodes(d-1)) = 1; | |
37 end | |
38 if F1 | |
39 intra(Fnodes(2), Fnodes(1)) = 1; | |
40 end | |
41 if all_Q_to_Qs | |
42 if F1 | |
43 intra(Qnodes(1), Fnodes(1:end)) = 1; | |
44 else | |
45 intra(Qnodes(1), Fnodes(2:end)) = 1; | |
46 end | |
47 for d=2:D | |
48 intra(Qnodes(d), Fnodes(d:end)) = 1; | |
49 end | |
50 else | |
51 if F1 | |
52 intra(Qnodes(1), Fnodes([1 2])) = 1; | |
53 else | |
54 intra(Qnodes(1), Fnodes(2)) = 1; | |
55 end | |
56 for d=2:D-1 | |
57 intra(Qnodes(d), Fnodes([d d+1])) = 1; | |
58 end | |
59 intra(Qnodes(D), Fnodes(D)) = 1; | |
60 end | |
61 | |
62 | |
63 inter = zeros(ss); | |
64 for d=1:D | |
65 inter(Qnodes(d), Qnodes(d)) = 1; | |
66 end | |
67 if F1 | |
68 inter(Fnodes(1), Qnodes(1)) = 1; | |
69 end | |
70 for d=2:D | |
71 inter(Fnodes(d), Qnodes([d-1 d])) = 1; | |
72 end | |
73 | |
74 if ~F1 | |
75 Fnodes = Fnodes(2:end); % strip off dummy -1 term | |
76 end |