swh:1:snp:81eadaa089e8253d8469bcef66aa332632c6c669
Tip revision: fdf16693b000f3e309c56091892c61f0ec9fd670 authored by Hans W. Borchers on 21 November 2017, 16:15:00 UTC
version 2.1.1
version 2.1.1
Tip revision: fdf1669
poly.R
###
### p o l y . R Polynom
###
Poly <- function(x) {
if (is.null(x) || length(x) == 0) return(c(1))
if (is.vector(x, mode="numeric") || is.vector(x, mode="complex")) {
y <- x
} else {
if ((is.numeric(x) || is.complex(x)) && is.matrix(x)) {
y <- eigen(x)$values
} else {
stop("Argument 'x' must be a vector or square matrix.")
}
}
n <- length(y)
p <- c(1, rep(0, n))
for (i in 1:n) {
p[2:(i+1)] <- p[2:(i+1)] - y[i] * p[1:i]
}
if (all(Im(p) == 0)) p <- Re(p)
return(p)
}