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: spm_kl_wishart.m
    path of file: ./repos/malini/Codes/deconvolution - model/spm8
    
    the code of the file until where you have to start completion: function [kl] = spm_kl_wishart (q,Q,p,P)

    
function [kl] = spm_kl_wishart (q,Q,p,P)
% KL divergence between two Wishart densities
% FORMAT [kl] = spm_kl_wishart (q,Q,p,P)
%
% Calculate KL (Q||P) = <log Q/P> where avg is wrt Q
% between two Wishart densities Q and P
%
% q,Q      Parameters of first density
% p,P      Parameters of first density
%___________________________________________________________________________
% Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging

% Will Penny 
% $Id: spm_kl_wishart.m 1276 2008-03-28 18:29:19Z guillaume $

logdetQ=log(det(Q));
logdetP=log(det(P));

% Get dimension 
d=size(Q,1);

LqQ=0;
for i=1:d,
  LqQ=LqQ+psi((q+1-i)/2);
end