swh:1:snp:81eadaa089e8253d8469bcef66aa332632c6c669
Tip revision: 26e049d70b4a1c237987e260cba68f6a9413736c authored by Hans W. Borchers on 09 April 2019, 04:10:07 UTC
version 2.2.5
version 2.2.5
Tip revision: 26e049d
moler.R
##
## m o l e r . R
##
moler <- function(n) {
if (length(n) != 1 || n != round(n))
stop("Argument 'n' must be an integer.")
if (n <= 0) return(c())
A <- matrix(0, nrow = n, ncol = n)
for (i in 1:n) {
A[i, 1:i] <- (1:i) - 2
}
A <- A + t(A)
diag(A) <- 1:n
A
}