function [trans_mat, trans_cov, obs_mat, obs_cov, init_state, init_cov] = dbn_to_lds(bnet)
% Compute the Linear Dynamical System parameters from the Gaussian DBN.
% [trans_mat, trans_cov, obs_mat, obs_cov, init_state, init_cov] = dbn_to_lds(bnet)

%[trans_mat, trans_cov, obs_mat, obs_cov, init_state, init_cov] = can_dbn_to_lds(bnet);
%return;

assert(canonical_dbn(bnet.intra, bnet.inter, bnet.observed_slice));

num_nodes = bnet.slice_size*2;  % just extract params from first 2 slices
[W,D,mu] = extract_params_from_gbn(bnet, num_nodes);

hidden_nodes = bnet.hidden_slice;
obs_nodes = bnet.observed_slice;
bs = bnet.blocks(1:num_nodes);
ss = bnet.slice_size;

obs_mat = W(block(hidden_nodes,bs), block(obs_nodes,bs))';
u = block(obs_nodes,bs);
obs_cov = D(u,u);
trans_mat = W(block(hidden_nodes,bs), block(hidden_nodes + ss, bs))';
u = block(hidden_nodes + ss, bs);
trans_cov = D(u,u);

u = block(hidden_nodes,bs);
init_cov = D(u,u);
init_state = mu(u);

