Core API Reference

Core module providing fundamental definitions, utilities, and base classes.

When you import hpfracc.core as a package, only hpfracc.core.definitions is loaded immediately; hpfracc.core.utilities, hpfracc.core.derivatives, and hpfracc.core.integrals (and their re-exported names) load on first attribute access. Importing submodules directly (e.g. import hpfracc.core.integrals) is unchanged.

Fractional Order Definitions

Mathematical definitions for fractional calculus.

This module provides the fundamental mathematical definitions and properties of fractional derivatives and integrals, which form the theoretical foundation for the numerical implementations.

class hpfracc.core.definitions.FractionalOrder(alpha, validate=True, method=None)[source]

Bases: object

Represents a fractional order with validation and properties.

The fractional order α can be any real number, but typically we consider 0 < α < 2 for most applications.

Parameters:
__init__(alpha, validate=True, method=None)[source]

Initialize fractional order.

Parameters:
_validate()[source]

Validate the fractional order.

property value: float

Get the fractional order value.

property is_integer: bool

Check if the order is an integer.

property is_fractional: bool

Check if the order is fractional (not integer).

property integer_part: int

Get the integer part of the fractional order.

property fractional_part: float

Get the fractional part of the fractional order.

class hpfracc.core.definitions.DefinitionType(value)[source]

Bases: Enum

Enumeration of fractional derivative definitions.

CAPUTO = 'caputo'
RIEMANN_LIOUVILLE = 'riemann_liouville'
GRUNWALD_LETNIKOV = 'grunwald_letnikov'
MILLER_ROSS = 'miller_ross'
WEYL = 'weyl'
MARCHAUD = 'marchaud'
class hpfracc.core.definitions.FractionalDefinition(order, definition_type)[source]

Bases: object

Base class for fractional derivative definitions.

This class provides the mathematical framework for different definitions of fractional derivatives and integrals.

Parameters:
__init__(order, definition_type)[source]

Initialize fractional definition.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition_type (DefinitionType) – Type of fractional definition

get_definition_formula()[source]

Get the mathematical formula for this definition.

Return type:

str

get_properties()[source]

Get mathematical properties of this definition.

Return type:

Dict[str, Any]

class hpfracc.core.definitions.CaputoDefinition(order)[source]

Bases: FractionalDefinition

Caputo fractional derivative definition.

The Caputo derivative is defined as: D^α f(x) = (1/Γ(n-α)) ∫₀^x (x-t)^(n-α-1) f^(n)(t) dt

where n = ⌈α⌉ is the smallest integer greater than or equal to α.

Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional definition.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition_type – Type of fractional definition

property n: int

Get the smallest integer n such that n-1 < α ≤ n.

get_advantages()[source]

Get advantages of the Caputo definition.

Return type:

list

get_limitations()[source]

Get limitations of the Caputo definition.

Return type:

list

class hpfracc.core.definitions.RiemannLiouvilleDefinition(order)[source]

Bases: FractionalDefinition

Riemann-Liouville fractional derivative definition.

The Riemann-Liouville derivative is defined as: D^α f(x) = (1/Γ(n-α)) (d/dx)^n ∫₀^x (x-t)^(n-α-1) f(t) dt

where n = ⌈α⌉ is the smallest integer greater than or equal to α.

Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional definition.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition_type – Type of fractional definition

property n: int

Get the smallest integer n such that n-1 < α ≤ n.

get_advantages()[source]

Get advantages of the Riemann-Liouville definition.

Return type:

list

get_limitations()[source]

Get limitations of the Riemann-Liouville definition.

Return type:

list

class hpfracc.core.definitions.GrunwaldLetnikovDefinition(order)[source]

Bases: FractionalDefinition

Grünwald-Letnikov fractional derivative definition.

The Grünwald-Letnikov derivative is defined as: D^α f(x) = lim_{h→0} h^(-α) Σ_{k=0}^∞ (-1)^k C(α,k) f(x-kh)

