Learn R Programming

gremlin (version 1.0.1)

tr: Matrix trace methods.

Description

Methods to efficiently calculate a matrix trace depending on the class of matrix.

Usage

tr(X, ...)

# S3 method for default tr(X, ...)

# S3 method for dgCMatrix tr(X, ...)

# S3 method for dsCMatrix tr(X, ...)

Arguments

X

A matrix.

Additional arguments.

Value

A numeric value for the sum of the diagonal elements.

Methods (by class)

  • default: Default method

  • dgCMatrix: Method for matrix X of class Matrix:::dgCMatrix

  • dsCMatrix: Method for matrix X of class Matrix:::dsCMatrix