summaryrefslogtreecommitdiff
path: root/numpy/polynomial/chebyshev.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/polynomial/chebyshev.py')
-rw-r--r--numpy/polynomial/chebyshev.py59
1 files changed, 52 insertions, 7 deletions
diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py
index 6a2394382..ec3fde2f8 100644
--- a/numpy/polynomial/chebyshev.py
+++ b/numpy/polynomial/chebyshev.py
@@ -87,11 +87,12 @@ References
"""
from __future__ import division, absolute_import, print_function
+import warnings
import numpy as np
import numpy.linalg as la
+
from . import polyutils as pu
-import warnings
-from .polytemplate import polytemplate
+from ._polybase import ABCPolyBase
__all__ = ['chebzero', 'chebone', 'chebx', 'chebdomain', 'chebline',
'chebadd', 'chebsub', 'chebmulx', 'chebmul', 'chebdiv', 'chebpow',
@@ -1646,10 +1647,15 @@ def chebfit(x, y, deg, rcond=None, full=False, w=None):
the coefficients for the data in column k of `y` are in column
`k`.
- [residuals, rank, singular_values, rcond] : present when `full` = True
- Residuals of the least-squares fit, the effective rank of the
- scaled Vandermonde matrix and its singular values, and the
- specified value of `rcond`. For more details, see `linalg.lstsq`.
+ [residuals, rank, singular_values, rcond] : list
+ These values are only returned if `full` = True
+
+ resid -- sum of squared residuals of the least squares fit
+ rank -- the numerical rank of the scaled Vandermonde matrix
+ sv -- singular values of the scaled Vandermonde matrix
+ rcond -- value of `rcond`.
+
+ For more details, see `linalg.lstsq`.
Warns
-----
@@ -2012,4 +2018,43 @@ def chebpts2(npts):
# Chebyshev series class
#
-exec(polytemplate.substitute(name='Chebyshev', nick='cheb', domain='[-1,1]'))
+class Chebyshev(ABCPolyBase):
+ """A Chebyshev series class.
+
+ The Chebyshev class provides the standard Python numerical methods
+ '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the
+ methods listed below.
+
+ Parameters
+ ----------
+ coef : array_like
+ Chebyshev coefficients in order of increasing degree, i.e.,
+ ``(1, 2, 3)`` gives ``1*T_0(x) + 2*T_1(x) + 3*T_2(x)``.
+ domain : (2,) array_like, optional
+ Domain to use. The interval ``[domain[0], domain[1]]`` is mapped
+ to the interval ``[window[0], window[1]]`` by shifting and scaling.
+ The default value is [-1, 1].
+ window : (2,) array_like, optional
+ Window, see `domain` for its use. The default value is [-1, 1].
+
+ .. versionadded:: 1.6.0
+
+ """
+ # Virtual Functions
+ _add = staticmethod(chebadd)
+ _sub = staticmethod(chebsub)
+ _mul = staticmethod(chebmul)
+ _div = staticmethod(chebdiv)
+ _pow = staticmethod(chebpow)
+ _val = staticmethod(chebval)
+ _int = staticmethod(chebint)
+ _der = staticmethod(chebder)
+ _fit = staticmethod(chebfit)
+ _line = staticmethod(chebline)
+ _roots = staticmethod(chebroots)
+ _fromroots = staticmethod(chebfromroots)
+
+ # Virtual properties
+ nickname = 'cheb'
+ domain = np.array(chebdomain)
+ window = np.array(chebdomain)