You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: linear_gaussian_to_cpot.m
    path of file: ./repos/bnt/BNT/general
    
    the code of the file until where you have to start completion: function pot = linear_gaussian_to_cpot(mu, Sigma, W, domain, ns, cnodes, evidence)

    
function pot = linear_gaussian_to_cpot(mu, Sigma, W, domain, ns, cnodes, evidence)
% LINEAR_GAUSSIAN_TO_CPOT Convert a linear Gaussian CPD  to a canonical potential.
% pot = linear_gaussian_to_cpot(mu, Sigma, W, domain, ns, cnodes, evidence)
%
% We include any cts evidence, but ignore any discrete evidence.
% (Use gaussian_CPD_params_given_dps to use discrete evidence to select mu, Sigma, W.)

odom = domain(~isemptycell(evidence(domain)));
hdom = domain(isemptycell(evidence(domain)));
cobs = myintersect(cnodes, odom);
chid = myintersect(cnodes, hdom);
cvals = cat(1, evidence{cobs});

%[g,h,K] = gaussian_to_canonical(mu, Sigma, W);
Sinv = inv(Sigma);
g = -0.5*mu'*Sinv*mu + log(normal_coef(Sigma));
if isempty(W) | (size(W,2)==0)  % no cts parents
  h = Sinv*mu;
  K = Sinv;
else
  h = [-W'*Sinv*mu; Sinv*mu];
  K = [W'*Sinv*W  -W'*Sinv';
       -Sinv*W     Sinv]; 
end