R/sqrt.R

setMethod("sqrt", signature(x = "PosSemDefSymmMatrix"), function(x){
            er <- eigen(x)
            d <- sqrt(er$values)
            D <- if(length(d)==1) diag(1)*d else diag(d)
            return(PosSemDefSymmMatrix(er$vectors %*% D %*% t(er$vectors)))
})

Try the distr package in your browser

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

distr documentation built on May 31, 2023, 5:58 p.m.