wolffd@0: function M = unroll_dbn_topology(intra, inter, T, intra1) wolffd@0: % UNROLL_DBN_TOPOLOGY Make the block diagonal adjacency matrix for a DBN consisting of T slices wolffd@0: % M = unroll_dbn_topology(intra, inter, T, intra1) wolffd@0: % wolffd@0: % intra is the connectivity within a slice, inter between two slices. wolffd@0: % M will have intra along the diagonal, and inter one above the diagonal. wolffd@0: % intra1 is an optional argumnet, in case the intra is different for the first slice. wolffd@0: wolffd@0: if nargin < 4, intra1 = intra; end wolffd@0: wolffd@0: ss = length(intra); % slice size wolffd@0: M = sparse(ss*T, ss*T); wolffd@0: wolffd@0: b = 1:ss; wolffd@0: M(b,b) = intra1; wolffd@0: M(b,b+ss) = inter; wolffd@0: wolffd@0: for t=2:T-1 wolffd@0: b = (1:ss) + (t-1)*ss; wolffd@0: M(b,b) = intra; wolffd@0: M(b,b+ss) = inter; wolffd@0: end wolffd@0: wolffd@0: t = T; wolffd@0: b = (1:ss) + (t-1)*ss; wolffd@0: M(b,b) = intra; wolffd@0: wolffd@0: