Daniel@0: function M = unroll_higher_order_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 Daniel@0: intra1 = intra; Daniel@0: end; Daniel@0: Daniel@0: Daniel@0: ss = length(intra); % slice size Daniel@0: M = sparse(ss*T, ss*T); Daniel@0: [rows,columns,order] = size(inter); Daniel@0: for t1 = 1:T Daniel@0: b = 1 + (t1 - 1)*ss : t1*ss; Daniel@0: if t1 == 1 Daniel@0: M(b,b) = intra1; Daniel@0: else Daniel@0: M(b,b) = intra; Daniel@0: end Daniel@0: for t2 = 1:order Daniel@0: if t1 + t2 <= T Daniel@0: M(b,b+t2*ss) = inter(:,:,t2); Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: