R/matrix.trace.R

Defines functions matrix.trace

Documented in matrix.trace

matrix.trace <- function( x )
{
###
### this function returns the trace of the given square matrix
###
### parameters
### x = a numeric square matrix object
###
    if ( !is.square.matrix( x ) )
        stop( "argument x is not a square matrix" )
    return( sum( diag( x ) ) )
}

Try the matrixcalc package in your browser

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

matrixcalc documentation built on Sept. 15, 2022, 1:05 a.m.