R/mhalf.R

Defines functions mhalf

Documented in mhalf

#' Symmetric square root of a matrix
#' 
#' Computes the symmetric square root of a positive definite matrix
#' 
#' 
#' @usage mhalf(M)
#' @param M a positive definite matrix
#' @return a matrix \code{H} such that \code{H^2} equals \code{M}
#' @author Peter Hoff
#' @export mhalf
mhalf <-
function(M) 
{ 
  #symmetric square  root of a pos def matrix
  tmp<-eigen(M)
  tmp$vec%*%sqrt(diag(tmp$val,nrow=nrow(M)))%*%t(tmp$vec)
}

Try the amen package in your browser

Any scripts or data that you put into this service are public.

amen documentation built on Jan. 13, 2021, 9:17 p.m.