Special operators vs mathematical special functions

Algorithms layer — fractional Laplacian, fractional Fourier / Z / Mellin transforms (hpfracc.algorithms.fractional_operator_methods; legacy path special_methods).

Mathematical special functions — Γ, β, binomials, Mittag–Leffler (hpfracc.special).

Fractional operator extensions

Fractional operator extensions (Laplacian, FrFT, Z/Mellin transforms).

This is the algorithms-layer complement to hpfracc.special (Γ, β, binomial, Mittag–Leffler). It implements operators used in PDEs and signal processing:

  • Fractional Laplacian

  • Fractional Fourier / Z / Mellin transforms

Canonical import: from hpfracc.algorithms.fractional_operator_methods import .... The legacy path hpfracc.algorithms.special_methods remains a thin re-export shim.

hpfracc.algorithms.fractional_operator_methods._numpy_trapezoid(y, x)[source]

Trapezoidal rule; prefers numpy.trapezoid (NumPy 2+) over deprecated trapz.

hpfracc.algorithms.fractional_operator_methods._factorial(n)

Simple factorial function for NUMBA compatibility.

Parameters:

n (int)

Return type:

int

class hpfracc.algorithms.fractional_operator_methods.FractionalLaplacian(alpha, *, dimension=1, boundary_conditions=None)[source]

Bases: object

Fractional Laplacian operator implementation.

The fractional Laplacian is defined as: \((-\Delta)^{\alpha/2} f(x) = \mathcal{F}^{-1}\left(|\xi|^{\alpha}\, \mathcal{F}[f](\xi)\right)\)

This is a fundamental operator in fractional PDEs, diffusion processes, and many physical applications.

Parameters:
__init__(alpha, *, dimension=1, boundary_conditions=None)[source]

Initialize fractional Laplacian calculator.

Parameters:
  • order – Fractional order (0 < α < 2)

  • dimension (int) – Spatial dimension

  • boundary_conditions (str | None) – Boundary condition type

  • alpha (float | FractionalOrder)

compute(f, x, h=None, method='spectral')[source]

Compute fractional Laplacian.

Parameters:
  • f (Callable | ndarray) – Function or array of function values

  • x (float | ndarray) – Domain points

  • h (float | None) – Step size (if not provided, inferred from x)

  • method (str) – Computation method (“spectral”, “finite_difference”, “integral”)

Returns:

Fractional Laplacian values

Return type:

float | ndarray

_spectral_method(f, x, h)[source]

Spectral method using FFT.

Parameters:
Return type:

ndarray

_finite_difference_method(f, x, h)[source]

Finite difference approximation.

Parameters:
Return type:

ndarray

compute_numerical(f, x, h=None)[source]

Numerical convenience API used by tests.

Uses finite-difference approximation under the hood.

Parameters:
Return type:

ndarray

_integral_method(f, x, h)[source]

Integral representation method.

Parameters:
Return type:

ndarray

_grunwald_coefficients(N)[source]

Compute Grünwald-Letnikov coefficients.

Parameters:

N (int)

Return type:

ndarray

class hpfracc.algorithms.fractional_operator_methods.FractionalFourierTransform(alpha, *, method='spectral')[source]

Bases: object

Fractional Fourier Transform (FrFT) implementation.

The fractional Fourier transform is a generalization of the Fourier transform that depends on a parameter α. For α = π/2, it reduces to the standard Fourier transform.

FrFT[f](u) = ∫_{-∞}^∞ K_α(x, u) f(x) dx

where K_α is the fractional Fourier kernel.

Parameters:
__init__(alpha, *, method='spectral')[source]

Initialize fractional Fourier transform calculator.

Parameters:
transform(f, x, h=None, method='auto')[source]

Compute fractional Fourier transform.

Parameters:
  • f (Callable | ndarray) – Function or array of function values

  • x (float | ndarray) – Domain points

  • h (float | None) – Step size

  • method (str) – Computation method (“auto”, “discrete”, “spectral”, “fast”)

Returns:

Tuple of (u_domain, transformed_values)

Return type:

Tuple[ndarray, ndarray]

compute(f, x, h=None, method='auto')[source]

Compatibility wrapper returning only transformed values.

Some call sites expect a compute(…) API that returns the transformed values array directly. This method delegates to transform(…) and returns only the values component.

Parameters:
Return type:

ndarray

_discrete_method(f, x, h)[source]

Discrete fractional Fourier transform using optimized FFT-based approach.

Parameters:
Return type:

Tuple[ndarray, ndarray]

_fft_based_method(f, x, u, h)[source]

