summaryrefslogtreecommitdiff
path: root/numpy/polynomial/chebyshev.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-08-15 21:06:27 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-08-15 21:06:27 +0000
commit3ade0a810b185383e97428e8c6365da1951de436 (patch)
tree78b0cf0900368372c62ca395bd098888743a9fcf /numpy/polynomial/chebyshev.py
parent0a0248000491b40e03f29a98055a7546316cc92f (diff)
downloadnumpy-3ade0a810b185383e97428e8c6365da1951de436.tar.gz
Merge branch 'poly'
Diffstat (limited to 'numpy/polynomial/chebyshev.py')
-rw-r--r--numpy/polynomial/chebyshev.py67
1 files changed, 66 insertions, 1 deletions
diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py
index 61d7c7f68..23f8a728f 100644
--- a/numpy/polynomial/chebyshev.py
+++ b/numpy/polynomial/chebyshev.py
@@ -36,6 +36,8 @@ Misc Functions
- `chebroots` -- find the roots of a Chebyshev series.
- `chebvander` -- Vandermonde-like matrix for Chebyshev polynomials.
- `chebfit` -- least-squares fit returning a Chebyshev series.
+- `chebpts1` -- Chebyshev points of the first kind.
+- `chebpts2` -- Chebyshev points of the second kind.
- `chebtrim` -- trim leading coefficients from a Chebyshev series.
- `chebline` -- Chebyshev series of given straight line.
- `cheb2poly` -- convert a Chebyshev series to a polynomial.
@@ -78,7 +80,8 @@ from __future__ import division
__all__ = ['chebzero', 'chebone', 'chebx', 'chebdomain', 'chebline',
'chebadd', 'chebsub', 'chebmulx', 'chebmul', 'chebdiv', 'chebval',
'chebder', 'chebint', 'cheb2poly', 'poly2cheb', 'chebfromroots',
- 'chebvander', 'chebfit', 'chebtrim', 'chebroots', 'Chebyshev']
+ 'chebvander', 'chebfit', 'chebtrim', 'chebroots', 'chebpts1',
+ 'chebpts2', 'Chebyshev']
import numpy as np
import numpy.linalg as la
@@ -1332,6 +1335,68 @@ def chebroots(cs):
return roots
+def chebpts1(npts):
+ """Chebyshev points of the first kind.
+
+ Chebyshev points of the first kind are the set ``{cos(x_k)}``,
+ where ``x_k = pi*(k + .5)/npts`` for k in ``range(npts}``.
+
+ Parameters
+ ----------
+ npts: int
+ Number of sample points desired.
+
+ Returns
+ -------
+ pts: ndarray
+ The Chebyshev points of the second kind.
+
+ Notes
+ -----
+ .. versionadded:: 1.5.0
+
+ """
+ _npts = int(npts)
+ if _npts != npts:
+ raise ValueError("npts must be integer")
+ if _npts < 1:
+ raise ValueError("npts must be >= 1")
+
+ x = np.linspace(-np.pi, 0, _npts, endpoint=False) + np.pi/(2*_npts)
+ return np.cos(x)
+
+
+def chebpts2(npts):
+ """Chebyshev points of the second kind.
+
+ Chebyshev points of the second kind are the set ``{cos(x_k)}``,
+ where ``x_k = pi*/(npts - 1)`` for k in ``range(npts}``.
+
+ Parameters
+ ----------
+ npts: int
+ Number of sample points desired.
+
+ Returns
+ -------
+ pts: ndarray
+ The Chebyshev points of the second kind.
+
+ Notes
+ -----
+ .. versionadded:: 1.5.0
+
+ """
+ _npts = int(npts)
+ if _npts != npts:
+ raise ValueError("npts must be integer")
+ if _npts < 2:
+ raise ValueError("npts must be >= 2")
+
+ x = np.linspace(-np.pi, 0, _npts)
+ return np.cos(x)
+
+
#
# Chebyshev series class
#