Learn R Programming

sfsmisc (version 1.1-19)

diagX: The “Other” Diagonal Matrix

Description

Compute the other diagonal identity matrix. The result is basically a fast version of diag(n)[, n:1].

Usage

diagX(n)

Value

a numeric \(n \times n\) matrix with many zeros -- apart from

1s in the other diagonal.

Arguments

n

positive integer.

Author

Martin Maechler, 1992.

See Also

Examples

Run this code
diagX(4)
for(m in 1:5)
  stopifnot(identical(diagX(m), diag(m)[, m:1, drop = FALSE]))

Run the code above in your browser using DataLab