Tools for working with Chebyshev expansion
Project description
ChebTools
Chebyshev-basis expansions, and more broadly, orthogonal polynomial expansions, are commonly used as numerical approximations of continuous functions on closed domains. One of the most successful projects that makes use of the Chebyshev expansions is the chebfun
library for MATLAB. Other similar libraries are pychebfun, chebpy, and Approxfun. Our library ChebTools
fills a similar niche as that of chebfun
-- working with Chebyshev expansions.
The primary motivation for the development of ChebTools
is the need for a highly optimized and fast C++11 library for working with Chebyshev expansions. Particularly, in order to approximate numerical functions with well-behaved interpolation functions.
Automatic tests on github actions:
Paper about ChebTools in JOSS:
Example:
Suppose we wanted to calculate the roots and extrema of the 0-th Bessel function in [0, 30]. That results in a picture like this:
For which the Python code would read
import scipy.special
import ChebTools
# Only keep the roots that are in [-1,1] in scaled coordinates
only_in_domain = True
# The 0-th Bessel function (for code concision)
def J0(x): return scipy.special.jn(0,x)
# Make a 200-th order expansion of the 0-th Bessel function in [0,30]
f = ChebTools.generate_Chebyshev_expansion(200, J0, 0, 30)
# Roots of the function
rts = f.real_roots(only_in_domain)
# Extrema of the function (roots of the derivative, where dy/dx =0)
extrema = f.deriv(1).real_roots(only_in_domain)
Changelog
- 1.1: Added
integrate
function for indefinite integral - 1.2: Added some more operators, including division and unary negation
- 1.3: Added
is_monotonic
function to ascertain whether the nodes are monotonically increasing or decreasing - 1.4: Added dyadic splitting into intervals (C++ only for now)
- 1.5: Added FFT-based function for getting expansion coefficient values from nodal values
- 1.7: Added
ChebyshevCollection
container class for fast evaluation of collection of expansions (generated from dyadic splitting maybe?) - 1.8: Added
__version__
attribute - 1.9: Added the ability to construct inverse functions
- 1.10: Added 2D evaluation functions in
double
andcomplex<double>
options (useful for model optimization with complex step derivatives) - 1.10.1: Repaired universal2 binary wheels on Mac
- 1.11: Exposed
get_coef
function for Taylor series extrapolator - 1.12.0: Switched interface for python to nanobind. Dropped pypy wheels.
License
*MIT licensed (see LICENSE for specifics), not subject to copyright in the USA.
Uses unmodified Eigen for matrix operations
Contributing/Getting Help
If you would like to contribute to ChebTools
or report a problem, please open a pull request or submit an issue. Especially welcome would be additional tests.
Installation
Prerequisites
You will need:
- cmake (on windows, install from cmake, on linux
sudo apt install cmake
should do it, on OSX,brew install cmake
) - Python (the anaconda distribution is used by the authors)
- a compiler (on windows, Visual Studio 2015+ (express version is fine), g++ on linux/OSX)
If on linux you use Anaconda and end up with an error like
ImportError: /home/theuser/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/theuser/anaconda3/lib/python3.5/site-packages/ChebTools.cpython-35m-x86_64-linux-gnu.so)
it can be sometimes fixed by installing libgcc
with conda: conda install libgcc
. This is due to an issue in Anaconda
To install in one line from github (easiest)
This will download the sources into a temporary directory and build and install the python extension so long as you have the necessary prerequisites:
pip install git+git://github.com/usnistgov/ChebTools.git
From a cloned repository
Alternatively, you can clone (recursively!) and run the setup.py
script
git clone --recursive --shallow-submodules https://github.com/usnistgov/ChebTools
cd ChebTools
python setup.py install
to install, or
python setup.py develop
to use a locally-compiled version for testing. If you want to build a debug version, you can do so with
python setup.py build -g develop
With a debug build, you can step into the debugger to debug the C++ code, for instance.
Cmake build
Starting in the root of the repo (a debug build with the default compiler, here on linux):
git clone --recursive --shallow-submodules https://github.com/usnistgov/ChebTools
cd ChebTools
mkdir build
cd build
cmake ..
cmake --build .
For those using Anaconda on Linux, please use the following for cmake:
mkdir build
cd build
cmake .. -DPYTHON_EXECUTABLE=`which python`
cmake --build .
For Visual Studio 2015 (64-bit) in release mode, you would do:
git clone --recursive --shallow-submodules https://github.com/usnistgov/ChebTools
cd ChebTools
mkdir build
cd build
cmake .. -G "Visual Studio 14 2015 Win64"
cmake --build . --config Release
If you need to update your submodules (pybind11 and friends)
git submodule update --init
For other options, see the cmake docs.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file chebtools-1.13.0.tar.gz
.
File metadata
- Download URL: chebtools-1.13.0.tar.gz
- Upload date:
- Size: 6.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b57b2e5a463e89e182123eb3977f2a8ddb5564ba162c28d5da342ccd67a3b37 |
|
MD5 | f39eba38fa5087c142f01aecd9fb6f80 |
|
BLAKE2b-256 | 04872146b4be6f84b860d349221270327b1093a9bab1cf71986e2d836dc729e4 |
File details
Details for the file chebtools-1.13.0-cp312-abi3-win_amd64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 168.6 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 930a98e4e0ad3ea67bc17bb22a56d103072c7fcbeffe699fa7958fa6b61d28b6 |
|
MD5 | 6010e7e162269f8e67d51e277dc9cf3b |
|
BLAKE2b-256 | 3cdc0f712b491a1fc683ca63f8d3898d99f1433dc49d85d97636ad23d539a96e |
File details
Details for the file chebtools-1.13.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 183.3 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2288cf485849bc97e88461c7eecf63b4f046c253e7786fa9573dce7df6dbb7da |
|
MD5 | c13a7952e4b7e96e9324187bc846d5d5 |
|
BLAKE2b-256 | 74534dd1ec74a731086305098d5775a92c5fb351883ca7b0aea47a5d852bc205 |
File details
Details for the file chebtools-1.13.0-cp312-abi3-macosx_10_15_universal2.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp312-abi3-macosx_10_15_universal2.whl
- Upload date:
- Size: 293.1 kB
- Tags: CPython 3.12+, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a70686105500860c677fee551713ab11cbf131133e89d885c6c58f286ed96d5c |
|
MD5 | d3a474f706865b284b5cc15392dea298 |
|
BLAKE2b-256 | 552a25177f873e175495c79f2657d1cbd9c2fa15f945af94f1b036c1cde30f26 |
File details
Details for the file chebtools-1.13.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 169.2 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd1d2729f1d970952a5012cb5dfe28f68e3977245fd11e03632182cbbd085efa |
|
MD5 | 038a4d22eebca0407d038495f4a20ec5 |
|
BLAKE2b-256 | ec8782da323a23b0570f7e8f072061f14fafae087a4052ba8f6622cd94087d59 |
File details
Details for the file chebtools-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 184.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee2685ca0984195e62a2a3486f4f906306ba4e529162e3dba7057eeec76506b0 |
|
MD5 | 924531b98b44e4478b9d96b8f5238328 |
|
BLAKE2b-256 | 5bd4148ced534e74d45a50c30fd11da838314d9deade878a2564816c32f21aed |
File details
Details for the file chebtools-1.13.0-cp311-cp311-macosx_10_15_universal2.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp311-cp311-macosx_10_15_universal2.whl
- Upload date:
- Size: 294.4 kB
- Tags: CPython 3.11, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f56232e52b78ec8674ca6f8ad7fe2bd33f588fbd2e220a8f4e10175f9a0b4d9 |
|
MD5 | 8a36eb5c24e9502271da71a2d73d6adc |
|
BLAKE2b-256 | 789e0cc8b6d613815186a651bb2e9928450a1ea6b210c8417ac4d34ef0688f44 |
File details
Details for the file chebtools-1.13.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 169.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3b5438fa60650d82b7784f5c313c2f856db4fbe8cf837712d7bfa6e2192c126 |
|
MD5 | 39344278d4e9dbf6ed08f361433e1187 |
|
BLAKE2b-256 | aae376983b17d49e5c113e9aed26360a1914f36fe15d491246380caf03f5f5e6 |
File details
Details for the file chebtools-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 184.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdf2f8a5398e5c2404095647cd1113e15efa75a8753ea4681c0c0fc987baf58d |
|
MD5 | adc7019bd5b98b20236c433aa986dff1 |
|
BLAKE2b-256 | b3c8d1276c0b9065c0dcfcbffc28a1d4bf53102a3c3f61939dabb011ace8d119 |
File details
Details for the file chebtools-1.13.0-cp310-cp310-macosx_10_15_universal2.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp310-cp310-macosx_10_15_universal2.whl
- Upload date:
- Size: 294.8 kB
- Tags: CPython 3.10, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd43d97722a851155521e3ee5c091dea3f723ca5e4d919d2abba96a36cdc029a |
|
MD5 | 5a04ad2728fc2794c0ad9ee376097772 |
|
BLAKE2b-256 | 229f3270c3b477645b286e0dcefa4b82f1ec574bdf917b2c82ed158a3f305bc3 |
File details
Details for the file chebtools-1.13.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 169.7 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad5f421dcbc91ec16a6e0685c346ec923c9c779609686812b40b36798dbee93f |
|
MD5 | 9558605c85b69f92c650bd5a43ffd2a1 |
|
BLAKE2b-256 | 2bd5baddafbddd901840265cb207ebcc57d0decdb9fb7959722475f465944e18 |
File details
Details for the file chebtools-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 184.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4c7af313f7266889d75c7a115262b3683422583bfb8ceba06c1623abd9941a4 |
|
MD5 | a08e2984786790440fbf68e85f6c4a0f |
|
BLAKE2b-256 | 9c2adde2a259846fac3ed294be203e71bf1d775f8cad8e3114781cd58af4a425 |
File details
Details for the file chebtools-1.13.0-cp39-cp39-macosx_10_15_universal2.whl
.
File metadata
- Download URL: chebtools-1.13.0-cp39-cp39-macosx_10_15_universal2.whl
- Upload date:
- Size: 295.2 kB
- Tags: CPython 3.9, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 156a0c837cf655713cb1fdf9588ccab11161b3ef9dad0a008e85492449c88070 |
|
MD5 | 18f391572645f903dbf28cd7c94c395f |
|
BLAKE2b-256 | b2d8520e17e8bc9ce5c5db5bc1cf5fb5a62186e03e95d17b3f7c5281fb5972fd |