Fast FFT-based fractional Fourier transform.

Parameters:
Return type:

Tuple[ndarray, ndarray]

_chirp_based_method(f, x, u, h)[source]

Chirp-based algorithm for fractional Fourier transform.

Parameters:
Return type:

Tuple[ndarray, ndarray]

_spectral_method(f, x, h)[source]

Spectral method using decomposition.

Parameters:
Return type:

Tuple[ndarray, ndarray]

compute_numerical(f, x, h=None)[source]

Numerical convenience API returning only values.

Maps to the discrete method for accuracy.

Parameters:
Return type:

ndarray

_compute_transform_matrix(x, u, h)[source]

Compute the discrete fractional Fourier transform matrix.

Parameters:
Return type:

ndarray

_hermite_decomposition(f, x, h)[source]

Decompose function into Hermite-Gaussian basis.

Parameters:
Return type:

ndarray

_hermite_function(n, x)[source]

Compute Hermite-Gaussian function of order n.

Parameters:
Return type:

ndarray

_fractional_hermite(n, u, alpha)[source]

Compute fractional Fourier transform of Hermite function.

Parameters:
Return type:

ndarray

_fast_approximation(f, x, h)[source]

Fast approximation using interpolation between standard FFT and identity.

Parameters:
Return type:

Tuple[ndarray, ndarray]

class hpfracc.algorithms.fractional_operator_methods.FractionalZTransform(alpha, *, method='spectral')[source]

Bases: object

Fractional Z-Transform implementation.

The fractional Z-transform is a generalization of the Z-transform that depends on a fractional parameter α. It’s useful for discrete-time systems and digital signal processing.

Z^α[f](z) = Σ_{n=0}^∞ f[n] z^(-αn)

Parameters:
__init__(alpha, *, method='spectral')[source]

Initialize fractional Z-transform calculator.

Parameters:
transform(f, z, method='direct')[source]

Compute fractional Z-transform.

Parameters:
  • f (ndarray) – Discrete signal array

  • z (complex | ndarray) – Complex variable(s) for evaluation

  • method (str) – Computation method (“direct”, “fft”)

Returns:

Transform values

Return type:

complex | ndarray

_direct_method(f, z)[source]

Direct computation of fractional Z-transform.

Parameters:
Return type:

complex | ndarray

_fft_method(f, z)[source]

FFT-based computation for unit circle evaluation.

Parameters:
Return type:

complex | ndarray

inverse_transform(F, z, N, method='contour')[source]

Compute inverse fractional Z-transform.

Parameters:
  • F (complex | ndarray) – Transform values

  • z (complex | ndarray) – Complex variable(s)

  • N (int) – Length of output signal

  • method (str) – Inversion method (“contour”, “residue”)

Returns:

Original signal

Return type:

ndarray

_contour_integration(F, z, N)[source]

Contour integration method for inverse transform.

Parameters:
Return type:

ndarray

_residue_method(F, z, N)[source]

Residue method for inverse transform.

Parameters:
Return type:

ndarray

class hpfracc.algorithms.fractional_operator_methods.FractionalMellinTransform(alpha)[source]

Bases: object

Fractional Mellin Transform implementation.

The fractional Mellin transform is defined as: M_α[f](s) = ∫₀^∞ f(x) x^(s-1+α) dx

This transform is useful for: - Scale-invariant signal processing - Fractional differential equations - Image processing and pattern recognition - Quantum mechanics applications

Parameters:

alpha (float | FractionalOrder)

__init__(alpha)[source]

Initialize fractional Mellin transform calculator.

Parameters:

alpha (float | FractionalOrder)

transform(f, x, s, method='numerical')[source]

Compute fractional Mellin transform.

Parameters:
  • f (Callable | ndarray) – Function or array of function values

  • x (float | ndarray) – Domain points (must be positive)

  • s (complex | ndarray) – Complex variable(s) for transform

  • method (str) – Computation method (“numerical”, “analytical”, “fft”)

Returns:

Transform values

Return type:

complex | ndarray

_numerical_method(f, x, s)[source]

Numerical integration method.

Parameters:
Return type:

complex | ndarray

_analytical_method(f, x, s)[source]

Analytical method for special functions.

Parameters:
Return type:

complex | ndarray

_fft_method(f, x, s)[source]

FFT-based method for efficient computation.

Parameters:
Return type:

complex | ndarray

inverse_transform(F, s, x, method='numerical')[source]

Compute inverse fractional Mellin transform.

Parameters:
Returns:

Original function values

Return type:

ndarray