where C(α,k) are the generalized binomial coefficients.

Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional definition.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition_type – Type of fractional definition

get_advantages()[source]

Get advantages of the Grünwald-Letnikov definition.

Return type:

list

get_limitations()[source]

Get limitations of the Grünwald-Letnikov definition.

Return type:

list

class hpfracc.core.definitions.FractionalIntegral(order)[source]

Bases: object

Fractional integral definition.

The Riemann-Liouville fractional integral of order α > 0 is defined as: I^α f(x) = (1/Γ(α)) ∫₀^x (x-t)^(α-1) f(t) dt

Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional integral.

Parameters:

order (float | FractionalOrder) – Fractional order (must be positive)

get_formula()[source]

Get the mathematical formula for the fractional integral.

Return type:

str

get_properties()[source]

Get mathematical properties of the fractional integral.

Return type:

Dict[str, Any]

class hpfracc.core.definitions.FractionalCalculusProperties[source]

Bases: object

Mathematical properties and relationships in fractional calculus.

static linearity_property()[source]

Get the linearity property.

Return type:

str

static semigroup_property()[source]

Get the semigroup property.

Return type:

str

static leibniz_rule()[source]

Get the generalized Leibniz rule.

Return type:

str

static chain_rule()[source]

Get the generalized chain rule.

Return type:

str

static relationship_between_definitions()[source]

Get relationships between different definitions.

Return type:

Dict[str, str]

static get_analytical_solutions()[source]

Get analytical solutions for common functions.

Return type:

Dict[str, str]

get_properties()[source]

Get all fractional calculus properties.

Return type:

Dict[str, Any]

get_definition_properties()[source]

Get properties specific to fractional derivative definitions.

Return type:

Dict[str, str]

get_integral_properties()[source]

Get properties specific to fractional integrals.

Return type:

Dict[str, Any]

hpfracc.core.definitions.create_definition(definition_type, alpha)[source]

Create a fractional derivative definition.

Parameters:
  • definition_type (str | DefinitionType) – Type of definition

  • alpha (float | FractionalOrder) – Fractional order

Returns:

Fractional derivative definition object

Return type:

FractionalDefinition

hpfracc.core.definitions.get_available_definitions()[source]

Get list of available fractional derivative definitions.

Return type:

list

hpfracc.core.definitions.validate_fractional_order(alpha, min_value=0.0, max_value=2.0)[source]

Validate fractional order within specified range.

Parameters:
  • alpha (float) – Fractional order to validate

  • min_value (float) – Minimum allowed value

  • max_value (float) – Maximum allowed value

Returns:

True if valid, False otherwise

Return type:

bool

Core Utilities

Core Utilities Module

This module provides common utility functions used throughout the HPFRACC library: - Mathematical utilities and helper functions - Type checking and validation utilities - Performance monitoring utilities - Error handling and debugging utilities - Common mathematical operations

hpfracc.core.utilities._get_torch()[source]

Lazy import torch to avoid CuDNN loading errors.

hpfracc.core.utilities.factorial_fractional(n)[source]

Compute factorial for integer and fractional values.

Parameters:

n (int | float) – Number to compute factorial for

Returns:

Factorial value

Return type:

float

hpfracc.core.utilities.binomial_coefficient(n, k)[source]

Compute binomial coefficient for real numbers.

Parameters:
Returns:

Binomial coefficient value

Return type:

float

hpfracc.core.utilities.pochhammer_symbol(x, n)[source]

Compute Pochhammer symbol (x)_n = x(x+1)…(x+n-1).

Parameters:
  • x (float) – Base value

  • n (int) – Number of factors

Returns:

Pochhammer symbol value

Return type:

float

hpfracc.core.utilities._hypergeometric_series_impl(a, b, z, max_terms=100)[source]

Internal implementation of hypergeometric series.

Parameters:
Return type:

float

hpfracc.core.utilities.hypergeometric_series(a, b, z, max_terms=100)[source]

Compute hypergeometric series pFq(a; b; z).

