Python wrapper around Fortran codes for special functions.
Project description
SPECial FUNCtions
This library provides a thin Python wrapper around the brilliant Fortran codes developed by Shanjie Zhang, Jianming Jin and John Burkardt.
The original Fortran 77 routines where developed by Shanjie Zhang and Jianming Jin:
Shanjie Zhang, Jianming Jin,
Computation of Special Functions,
Wiley, 1996,
ISBN: 0-471-11963-6,
LC: QA351.C45.
These were then adapted to Fortran 90 by John Burkardt and last modified in 30th of June 2012.
Minor adaptions to the original code were made to allow for interfacing with Python which is done through the pylib.f90
file.
This is a work in progress and currently I am just porting the routines as and when I need them.
Motivation
In essence, the special functions provided by Scipy based on C++ code was very unreliable for me and there were a number of open issues for problems I was encountering, so I started from the Fortran codes and made them into a Python library.
Functions
gammaln
:: $\log(\Gamma(x))$hyp1f1
:: $1F1(a, b, z)$hyp1f1ln
:: $\log(1F1(a, b, z))$
There are a lot of functions and subroutines available in the special_functions.f90
if there are any other functions that you'd like available raise in an issue.
Installation
Currently only Linux is supported, if you have the displeasure of using any other operating system then you will need to compile the special_functions.so
library manually.
If you have gfortran
installed then this can be done from running:
make lib
in the src/
directory.
Linux
Via poetry:
poetry add specfunc
or via PyPI:
pip install specfunc
Usage
specfuncs
is intended to work with numpy arrays and is currently in very early stages of development.
I have no intention in making significant changes but that cannot be guaranteed.
import numpy as np
import specfunc as sf
x = np.arange(0, 10).reshape(1, -1) + 1
lgx = sf.gammaln(x) # ln(Gamma(x))
a = np.array([1, 10, 10, 100, 12]).reshape(1, -1)
b = np.array([1, 1, 10, 10, 14]).reshape(1, -1)
z = np.array([1, 10, 10, 1, 0.4]).reshape(1, -1)
hgfv = hyp1f1(a, b, z) # Confluent hypergeometric function
lhgfv = hyp1f1ln(a, b, z) # Log of confluent hypergeometric function
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file specfunc-0.2.0.tar.gz
.
File metadata
- Download URL: specfunc-0.2.0.tar.gz
- Upload date:
- Size: 260.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.6.7-dist
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49dae0f7e4ef3173713f15a2e602f87528f0f2dbb163860259384e65f216b3e8 |
|
MD5 | 7f020c11364dcb4091969ee87cfb9c55 |
|
BLAKE2b-256 | 805e9326590b577ad765c714743577e2d9e9a9976cbfd58f284f2696386109c7 |
File details
Details for the file specfunc-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: specfunc-0.2.0-py3-none-any.whl
- Upload date:
- Size: 265.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Linux/6.6.7-dist
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03c474b963e94c9e563908fbd205457c10ad3b6c8eb79e08a66afbb734c01649 |
|
MD5 | f31f45b8ec3ccd177ca037a4fe6ee454 |
|
BLAKE2b-256 | a03e70974769affa9945e22fa6df59ba3762ad31e94a90892a971d7d919af529 |