swh:1:snp:81eadaa089e8253d8469bcef66aa332632c6c669
Tip revision: fdf16693b000f3e309c56091892c61f0ec9fd670 authored by Hans W. Borchers on 21 November 2017, 16:15:00 UTC
version 2.1.1
version 2.1.1
Tip revision: fdf1669
trace.R
##
## t r a c e . R Matrix trace
##
Trace <- function(a) {
if (length(a) <= 1) return(a)
if ((!is.numeric(a) && !is.complex(a)) || !is.matrix(a))
stop("Argument 'a' must be a real or complex matrix.")
if (nrow(a) != ncol(a))
stop("Matrix 'a' must be square.")
return(sum(diag(a)))
}