_inverse_numerical(F, s, x)[source]

Numerical inverse transform.

Parameters:
Return type:

ndarray

_inverse_fft(F, s, x)[source]

FFT-based inverse transform.

Parameters:
Return type:

ndarray

hpfracc.algorithms.fractional_operator_methods.fractional_laplacian(f, x, alpha, h=None, method='spectral')[source]

Convenience function for fractional Laplacian.

Parameters:
Return type:

float | ndarray

hpfracc.algorithms.fractional_operator_methods.fractional_fourier_transform(f, x, alpha, h=None, method='auto')[source]

Convenience function for fractional Fourier transform.

Parameters:
Return type:

Tuple[ndarray, ndarray]

hpfracc.algorithms.fractional_operator_methods.fractional_z_transform(f, z, alpha, method='direct')[source]

Convenience function for fractional Z-transform.

Parameters:
Return type:

complex | ndarray

hpfracc.algorithms.fractional_operator_methods.fractional_mellin_transform(f, x, s, alpha, method='numerical')[source]

Convenience function for fractional Mellin transform.

Parameters:
Return type:

complex | ndarray

class hpfracc.algorithms.fractional_operator_methods.SpecialMethodsConfig(optimized=True, parallel=False)[source]

Bases: object

Configuration for special methods optimization.

Parameters:
__init__(optimized=True, parallel=False)[source]

Initialize special methods configuration.

Parameters:
  • optimized (bool) – Enable optimized implementations

  • parallel (bool) – Enable parallel processing (if available)

class hpfracc.algorithms.fractional_operator_methods.SpecialOptimizedWeylDerivative(alpha, config=None)[source]

Bases: object

Weyl derivative optimized using Fractional Fourier Transform.

This implementation replaces the standard FFT convolution approach with Fractional Fourier Transform for better performance, especially for large arrays and specific alpha values.

Parameters:
__init__(alpha, config=None)[source]

Initialize special optimized Weyl derivative calculator.

Parameters:
_determine_optimal_method()[source]

Determine the optimal computation method based on alpha value.

compute(f, x, h=None, method=None)[source]

Compute Weyl derivative using optimized method.

Parameters:
Return type:

float | ndarray

_compute_frft(f, x, h)[source]

Compute using Fractional Fourier Transform.

Parameters:
Return type:

ndarray

_compute_standard_fft(f, x, h)[source]

Compute using standard FFT approach.

Parameters:
Return type:

ndarray

_compute_hybrid(f, x, h)[source]

Compute using hybrid approach combining FRFT and standard FFT.

Parameters:
Return type:

ndarray

_compute_weyl_kernel(u, h)[source]

Compute Weyl derivative kernel.

Parameters:
Return type:

ndarray

class hpfracc.algorithms.fractional_operator_methods.SpecialOptimizedMarchaudDerivative(alpha, config=None)[source]

Bases: object

Marchaud derivative optimized using Fractional Z-Transform.

This implementation replaces the difference quotient convolution with Fractional Z-Transform for better performance on discrete signals.

Parameters:
__init__(alpha, config=None)[source]

Initialize special optimized Marchaud derivative calculator.

Parameters:
compute(f, x, h=None, method='z_transform')[source]

Compute Marchaud derivative using optimized method.

Parameters:
Return type:

float | ndarray

_compute_z_transform(f, x, h)[source]

Compute using Fractional Z-Transform.

Parameters:
Return type:

ndarray

_compute_standard(f, x, h)[source]

Compute using standard difference quotient approach.

Parameters:
Return type:

ndarray

class hpfracc.algorithms.fractional_operator_methods.SpecialOptimizedReizFellerDerivative(alpha, config=None)[source]

Bases: object

Reiz-Feller derivative optimized using Fractional Laplacian.

This implementation uses the Fractional Laplacian for efficient computation of the Reiz-Feller derivative, especially for spectral methods and large-scale problems.

Parameters:
__init__(alpha, config=None)[source]

Initialize special optimized Reiz-Feller derivative calculator.

Parameters:
compute(f, x, h=None, method='laplacian')[source]

Compute Reiz-Feller derivative using optimized method.

Parameters:
Return type:

float | ndarray

_compute_laplacian(f, x, h)[source]

Compute using Fractional Laplacian.

Parameters:
Return type:

ndarray

_compute_spectral(f, x, h)[source]

Compute using spectral method.

Parameters:
Return type:

ndarray

class hpfracc.algorithms.fractional_operator_methods.UnifiedSpecialMethods(config=None)[source]

Bases: object

Unified interface for all special methods with automatic method selection.

