diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-06-20 16:49:49 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-06-20 17:31:35 -0600 |
commit | 12e06a261e8ea6b08002de8e9933fd43e5465df9 (patch) | |
tree | 527a2df97d58a190de018b4a917f3be06908f541 /numpy/polynomial/polynomial.py | |
parent | b3755926f5e5dc9fde273a8bf53bd98238e8e2b8 (diff) | |
download | numpy-12e06a261e8ea6b08002de8e9933fd43e5465df9.tar.gz |
BUG: Campanion Matrix was scalar, not matrix for degree 1.
The companion matrices returned by the various polynomial types was
a scalar in the degree one case instead of a 2-D array. Fix that and
add a test to check for that result.
Closes #3459.
Diffstat (limited to 'numpy/polynomial/polynomial.py')
-rw-r--r-- | numpy/polynomial/polynomial.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index 7a0b36cde..0b044e8e8 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -39,6 +39,7 @@ Misc Functions - `polyvander` -- Vandermonde-like matrix for powers. - `polyvander2d` -- Vandermonde-like matrix for 2D power series. - `polyvander3d` -- Vandermonde-like matrix for 3D power series. +- `polycompanion` -- companion matrix in power series form. - `polyfit` -- least-squares fit returning a polynomial. - `polytrim` -- trim leading coefficients from a polynomial. - `polyline` -- polynomial representing given straight line. @@ -1417,7 +1418,7 @@ def polycompanion(c): if len(c) < 2 : raise ValueError('Series must have maximum degree of at least 1.') if len(c) == 2: - return np.array(-c[0]/c[1]) + return np.array([[-c[0]/c[1]]]) n = len(c) - 1 mat = np.zeros((n, n), dtype=c.dtype) |