compan.RdComputes the companion matrix of a real or complex vector.
compan(p)Computes the companion matrix corresponding to the vector p
with -p[2:length(p)]/p[1] as first row.
The eigenvalues of this matrix are the roots of the polynomial.
A square matrix of length(p)-1 rows and columns
p <- c(1, 0, -7, 6)
compan(p)
#> [,1] [,2] [,3]
#> [1,] 0 7 -6
#> [2,] 1 0 0
#> [3,] 0 1 0
# 0 7 -6
# 1 0 0
# 0 1 0