function compile_lw(bnet)
% COMPILE_LW Compile a C version of likelihood weighting specific to bnet
% compile_lw(bnet) generates the files mylw.h and C_lw.mex in the directory BNT/bnet
% All subsequent calls to lw will use the parameters of this particular model.

assert(~bnet.is_dbn);
fprintf('compiling lw...\n');
tic
global BNTroot
cd([BNTroot 'bnet']);
nnodes = length(bnet.adj_mat);
!rm mylw.h
fid = fopen([BNTroot 'bnet/mylw.h'], 'w');
generate_mylw_C(bnet, fid, nnodes);
fclose(fid);
!mex C_lw.c
toc