Parameters:
  • a (float | List[float]) – Upper parameter(s) - can be float or list of floats

  • b (float | List[float]) – Lower parameter(s) - can be float or list of floats

  • z (float) – Variable

  • max_terms (int) – Maximum number of terms to compute

Returns:

Hypergeometric series value

Return type:

float

hpfracc.core.utilities.bessel_function_first_kind(nu, x)[source]

Compute Bessel function of the first kind J_ν(x).

Parameters:
  • nu (float) – Order of Bessel function

  • x (float) – Argument

Returns:

Bessel function value

Return type:

float

hpfracc.core.utilities.modified_bessel_function_first_kind(nu, x)[source]

Compute modified Bessel function of the first kind I_ν(x).

Parameters:
  • nu (float) – Order of Bessel function

  • x (float) – Argument

Returns:

Modified Bessel function value

Return type:

float

hpfracc.core.utilities.validate_fractional_order(alpha, min_val=0.0, max_val=2.0)[source]

Validate and convert fractional order.

Parameters:
Returns:

True if fractional order is valid

Return type:

bool

hpfracc.core.utilities.validate_function(f, domain=(0.0, 1.0), n_points=100)[source]

Validate that a function is callable and well-behaved on a domain.

Parameters:
  • f (Callable) – Function to validate

  • domain (Tuple[float, float]) – Domain to test on (min, max)

  • n_points (int) – Number of test points

Returns:

True if function is valid

Return type:

bool

hpfracc.core.utilities.validate_tensor_input(x, expected_shape=None)[source]

Validate tensor input for fractional calculus operations.

Parameters:
  • x (ndarray | torch.Tensor) – Input tensor

  • expected_shape (Tuple | None) – Expected shape (optional)

Returns:

True if input is valid

Return type:

bool

hpfracc.core.utilities.timing_decorator(func)[source]

Decorator to measure function execution time.

Parameters:

func (Callable) – Function to time

Returns:

Wrapped function with timing

Return type:

Callable

hpfracc.core.utilities.memory_usage_decorator(func)[source]

Decorator to monitor memory usage.

Parameters:

func (Callable) – Function to monitor

Returns:

Wrapped function with memory monitoring

Return type:

Callable

class hpfracc.core.utilities.PerformanceMonitor[source]

Bases: object

Performance monitoring utility for tracking execution times and memory usage.

__init__()[source]
start_timer(name)[source]

Start timing an operation.

Parameters:

name (str)

end_timer(name)[source]

End timing an operation and return duration.

Parameters:

name (str)

Return type:

float

get_statistics()[source]

Get performance statistics.

Return type:

Dict[str, Any]

timer(name)[source]

Context manager for timing operations.

Parameters:

name (str)

memory_tracker(name)[source]

Context manager for memory tracking.

Parameters:

name (str)

reset()[source]

Reset all statistics.

class hpfracc.core.utilities.TimerContext(monitor, name)[source]

Bases: object

Context manager for timing operations.

Parameters:
  • monitor (PerformanceMonitor)

  • name (str)

__init__(monitor, name)[source]
Parameters:
  • monitor (PerformanceMonitor)

  • name (str)

class hpfracc.core.utilities.MemoryTrackerContext(monitor, name)[source]

Bases: object

Context manager for memory tracking.

Parameters:
  • monitor (PerformanceMonitor)

  • name (str)

__init__(monitor, name)[source]
Parameters:
  • monitor (PerformanceMonitor)

  • name (str)

exception hpfracc.core.utilities.FractionalCalculusError[source]

Bases: Exception

Base exception for fractional calculus operations.

exception hpfracc.core.utilities.ConvergenceError[source]

Bases: FractionalCalculusError

Exception raised when numerical methods fail to converge.

exception hpfracc.core.utilities.ValidationError[source]

Bases: FractionalCalculusError

Exception raised when input validation fails.

hpfracc.core.utilities.safe_divide(numerator, denominator, default=0.0)[source]

Safely divide two numbers, handling division by zero.

