Skip to main content

libcalculus: A comprehensive real and complex analysis library for Python

pipeline status

libcalculus is fully written in C++ and Cython for bindings to Python; all numeric calculations take place in C++ and take full advantage of SIMD vectorization and OpenMP threading wherever available.

Features

  • Functional programming approach to analysis in Python
  • Numeric integration and differentiation of real and complex functions
  • Full integration with NumPy: functions support array inputs
  • LaTeX support: every function object has a .latex() that produces its LaTeX markup

Technology

libcalculus is written in C++20 and bound to Python via Cython; operations between functions are performed using C++ lambdas, and all calculations happen at the C++ level, with Python only interfacing methods and results.

Installation

libcalculus can be installed from pip:

pip install libcalculus

Examples

Here is a snippet demonstrating some of the library's features:

>>> import libcalculus, numpy as np
>>> f = libcalculus.csc @ (1 / libcalculus.identity) # csc(1 / z)
>>> f(1 + 2j)
(1.0316491868272164+1.9336686363989997j)
>>> libcalculus.residue(f, 0, tol=1e-4)
(0.16666666639893526-8.181230860681676e-06j)

>>> print(f.latex("z"))
\csc\left( \frac{1}{z}\right)

>>> contour = libcalculus.line(2, 1 + 1j) # 2(1 - t) + (1 + 1i)t
>>> libcalculus.integrate(f, contour, 0, 1) # integrate along the contour between t=0 and t=1
(-2.0551412843830605+1.1351565349386723j)

>>> libcalculus.threads(4) # Enable threading
>>> arr = np.array([[1, 2j, 3], [4 + 1j, 5 + 2j, 7 + 3j]])
>>> print(f(arr))
[[ 1.18839511+0.j         -0.        +1.91903475j  3.05628425+0.j        ]
 [ 4.03942207+0.99000843j  5.02878731+1.98839211j  7.02013025+2.99133798j]]

Source Build

Building from source can be beneficial when looking to tailor optimizations to one's specific CPU architecture or so as to modify source code privately. This can be done easily with the proper required libraries - Boost, Cython and NumPy.

Linux

A convenient driver script for compilation with different options, testing etc. is available on Linux.

$ git clone https://gitlab.com/ariter777/libcalculus && cd libcalculus
$ ./run.sh --debug build test # Run with -h (or without any flags) for help

Extra compiler and linker flags can be provided with the CXXFLAGS and LDFLAGS environment variables.

Windows

On Windows you will need to run the individual scripts separately; setup.py for building, and test.py for testing.

> git clone https://gitlab.com/ariter777/libcalculus && cd libcalculus
> python setup.py build_ext --inplace
> python test.py --Function --RealFunction --Contour --ComplexFunction

License

Copyright (c) 2022, Ariel Terkeltoub All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
   copyright notice, this list of conditions and the following
   disclaimer in the documentation and/or other materials provided
   with the distribution.

* Neither the name of the libcalculus developers nor the names of any
   contributors may be used to endorse or promote products derived
   from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

Metadata

Release files for libcalculus 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libcalculus 1.0.2
File Size Uploaded Provenance Actions
libcalculus-1.0.2.tar.gz 289.2 kB Without provenance Details for libcalculus-1.0.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for libcalculus 1.0.2
File Interpreter ABI Platform Actions
libcalculus-1.0.2-cp38-cp38-manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for libcalculus-1.0.2-cp38-cp38-manylinux2014_x86_64.whl
libcalculus-1.0.2-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details for libcalculus-1.0.2-cp37-cp37m-win_amd64.whl

Total release size: 4.5 MB

Release files / libcalculus-1.0.2.tar.gz

Download URL libcalculus-1.0.2.tar.gz
Size 289.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee5eb8f77956efe34c1a84b92031bb3910ef22f6872fd707f7de3468755c8e2a
BLAKE2b-256 checksum
How to use checksums
27960fee2c9b5eaa3d553b94d5eb3a3bfffa7728310714e2ffd4d9fa07e4fd1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.46.1 importlib-metadata/4.11.2 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Release files / libcalculus-1.0.2-cp38-cp38-manylinux2014_x86_64.whl

Download URL libcalculus-1.0.2-cp38-cp38-manylinux2014_x86_64.whl
Size 3.9 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1f82a3ec64006c92a588f8aa77ce9761ded2763bb5f17c2c1b82facf34c732f3
BLAKE2b-256 checksum
How to use checksums
6f8b37ef02a116a07da0cdc436430967ead374b56bf0cf0bb90a497371d3126c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.46.1 importlib-metadata/4.11.2 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Release files / libcalculus-1.0.2-cp37-cp37m-win_amd64.whl

Download URL libcalculus-1.0.2-cp37-cp37m-win_amd64.whl
Size 351.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a0d1e505c30164efb73a15b101d06429c80a1c62576adf923cd235f4a658c7b8
BLAKE2b-256 checksum
How to use checksums
d56494f9b8b0ec1d6dbd1660ef599769bd7dbb18604011e56c37dee74fe7299f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.59.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.4

Security for libcalculus 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

3 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page