Daniel@0: function can = mpot_to_cpot(mom) Daniel@0: % MPOT_TO_CPOT Convert a moment potential to canonical form. Daniel@0: % mom = mpot_to_cpot(can) Daniel@0: Daniel@0: [g, h, K] = moment_to_canonical(mom.logp, mom.mu, mom.Sigma); Daniel@0: can = cpot(mom.domain, mom.sizes, g, h, K); Daniel@0: Daniel@0: %%%%%%%%%%% Daniel@0: Daniel@0: function [g, h, K] = moment_to_canonical(logp, mu, Sigma) Daniel@0: % MOMENT_TO_CANONICAL Convert moment characteristics to canonical form. Daniel@0: % [g, h, K] = moment_to_canonical(logp, mu, Sigma) Daniel@0: Daniel@0: K = inv(Sigma); Daniel@0: h = K*mu; Daniel@0: n = length(K); Daniel@0: if isempty(mu) Daniel@0: g = logp + 0.5*(log(det(K)) - n*log(2*pi)); Daniel@0: else Daniel@0: g = logp + 0.5*(log(det(K)) - n*log(2*pi) - mu'*K*mu); Daniel@0: end