Parameters:
  • numerator (float) – Numerator

  • denominator (float) – Denominator

  • default (float) – Default value if denominator is zero

Returns:

Division result or default value

Return type:

float

hpfracc.core.utilities.check_numerical_stability(values, tolerance=1e-10)[source]

Check if numerical values are stable.

Parameters:
  • values (ndarray | torch.Tensor) – Array of values to check

  • tolerance (float) – Tolerance for stability check

Returns:

True if values are stable

Return type:

bool

hpfracc.core.utilities.vectorize_function(func, vectorize=True)[source]

Vectorize a scalar function for array inputs.

Parameters:
  • func (Callable) – Scalar function to vectorize

  • vectorize (bool) – Whether to use numpy vectorize

Returns:

Vectorized function

Return type:

Callable

hpfracc.core.utilities.normalize_array(arr, norm_type='l2', method=None)[source]

Normalize an array using different norm types.

Parameters:
  • arr (ndarray | torch.Tensor) – Array to normalize

  • norm_type (str) – Type of normalization (“l1”, “l2”, “max”, “minmax”)

  • method (str | None) – Alias for norm_type (for backward compatibility)

Returns:

Normalized array

Return type:

ndarray | torch.Tensor

hpfracc.core.utilities.smooth_function(func, smoothing_factor=0.1)[source]

Create a smoothed version of a function using convolution.

Parameters:
  • func (Callable) – Original function

  • smoothing_factor (float) – Smoothing factor (0-1)

Returns:

Smoothed function

Return type:

Callable

hpfracc.core.utilities.fractional_power(x, alpha)[source]

Compute fractional power with proper handling of negative values.

Parameters:
  • x (float | ndarray | torch.Tensor) – Base value(s)

  • alpha (float) – Fractional exponent

Returns:

Fractional power result

Return type:

float | ndarray | torch.Tensor

hpfracc.core.utilities.fractional_exponential(x, alpha)[source]

Compute fractional exponential function.

Parameters:
  • x (float | ndarray | torch.Tensor) – Input value(s)

  • alpha (float) – Fractional order

Returns:

Fractional exponential result

Return type:

float | ndarray | torch.Tensor

hpfracc.core.utilities.get_default_precision()[source]

Get default numerical precision for the library.

Return type:

int

hpfracc.core.utilities.set_default_precision(precision)[source]

Set default numerical precision for the library.

Parameters:

precision (int)

hpfracc.core.utilities.get_available_methods()[source]

Get list of available fractional calculus methods.

Return type:

List[str]

hpfracc.core.utilities.get_method_properties(method)[source]

Get properties of a specific fractional calculus method.

Parameters:

method (str) – Method name

Returns:

Dictionary of method properties

Return type:

Dict[str, Any]

hpfracc.core.utilities.setup_logging(name='INFO', log_file=None, level='INFO')[source]

Setup logging for the HPFRACC library.

Parameters:
  • level (str) – Logging level

  • log_file (str | None) – Optional log file path

  • name (str)

Returns:

Logger instance

hpfracc.core.utilities.get_logger(name='hpfracc')[source]

Get a logger for the HPFRACC library.

Parameters:

name (str) – Logger name

Returns:

Logger instance

Return type:

Logger

Main Module

High-Performance Fractional Calculus Library (hpfracc)

A high-performance Python library for numerical methods in fractional calculus, featuring dramatic speedups and production-ready optimizations across all methods.

This library provides optimized implementations of: - Core fractional derivatives: Caputo, Riemann-Liouville, Grünwald-Letnikov - Advanced methods: Weyl, Marchaud, Hadamard, Reiz-Feller derivatives - Fractional operator extensions (Laplacian, FrFT, Z/Mellin): see hpfracc.algorithms.fractional_operator_methods (not hpfracc.special, which is Γ / binomial / Mittag–Leffler) - GPU acceleration via JAX, PyTorch, and CuPy - Parallel computing via NUMBA

hpfracc.OptimizedRiemannLiouville

alias of RiemannLiouville

hpfracc.OptimizedCaputo

