diriDensity <- function(p = 3, parms = c(2,2,2), 
					pts = c(1/3, 1/3, 1/3), log = F)
{
	#this is the normalized spectral density of Coles and Tawn
	#this is NOT the standard dirichlet density--that can be
	#found in diriStdDensity program
	#this meets the center of mass condition
	
	#this evaluates the spectral measure of the n-dimensional 
	#max-stable dirichlet model as described by Kotz and Nadarajah
	
    #assumes pts is in S3 and converts it to be a matrix if 
    #it is just a vector
    if(is.vector(pts))
    {
    	pts <- t(pts)
    }	
    	
	parmsSum <- sum(parms)
	parmsMtx <- matrix(rep(parms, dim(pts)[1]), byrow = T, 
						ncol = length(parms)) 
	parmsPts <- parmsMtx * pts

	first  <- lgamma(parmsSum + 1) - (p+1)*
					log(apply(parmsPts, 1, sum))
	second <- sum(log(parms) - lgamma(parms))
	third <- apply((parmsMtx - 1)*(log(parmsPts) - 
				log(apply(parmsPts, 1, sum))), 1, sum)

	combine <- -3/2*log(p)+ first + second + third
	if(log)
	{return(combine)}
	else
	return(exp(combine))
}