*
* %CXLogDensity(cvsigma,cvx)
* Generalization of %LogDensity to complex matrices. cvsigma should be
* an Hermitian p.d. matrix. cvx is a complex vector with the same
* dimension as cvsigma. Returns the log density of a N(0,cvsigma) at cvx.
*
* This computes the frequency-by-frequency log likelihood. Use
* %CXLogDensityCV for the concentrated Whittle log likelihood.
*
function %CXLogDensity cvsigma cvx
type real %CXLogDensity
type cmatrix cvsigma
type cvector cvx
*
local vect[cmatrix] cxsvd
local integer n
local cvector ux
local real    logdet qform
*
compute n=%rows(cvsigma)
*
compute cxsvd=%cxsvd(cvsigma)
compute ux=%cxadj(cxsvd(1))*cvx
sstats 1 n log(%real(cxsvd(2)(t,1)))>>logdet $
   %cabs(ux(t))^2/%real(cxsvd(2)(t,1))>>qform
disp qform
disp %cxadj(cvx)*%cxinv(cvsigma)*cvx
compute %CXLogDensity=-.5*logdet-.5*qform-.5*n*log(2*%pi)
end