alias of Caputo

hpfracc.OptimizedGrunwaldLetnikov

alias of GrunwaldLetnikov

hpfracc.optimized_riemann_liouville(f, t, alpha, h=None)[source]
class hpfracc.FractionalOrder(alpha, validate=True, method=None)[source]

Bases: object

Represents a fractional order with validation and properties.

The fractional order α can be any real number, but typically we consider 0 < α < 2 for most applications.

Parameters:
__init__(alpha, validate=True, method=None)[source]

Initialize fractional order.

Parameters:
_validate()[source]

Validate the fractional order.

property value: float

Get the fractional order value.

property is_integer: bool

Check if the order is an integer.

property is_fractional: bool

Check if the order is fractional (not integer).

property integer_part: int

Get the integer part of the fractional order.

property fractional_part: float

Get the fractional part of the fractional order.

class hpfracc.WeylDerivative(alpha, parallel_config=None, optimized=True, **kwargs)[source]

Bases: object

Weyl fractional derivative via FFT Convolution with parallelization.

The Weyl derivative is defined as: D^α f(x) = (1/Γ(n-α)) (d/dx)^n ∫_x^∞ (τ-x)^(n-α-1) f(τ) dτ

This implementation uses FFT convolution for efficiency and parallel processing.

Parameters:
__init__(alpha, parallel_config=None, optimized=True, **kwargs)[source]

Initialize Weyl derivative calculator.

Parameters:
compute(f, x, h=None, use_parallel=True)[source]

Compute Weyl derivative using optimized FFT convolution.

Parameters:
Return type:

float | ndarray

_compute_serial(f, x, h)[source]

Serial computation using optimized FFT convolution.

Parameters:
Return type:

ndarray

_compute_parallel(f, x, h)[source]

Parallel computation using chunked processing.

Parameters:
Return type:

ndarray

_process_chunk(chunk_data)[source]

Process a chunk of data for parallel computation.

Parameters:

chunk_data (Tuple[ndarray, ndarray, float])

Return type:

ndarray

class hpfracc.MarchaudDerivative(alpha, parallel_config=None, **kwargs)[source]

Bases: object

Marchaud fractional derivative with Difference Quotient convolution and memory optimization.

The Marchaud derivative is defined as: D^α f(x) = α/Γ(1-α) ∫_0^∞ [f(x) - f(x-τ)] / τ^(α+1) dτ

This implementation uses difference quotient convolution with memory optimization.

Parameters:
__init__(alpha, parallel_config=None, **kwargs)[source]

Initialize Marchaud derivative calculator.

Parameters:
compute(f, x, h=None, use_parallel=True, memory_optimized=True)[source]

Compute Marchaud derivative with memory optimization.

Parameters:
Return type:

float | ndarray

_compute_memory_optimized(f, x, h, use_parallel)[source]

Memory-optimized computation using streaming approach.

Parameters:
Return type:

ndarray

_process_marchaud_chunk(chunk_data)[source]

Process a chunk for Marchaud derivative.

Parameters:

chunk_data (Tuple[ndarray, ndarray, float, int, int])

Return type:

ndarray

_compute_marchaud_segment(f, x, h, start_idx, end_idx)[source]

Compute Marchaud derivative for a segment.

Parameters:
Return type:

ndarray

_compute_standard(f, x, h, use_parallel)[source]

Standard computation without memory optimization.

Parameters:
Return type:

ndarray

class hpfracc.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.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.RiemannLiouvilleIntegral(order)[source]

Bases: FractionalIntegral

Riemann-Liouville fractional integral.

The Riemann-Liouville fractional integral of order α is defined as:

I^α f(t) = (1/Γ(α)) ∫₀ᵗ (t-τ)^(α-1) f(τ) dτ

where Γ(α) is the gamma function.

Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional integral.

Parameters:
  • order (float | FractionalOrder) – Fractional order (0 < α < 1 for most methods)

  • method – Integration method (“RL”, “Caputo”, “Weyl”, “Hadamard”)

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

