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