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