Compute Riemann-Liouville fractional integral (alias for __call__).

Parameters:
  • f (Callable) – Function to integrate

  • x (float | ndarray | torch.Tensor) – Point(s) at which to evaluate the integral

  • h (float)

Returns:

Fractional integral value(s)

Return type:

float | ndarray | torch.Tensor

_coerce_function(f, x_arg)[source]

If f is an array, create an interpolating callable over x grid.

Parameters:
Return type:

Callable

_compute_scalar(f, x)[source]

Compute fractional integral at a scalar point.

Parameters:
Return type:

float

_compute_array_numpy(f, x)[source]

Compute fractional integral for numpy array.

Parameters:
Return type:

ndarray

_compute_array_torch(f, x)[source]

Compute fractional integral for torch tensor.

Parameters:
Return type:

torch.Tensor

class hpfracc.CaputoIntegral(order)[source]

Bases: FractionalIntegral

Caputo fractional integral.

The Caputo fractional integral is related to the Riemann-Liouville integral and is often more suitable for initial value problems.

Supports all fractional orders α ≥ 0: - For 0 < α < 1: Equals Riemann-Liouville integral - For α ≥ 1: Uses decomposition I^α = I^n * I^β where α = n + β

Examples

>>> from hpfracc.core.integrals import CaputoIntegral
>>> def f(x): return x**2
>>> # For 0 < α < 1
>>> integral_05 = CaputoIntegral(0.5)
>>> result = integral_05(f, 1.0)
>>> # For α ≥ 1
>>> integral_15 = CaputoIntegral(1.5)
>>> result = integral_15(f, 1.0)
Parameters:

order (float | FractionalOrder)

__init__(order)[source]

Initialize fractional integral.

Parameters:
  • order (float | FractionalOrder) – Fractional order (0 < α < 1 for most methods)

  • method – Integration method (“RL”, “Caputo”, “Weyl”, “Hadamard”)

_coerce_function(f, x_arg)[source]

If f is an array, create an interpolating callable over x grid.

Parameters:
Return type:

Callable

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

Alias for __call__; accepts an optional step size h for compatibility.

Parameters:
Return type:

float | ndarray | torch.Tensor

class hpfracc.CaputoFabrizioDerivative(order, **kwargs)[source]

Bases: BaseFractionalDerivative

Caputo-Fabrizio fractional derivative implementation.

Uses the novel implementation from algorithms.

Parameters:

order (float | FractionalOrder)

__init__(order, **kwargs)[source]

Initialize fractional derivative.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition – Mathematical definition

  • use_jax – Whether to use JAX optimizations

  • use_numba – Whether to use NUMBA optimizations

compute(f, x, **kwargs)[source]

Compute the Caputo-Fabrizio fractional derivative.

Parameters:
Return type:

float | ndarray

compute_numerical(f_values, x_values, **kwargs)[source]

Compute the derivative numerically from function values.

Parameters:
Return type:

ndarray

class hpfracc.AtanganaBaleanuDerivative(order, **kwargs)[source]

Bases: BaseFractionalDerivative

Atangana-Baleanu fractional derivative implementation.

Uses the novel implementation from algorithms.

Parameters:

order (float | FractionalOrder)

__init__(order, **kwargs)[source]

Initialize fractional derivative.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition – Mathematical definition

  • use_jax – Whether to use JAX optimizations

  • use_numba – Whether to use NUMBA optimizations

compute(f, x, **kwargs)[source]

Compute the Atangana-Baleanu fractional derivative.

Parameters:
Return type:

float | ndarray

compute_numerical(f_values, x_values, **kwargs)[source]

Compute the derivative numerically from function values.

Parameters:
Return type:

ndarray

hpfracc.RiemannLiouville

alias of RiemannLiouvilleDerivative

class hpfracc.RiemannLiouvilleDerivative(order, **kwargs)[source]

Bases: BaseFractionalDerivative

Riemann-Liouville fractional derivative — adapter over the canonical engine hpfracc.algorithms.derivatives.RiemannLiouville.

