swh:1:snp:81eadaa089e8253d8469bcef66aa332632c6c669
Tip revision: f0ba8a5d88ce30d08c8312fd9b882f2ff051d91b authored by Hans W. Borchers on 25 August 2018, 21:00:11 UTC
version 2.1.5
version 2.1.5
Tip revision: f0ba8a5
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
}