bundles / scipy latest / scipy / linalg / _special_matrices / companion
function
scipy.linalg._special_matrices:companion
Signature
def companion ( a ) Summary
Create a companion matrix.
Extended Summary
Create the companion matrix [1] associated with the polynomial whose coefficients are given in a.
Array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details.
Parameters
a: (..., N) array_like1-D array of polynomial coefficients. The length of
amust be at least two, anda[0]must not be zero. M-dimensional arrays are treated as a batch: each slice along the last axis is a 1-D array of polynomial coefficients.
Returns
c: (..., N-1, N-1) ndarrayFor 1-D input, the first row of c is
-a[1:]/a[0], and the first sub-diagonal is all ones. The data-type of the array is the same as the data-type of1.0*a[0]. For batch input, each slice of shape(N-1, N-1)along the last two dimensions of the output corresponds with a slice of shape(N,)along the last dimension of the input.
Raises
: ValueErrorIf any of the following are true: a)
a.shape[-1] < 2; b)a[..., 0] == 0.
Notes
Examples
from scipy.linalg import companion companion([1, -10, 31, -30])✓
Aliases
-
scipy.linalg.companion