swh:1:snp:1d6f9c912933e835b749aef1f8077112982fe84e
Tip revision: 85eeff77b2e878cc9dbd7659e4acbc035be93c28 authored by Hans W. Borchers on 22 September 2022, 13:50:02 UTC
version 2.4.2
version 2.4.2
Tip revision: 85eeff7
compan.Rd
\name{compan}
\alias{compan}
\title{Companion Matrix}
\description{
Computes the companion matrix of a real or complex vector.
}
\usage{
compan(p)
}
\arguments{
\item{p}{vector representing a polynomial}
}
\details{
Computes the companion matrix corresponding to the vector \code{p}
with \code{-p[2:length(p)]/p[1]} as first row.
The eigenvalues of this matrix are the roots of the polynomial.
}
\value{
A square matrix of \code{length(p)-1} rows and columns
}
\seealso{
\code{\link{roots}}
}
\examples{
p <- c(1, 0, -7, 6)
compan(p)
# 0 7 -6
# 1 0 0
# 0 1 0
}
\keyword{ array }