Skip to main content

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

Metadata

Release files for specfunc 0.2.0

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

Source distribution (sdist)

Source distribution for specfunc 0.2.0
File Size Uploaded Provenance Actions
specfunc-0.2.0.tar.gz 260.9 kB Without provenance Details for specfunc-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for specfunc 0.2.0
File Interpreter ABI Platform Actions
specfunc-0.2.0-py3-none-any.whl Python 3 none any Details for specfunc-0.2.0-py3-none-any.whl

Total release size: 526.6 kB

Release files / specfunc-0.2.0.tar.gz

Download URL specfunc-0.2.0.tar.gz
Size 260.9 kB
Tags Source
SHA-256 checksum
How to use checksums
49dae0f7e4ef3173713f15a2e602f87528f0f2dbb163860259384e65f216b3e8
BLAKE2b-256 checksum
How to use checksums
805e9326590b577ad765c714743577e2d9e9a9976cbfd58f284f2696386109c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Linux/6.6.7-dist

Release files / specfunc-0.2.0-py3-none-any.whl

Download URL specfunc-0.2.0-py3-none-any.whl
Size 265.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03c474b963e94c9e563908fbd205457c10ad3b6c8eb79e08a66afbb734c01649
BLAKE2b-256 checksum
How to use checksums
a03e70974769affa9945e22fa6df59ba3762ad31e94a90892a971d7d919af529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Linux/6.6.7-dist

Security for specfunc 0.2.0

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

0.2.0 This release

2 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