annotate toolboxes/FullBNT-1.0.7/bnt/general/unroll_higher_order_topology.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 M = unroll_higher_order_topology(intra, inter, T, intra1)
Daniel@0 2 % UNROLL_DBN_TOPOLOGY Make the block diagonal adjacency matrix for a DBN consisting of T slices
Daniel@0 3 % M = unroll_dbn_topology(intra, inter, T, intra1)
Daniel@0 4 %
Daniel@0 5 % intra is the connectivity within a slice, inter between two slices.
Daniel@0 6 % M will have intra along the diagonal, and inter one above the diagonal.
Daniel@0 7 % intra1 is an optional argumnet, in case the intra is different for the first slice.
Daniel@0 8
Daniel@0 9 if nargin < 4
Daniel@0 10 intra1 = intra;
Daniel@0 11 end;
Daniel@0 12
Daniel@0 13
Daniel@0 14 ss = length(intra); % slice size
Daniel@0 15 M = sparse(ss*T, ss*T);
Daniel@0 16 [rows,columns,order] = size(inter);
Daniel@0 17 for t1 = 1:T
Daniel@0 18 b = 1 + (t1 - 1)*ss : t1*ss;
Daniel@0 19 if t1 == 1
Daniel@0 20 M(b,b) = intra1;
Daniel@0 21 else
Daniel@0 22 M(b,b) = intra;
Daniel@0 23 end
Daniel@0 24 for t2 = 1:order
Daniel@0 25 if t1 + t2 <= T
Daniel@0 26 M(b,b+t2*ss) = inter(:,:,t2);
Daniel@0 27 end
Daniel@0 28 end
Daniel@0 29 end
Daniel@0 30