Parameters:

order (float | FractionalOrder)

__init__(order, **kwargs)[source]

Initialize fractional derivative.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition – Mathematical definition

  • use_jax – Whether to use JAX optimizations

  • use_numba – Whether to use NUMBA optimizations

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

Compute the Riemann-Liouville fractional derivative.

Parameters:
Return type:

float | ndarray

compute_numerical(f_values, x_values, **kwargs)[source]

Compute the derivative numerically from function values.

Parameters:
Return type:

ndarray

hpfracc.Caputo

alias of CaputoDerivative

class hpfracc.CaputoDerivative(order, **kwargs)[source]

Bases: BaseFractionalDerivative

Caputo fractional derivative — adapter over the canonical engine hpfracc.algorithms.derivatives.Caputo (single implementation path).

Parameters:

order (float | FractionalOrder)

__init__(order, **kwargs)[source]

Initialize fractional derivative.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition – Mathematical definition

  • use_jax – Whether to use JAX optimizations

  • use_numba – Whether to use NUMBA optimizations

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

Compute the Caputo fractional derivative.

Parameters:
Return type:

float | ndarray

compute_numerical(f_values, x_values, **kwargs)[source]

Compute the derivative numerically from function values.

Parameters:
Return type:

ndarray

hpfracc.GrunwaldLetnikov

alias of GrunwaldLetnikovDerivative

class hpfracc.GrunwaldLetnikovDerivative(order, **kwargs)[source]

Bases: BaseFractionalDerivative

Grünwald–Letnikov fractional derivative — adapter over the canonical engine hpfracc.algorithms.derivatives.GrunwaldLetnikov.

Parameters:

order (float | FractionalOrder)

__init__(order, **kwargs)[source]

Initialize fractional derivative.

Parameters:
  • order (float | FractionalOrder) – Fractional order

  • definition – Mathematical definition

  • use_jax – Whether to use JAX optimizations

  • use_numba – Whether to use NUMBA optimizations

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

Compute the Grunwald-Letnikov fractional derivative.

Parameters:
Return type:

float | ndarray

compute_numerical(f_values, x_values, **kwargs)[source]

Compute the derivative numerically from function values.

Parameters:
Return type:

ndarray

class hpfracc.HadamardDerivative(alpha=None, order=None, **kwargs)[source]

Bases: object

Hadamard fractional derivative.

The Hadamard derivative is defined as: D^α f(x) = (1/Γ(n-α)) (x d/dx)^n ∫_1^x (log(x/t))^(n-α-1) f(t) dt/t

This implementation uses logarithmic transformation and efficient quadrature.

Parameters:
__init__(alpha=None, order=None, **kwargs)[source]

Initialize Hadamard derivative calculator.

Accepts both alpha and order for backward compatibility.

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

Compute Hadamard derivative using logarithmic transformation.

Parameters:
Return type:

float | ndarray

_compute_hadamard(f, x, h)[source]

Compute Hadamard derivative using logarithmic transformation.

Parameters:
Return type:

ndarray

class hpfracc.ReizFellerDerivative(alpha, parallel_config=None, **kwargs)[source]

Bases: object

Reiz-Feller fractional derivative via spectral method.

The Reiz-Feller derivative is defined as: \(D^{\alpha} f(x) = \frac{1}{2\pi} \int_{-\infty}^{\infty} |\xi|^{\alpha} \, \mathcal{F}[f](\xi) \, e^{i\xi x} \, d\xi\)

This implementation uses FFT for spectral computation.

Parameters:
__init__(alpha, parallel_config=None, **kwargs)[source]

Initialize Reiz-Feller derivative calculator.

Parameters:
compute(f, x, h=None, use_parallel=True)[source]

Compute Reiz-Feller derivative using spectral method.

Parameters:
Return type:

float | ndarray

_compute_spectral(f, x, h, use_parallel)[source]

Compute using spectral method with FFT.

Parameters:
Return type:

ndarray

class hpfracc.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.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