This class provides a unified API that automatically selects the best special method based on the problem characteristics.

Parameters:

config (SpecialMethodsConfig | None)

__init__(config=None)[source]

Initialize unified special methods interface.

Parameters:

config (SpecialMethodsConfig | None)

compute_derivative(f, x, alpha, h, method=None, problem_type='general')[source]

Compute fractional derivative using optimal special method.

Parameters:
  • f (Callable | ndarray) – Function or function values

  • x (ndarray) – Domain points

  • alpha (float | FractionalOrder) – Fractional order

  • h (float) – Step size

  • method (str | None) – Specific method to use (if None, auto-select)

  • problem_type (str) – Type of problem (“periodic”, “discrete”, “spectral”, “general”)

Returns:

Derivative values

Return type:

ndarray

_auto_select_method(problem_type, size, alpha)[source]

Automatically select the best method based on problem characteristics.

Parameters:
Return type:

str

hpfracc.algorithms.fractional_operator_methods.special_optimized_weyl_derivative(f, x, alpha, h=None, method=None)[source]

Convenience function for special optimized Weyl derivative.

Parameters:
Return type:

float | ndarray

hpfracc.algorithms.fractional_operator_methods.special_optimized_marchaud_derivative(f, x, alpha, h=None, method='z_transform')[source]

Convenience function for special optimized Marchaud derivative.

Parameters:
Return type:

float | ndarray

hpfracc.algorithms.fractional_operator_methods.special_optimized_reiz_feller_derivative(f, x, alpha, h=None, method='laplacian')[source]

Convenience function for special optimized Reiz-Feller derivative.

Parameters:
Return type:

float | ndarray

hpfracc.algorithms.fractional_operator_methods.unified_special_derivative(f, x, alpha, h, method=None, problem_type='general')[source]

Convenience function for unified special derivative computation.

Parameters:
Return type:

ndarray

Mathematical special functions

Special Functions Module

This module provides special mathematical functions used in fractional calculus: - Gamma and Beta functions - Binomial coefficients - Mittag-Leffler functions

hpfracc.special.gamma_function(x)[source]

Gamma function that is compatible with both JAX and NumPy/SciPy.

hpfracc.special.beta_function(x, y)[source]

Beta function that is compatible with both JAX and NumPy/SciPy.

hpfracc.special.gamma(x)[source]

Gamma function that is compatible with both JAX and NumPy/SciPy.

hpfracc.special.beta(x, y)[source]

Beta function that is compatible with both JAX and NumPy/SciPy.

hpfracc.special.log_gamma(z, use_jax=False)[source]

Convenience function to compute log Gamma function.

Parameters:
  • z (float | ndarray | jax.numpy.ndarray) – Input value(s)

  • use_jax (bool) – Whether to use JAX implementation

Returns:

Log Gamma function value(s)

Return type:

float | ndarray | jax.numpy.ndarray

hpfracc.special.binomial_coefficient(n, k, use_jax=False, use_numba=True)

Convenience function to compute binomial coefficient.

Parameters:
  • n (float | ndarray | jax.numpy.ndarray) – Upper parameter

  • k (float | ndarray | jax.numpy.ndarray) – Lower parameter

  • use_jax (bool) – Whether to use JAX implementation

  • use_numba (bool) – Whether to use NUMBA implementation

Returns:

Binomial coefficient value(s)

Return type:

float | ndarray | jax.numpy.ndarray

hpfracc.special.generalized_binomial(alpha, k, use_jax=False, use_numba=True)

Convenience function to compute fractional binomial coefficient.

Parameters:
  • alpha (float | ndarray | jax.numpy.ndarray) – Fractional parameter

  • k (int | ndarray | jax.numpy.ndarray) – Integer parameter

  • use_jax (bool) – Whether to use JAX implementation

  • use_numba (bool) – Whether to use NUMBA implementation

Returns:

Fractional binomial coefficient value(s)

Return type:

float | ndarray | jax.numpy.ndarray

hpfracc.special.mittag_leffler_function(alpha, beta, z, use_jax=False, use_numba=True)[source]

Optimized Mittag-Leffler function. Legacy arg order: alpha, beta, z.

hpfracc.special.mittag_leffler_derivative(alpha, beta, z, order=1)[source]

Compute the derivative of the Mittag-Leffler function.

hpfracc.special.mittag_leffler_fast(z, alpha, beta=1.0)[source]

Fast Mittag-Leffler function optimized for fractional calculus.

hpfracc.special.mittag_leffler(z, alpha, beta=1.0, use_jax=False, use_numba=True)[source]